Apache Cordova
  1. Apache Cordova
  2. CB-587

CallbackServer.run() SocketException on ICS 4.0.4

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Critical Critical
    • Resolution: Not a Problem
    • Affects Version/s: 1.4.0, 1.7.0
    • Fix Version/s: 2.2.0
    • Component/s: Android
    • Labels:
      None
    • Environment:

      Motorola Xoom ICS 4.0.4.
      PhoneGap 1.7.0rc1 example application.

      Description

      I have recently started to see SocketExceptions from CallbackServer.run() on my Motorola Xoom. I don't know exactly when it started, but it would appear to line up with the update of the Xoom to ICS 4.0.4 that occurred a couple of weeks (or so) ago. I don't recall seeing it on the previous version of ICS (4.0.3?).

      The exception information from LogCat follows:

      04-26 15:57:58.730: W/System.err(10655): java.net.SocketException: sendto failed: ETIMEDOUT (Connection timed out)
      04-26 15:57:58.730: W/System.err(10655): at libcore.io.IoBridge.maybeThrowAfterSendto(IoBridge.java:496)
      04-26 15:57:58.730: W/System.err(10655): at libcore.io.IoBridge.sendto(IoBridge.java:465)
      04-26 15:57:58.740: W/System.err(10655): at java.net.PlainSocketImpl.write(PlainSocketImpl.java:507)
      04-26 15:57:58.740: W/System.err(10655): at java.net.PlainSocketImpl.access$100(PlainSocketImpl.java:46)
      04-26 15:57:58.740: W/System.err(10655): at java.net.PlainSocketImpl$PlainSocketOutputStream.write(PlainSocketImpl.java:269)
      04-26 15:57:58.740: W/System.err(10655): at java.io.OutputStream.write(OutputStream.java:82)
      04-26 15:57:58.740: W/System.err(10655): at java.io.DataOutputStream.writeBytes(DataOutputStream.java:156)
      04-26 15:57:58.740: W/System.err(10655): at org.apache.cordova.CallbackServer.run(CallbackServer.java:275)
      04-26 15:57:58.740: W/System.err(10655): at java.lang.Thread.run(Thread.java:856)
      04-26 15:57:58.740: W/System.err(10655): Caused by: libcore.io.ErrnoException: sendto failed: ETIMEDOUT (Connection timed out)
      04-26 15:57:58.740: W/System.err(10655): at libcore.io.Posix.sendtoBytes(Native Method)
      04-26 15:57:58.750: W/System.err(10655): at libcore.io.Posix.sendto(Posix.java:146)
      04-26 15:57:58.750: W/System.err(10655): at libcore.io.BlockGuardOs.sendto(BlockGuardOs.java:177)
      04-26 15:57:58.750: W/System.err(10655): at libcore.io.IoBridge.sendto(IoBridge.java:463)
      04-26 15:57:58.750: W/System.err(10655): ... 7 more

      This may be related to another issue that I have noticed with ICS 4.0.4 which is that it drops the WIFI connection a lot. It drops it WAY more frequently than the previous version did even with "Keep Wi-Fi on during sleep" set to "Always".

      My app is based on PhoneGap v1.4.0. I see this exception with my app on the Xoom. I have not seen it on my Samsung Galaxy S with 2.3.3 on it.

      The LogCat information above is from the 1.7.0rc1. For this test I simply created a new Android application in Eclipse using the Android example code as is. The exception happens even without interacting with the example app. Just leave it sit there and eventually... boom.

      1. PGexample-2.0.0.zip
        600 kB
        Wayne Fisher
      2. log.txt
        4 kB
        Wayne Fisher

        Issue Links

          Activity

          Hide
          Wayne Fisher added a comment -

          I have attached a slightly longer copy of the LogCat information.

          Show
          Wayne Fisher added a comment - I have attached a slightly longer copy of the LogCat information.
          Hide
          Joe Bowser added a comment -

          Can you go to the Device Library and grab the Xoom, make sure it has ICS 4.0.4 and run it. Ours is too hacked and Canadian to be useful for this bug.

          Show
          Joe Bowser added a comment - Can you go to the Device Library and grab the Xoom, make sure it has ICS 4.0.4 and run it. Ours is too hacked and Canadian to be useful for this bug.
          Hide
          Wayne Fisher added a comment -

          Have you been able to reproduce this issue on your device?

          I can run some tests on my Xoom if you have something for me to test.

          Show
          Wayne Fisher added a comment - Have you been able to reproduce this issue on your device? I can run some tests on my Xoom if you have something for me to test.
          Hide
          Anis Kadri added a comment -

          I wasn't able to find a motorola Xoom with that specific ICS version. I will keep looking. Hopefully this will get fixed in 1.8.0

          Show
          Anis Kadri added a comment - I wasn't able to find a motorola Xoom with that specific ICS version. I will keep looking. Hopefully this will get fixed in 1.8.0
          Hide
          Wayne Fisher added a comment -

          The Xoom I have is the US WiFi only model.

          The ICS version on it is the most recent OS version available for it.

          This is an annoying bug since, from the user's perspective, parts of the app silently stop working.

          Show
          Wayne Fisher added a comment - The Xoom I have is the US WiFi only model. The ICS version on it is the most recent OS version available for it. This is an annoying bug since, from the user's perspective, parts of the app silently stop working.
          Hide
          Joe Bowser added a comment -

          I've updated my Galaxy Nexus to 4.0.4, and I don't notice this on the Galaxy Nexus, which makes me think that this may be platform-related and confined to the Xoom.

          Show
          Joe Bowser added a comment - I've updated my Galaxy Nexus to 4.0.4, and I don't notice this on the Galaxy Nexus, which makes me think that this may be platform-related and confined to the Xoom.
          Hide
          Joe Bowser added a comment -

          Moving to minor, because 4.0.4 isn't common yet and we might not be able to fix it in 1.8.

          Show
          Joe Bowser added a comment - Moving to minor, because 4.0.4 isn't common yet and we might not be able to fix it in 1.8.
          Hide
          Wayne Fisher added a comment -

          Any progress or update on this issue?

          A customer reported an issue to me related to this issue. This customer was unable to use the camera functionality of my app. When this exception occurs, it appears to take out all (or at least most of) PhoneGap's functionality.

          This customer also had an in-app purchase not come through to him which is also likely related to this issue. My in-app purchases are implemented as a PhoneGap plugin, so if PhoneGap has died, then the plugin is also likely dead.

          One difference for this customer is that he has 4.0.3 running on his Xoom instead of the 4.0.4 that is running on mine.

          Show
          Wayne Fisher added a comment - Any progress or update on this issue? A customer reported an issue to me related to this issue. This customer was unable to use the camera functionality of my app. When this exception occurs, it appears to take out all (or at least most of) PhoneGap's functionality. This customer also had an in-app purchase not come through to him which is also likely related to this issue. My in-app purchases are implemented as a PhoneGap plugin, so if PhoneGap has died, then the plugin is also likely dead. One difference for this customer is that he has 4.0.3 running on his Xoom instead of the 4.0.4 that is running on mine.
          Hide
          Joe Bowser added a comment -

          I apologize for this, but we couldn't reproduce this issue on our end. We still have to test on a Xoom. :S

          Show
          Joe Bowser added a comment - I apologize for this, but we couldn't reproduce this issue on our end. We still have to test on a Xoom. :S
          Hide
          Joe Bowser added a comment -

          Got the XOOM here, turns out that we can't reproduce this on the stock firmware. Going to have to close this ticket based on these last tests.

          Show
          Joe Bowser added a comment - Got the XOOM here, turns out that we can't reproduce this on the stock firmware. Going to have to close this ticket based on these last tests.
          Hide
          Wayne Fisher added a comment -

          What was the environment that you used for the test? What was the version of Cordova/PhoneGap that you used and what version of Android do you have on your Xoom? Did you use a clean version of the example code?

          Once I know what you used for your test, I will try to match it (as close as possible) with my setup and see if we get the same result.

          Show
          Wayne Fisher added a comment - What was the environment that you used for the test? What was the version of Cordova/PhoneGap that you used and what version of Android do you have on your Xoom? Did you use a clean version of the example code? Once I know what you used for your test, I will try to match it (as close as possible) with my setup and see if we get the same result.
          Hide
          Joe Bowser added a comment -

          Motorola Xoom Wifi Only (MZ604)
          Build Number: IMM76
          Android Version: 4.0.4

          I tested this using Cordova 2.0.0 and Mobile Spec, which is our test suite. You can find this on github here: https://github.com/apache/incubator-cordova-mobile-spec

          Show
          Joe Bowser added a comment - Motorola Xoom Wifi Only (MZ604) Build Number: IMM76 Android Version: 4.0.4 I tested this using Cordova 2.0.0 and Mobile Spec, which is our test suite. You can find this on github here: https://github.com/apache/incubator-cordova-mobile-spec
          Hide
          Wayne Fisher added a comment -

          I had some difficulty reproducing the issue even when going back to the v1.7.0 example that I first used.

          Then I realized that the WIFI on my Xoom has been more stable lately (don't know why). Working on the theory that it is related to WIFI stability, I was then able to reproduce the issue using both the v1.7.0 and v2.0.0 example apps.

          I reproduced it in two ways.

          First, I started the example app and tapped on "Toggle Accelerometer" to be able to see the live updating of the accelerometer readings. Then I used the settings app to turn off WIFI. Eclipse then caught the SocketException and the accelerometer readings stopped being updated. I then let the app run and let the exception occur and crash the thread and the accelerometer data remained frozen.

          Second, with WIFI back on, I restarted the app and started the accelerometer again. I then took my Xoom outside and walked away from my access point until it lost the network connection. The accelerometer data stopped updating around the same time as the WIFI connection was lost. Bringing the Xoom back in and view the LogCat, I saw the SocketException in the log.

          So, it appears that the issue is related to the loss of the WIFI connection.

          An interesting thing I noticed though, is that it is not all dead. The compass reading continues to update even after the SocketException has occurred.

          Show
          Wayne Fisher added a comment - I had some difficulty reproducing the issue even when going back to the v1.7.0 example that I first used. Then I realized that the WIFI on my Xoom has been more stable lately (don't know why). Working on the theory that it is related to WIFI stability, I was then able to reproduce the issue using both the v1.7.0 and v2.0.0 example apps. I reproduced it in two ways. First, I started the example app and tapped on "Toggle Accelerometer" to be able to see the live updating of the accelerometer readings. Then I used the settings app to turn off WIFI. Eclipse then caught the SocketException and the accelerometer readings stopped being updated. I then let the app run and let the exception occur and crash the thread and the accelerometer data remained frozen. Second, with WIFI back on, I restarted the app and started the accelerometer again. I then took my Xoom outside and walked away from my access point until it lost the network connection. The accelerometer data stopped updating around the same time as the WIFI connection was lost. Bringing the Xoom back in and view the LogCat, I saw the SocketException in the log. So, it appears that the issue is related to the loss of the WIFI connection. An interesting thing I noticed though, is that it is not all dead. The compass reading continues to update even after the SocketException has occurred.
          Hide
          Joe Bowser added a comment -

          I've been toggling the crap out of the Wifi connection on my Xoom and I can't reproduce this. I'm using the mobile-spec version which watches the accelerometer and gets constant updates. It's very similar to the old demo. I'm running it against the latest.

          Show
          Joe Bowser added a comment - I've been toggling the crap out of the Wifi connection on my Xoom and I can't reproduce this. I'm using the mobile-spec version which watches the accelerometer and gets constant updates. It's very similar to the old demo. I'm running it against the latest.
          Hide
          Wayne Fisher added a comment -

          I have attached my v2.0.0 based example project for you to try. It is built using the example source from the v2.0.0 release with the only change being that I added the Cordova version to the title.

          I exported this from eclipse, renamed my original copy and installed from this archive. I ran it by "Debug As" "Android Application". I started the accelerometer and the compass. I disabled WIFI once and it kept running (still updating the display). Re-enabled WIFI, went back to the app, watched it for a few seconds and then disabled WIFI again. This time it died.

          Please try this app to see if you get the same result. Maybe there is enough different about the mobile-spec test that it doesn't occur there.

          Show
          Wayne Fisher added a comment - I have attached my v2.0.0 based example project for you to try. It is built using the example source from the v2.0.0 release with the only change being that I added the Cordova version to the title. I exported this from eclipse, renamed my original copy and installed from this archive. I ran it by "Debug As" "Android Application". I started the accelerometer and the compass. I disabled WIFI once and it kept running (still updating the display). Re-enabled WIFI, went back to the app, watched it for a few seconds and then disabled WIFI again. This time it died. Please try this app to see if you get the same result. Maybe there is enough different about the mobile-spec test that it doesn't occur there.
          Hide
          Wayne Fisher added a comment -

          Archive of example app that reproduces the issue has been added to the ticket.

          Show
          Wayne Fisher added a comment - Archive of example app that reproduces the issue has been added to the ticket.
          Hide
          Joe Bowser added a comment -

          OK, I can reproduce it only if I turn on and off my Wifi repeatedly. This is caused by the fact that we use a callback server on the local device for the bridge, and we just killed the routing table by doing this. I'll try to do this again by turning on and off airplane mode and see if that works on another device.

          Show
          Joe Bowser added a comment - OK, I can reproduce it only if I turn on and off my Wifi repeatedly. This is caused by the fact that we use a callback server on the local device for the bridge, and we just killed the routing table by doing this. I'll try to do this again by turning on and off airplane mode and see if that works on another device.
          Hide
          Wayne Fisher added a comment -

          That's good news! Thanks for keeping on it to reproduce it. Hopefully, there is an easy solution for it.

          Show
          Wayne Fisher added a comment - That's good news! Thanks for keeping on it to reproduce it. Hopefully, there is an easy solution for it.
          Hide
          Joe Bowser added a comment -

          OK, this is a bigger issue than I thought. Here's the cross-device version:

          Here's the device-independent version of this bug:
          Step 1. Start Accelerometer
          Step 2. Put device in Airplane Mode
          Step 3. Go back to App
          Step 4. Turn off Airplane Mode

          The issue is also present on other devices when you use Airplane mode. That being said, a solid third of my Android apps totally crap the bed when I do this, so it's tricky to see if it's us. I'm not sure if this is a fixable bug on our end, since without a routing table, there's no way you can get to our localhost callback server. We're going to have to revisit how our bridge works.

          Show
          Joe Bowser added a comment - OK, this is a bigger issue than I thought. Here's the cross-device version: Here's the device-independent version of this bug: Step 1. Start Accelerometer Step 2. Put device in Airplane Mode Step 3. Go back to App Step 4. Turn off Airplane Mode The issue is also present on other devices when you use Airplane mode. That being said, a solid third of my Android apps totally crap the bed when I do this, so it's tricky to see if it's us. I'm not sure if this is a fixable bug on our end, since without a routing table, there's no way you can get to our localhost callback server. We're going to have to revisit how our bridge works.
          Hide
          Joe Bowser added a comment -

          OK, this only happens on ICS devices. That's a partial relief. It seems that we're going to have to find a new bridge, since we can't get to a callback server if the routing is this broken.

          Show
          Joe Bowser added a comment - OK, this only happens on ICS devices. That's a partial relief. It seems that we're going to have to find a new bridge, since we can't get to a callback server if the routing is this broken.
          Hide
          Anis Kadri added a comment - - edited

          addJavascriptInterface ? :-D I think even URL intercepts would make me happier than the current solution.

          Show
          Anis Kadri added a comment - - edited addJavascriptInterface ? :-D I think even URL intercepts would make me happier than the current solution.
          Hide
          Joe Bowser added a comment -

          Wrong problem. This is a problem going from Java to Javascript, not the other way around.

          Show
          Joe Bowser added a comment - Wrong problem. This is a problem going from Java to Javascript, not the other way around.
          Hide
          Joe Bowser added a comment -

          Since CB-638 doesn't have a version attached to it, I'll remove this from 2.1.0.

          Show
          Joe Bowser added a comment - Since CB-638 doesn't have a version attached to it, I'll remove this from 2.1.0.
          Hide
          Braden Shepherdson added a comment -

          This is a bug with the CallbackServer bridge. Once that bridge is deprecated and not being used, this problem will go away.

          Show
          Braden Shepherdson added a comment - This is a bug with the CallbackServer bridge. Once that bridge is deprecated and not being used, this problem will go away.
          Hide
          Joe Bowser added a comment -

          I've changed the default bridge to use ONLINE_EVENT instead of HANGING_GET. This will still throw exceptions until we fully deprecate it in six months, but we can ignore it for now, since it shouldn't affect callbacks from Native to JS unless you go out of your way to use a broken mode.

          Show
          Joe Bowser added a comment - I've changed the default bridge to use ONLINE_EVENT instead of HANGING_GET. This will still throw exceptions until we fully deprecate it in six months, but we can ignore it for now, since it shouldn't affect callbacks from Native to JS unless you go out of your way to use a broken mode.
          Hide
          Joe Bowser added a comment -

          Actually, this is still critical until 2.2 is released.

          Show
          Joe Bowser added a comment - Actually, this is still critical until 2.2 is released.
          Hide
          Joe Bowser added a comment -

          Now that the callback server is deleted, there are no more socket exceptions! HURRAY!

          Show
          Joe Bowser added a comment - Now that the callback server is deleted, there are no more socket exceptions! HURRAY!

            People

            • Assignee:
              Joe Bowser
              Reporter:
              Wayne Fisher
            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development