Apache Cordova
  1. Apache Cordova
  2. CB-5393

Android's Online bridge sometimes doesn't work on KitKat

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.9.0, 3.0.0
    • Fix Version/s: 3.1.0, 2.9.1
    • Component/s: Android
    • Labels:
      None

      Description

      Here's an app /w source that can reproduce the problem consistently. I've made some tweaks to exacerbate the scenario in which it occurs. I'm fairly certain that happens when online changes back and forth too fast.

      The bug happens with & without the debugger attached.

      How to use the test app:

      • The bug is happening consistently for me on start-up and causes the page to not load correctly. If you get an alert saying that it didn't start-up, click the "Refresh Page" button at the top.
      • The bug doesn't appear on the second time (at least for me) (no alerts)
      • Click the "Benchmark exec" button and wait for it to report the bridge speed.
      • Notice that it seems to work fine
      • Now check the "Use two echos at once" box and run the test again a few times
      • Notice that you get an alert saying that no echo was received after a certain number of calls.

      The bug will not happen with the pre-KitKat WebView.

      mobilespec.zip & framework.zip have the sources.

      1. framework.zip
        897 kB
        Andrew Grieve
      2. mobilespec.zip
        4.08 MB
        Andrew Grieve
      3. screenshot-1.jpg
        142 kB
        Angela Fowler

        Activity

        Show
        Andrew Grieve added a comment - Fixed by only switching online/offline once per batch of messages. JS Change: https://git-wip-us.apache.org/repos/asf?p=cordova-js.git;a=commit;h=1be2876635d2a788270238c4b1cfad200c488e32 Android Change: https://git-wip-us.apache.org/repos/asf?p=cordova-android.git;a=commit;h=166b35bc6c5977cf547f4093690d554b57cb855a
        Hide
        Marcel Kinard added a comment -

        Does this fix need to be applied to master? Or more generally, are there other affected versions (earlier or later) besides 2.9.0 and 3.0.0?

        Show
        Marcel Kinard added a comment - Does this fix need to be applied to master? Or more generally, are there other affected versions (earlier or later) besides 2.9.0 and 3.0.0?
        Hide
        Andrew Grieve added a comment -

        The bug affects the ONLINE_EVENTS bridge mode, which has been the default since Cordova 2.2.

        The change was made to master before 3.1 was branched. It was also included in the 2.9.1 release.

        Show
        Andrew Grieve added a comment - The bug affects the ONLINE_EVENTS bridge mode, which has been the default since Cordova 2.2. The change was made to master before 3.1 was branched. It was also included in the 2.9.1 release.
        Hide
        Angela Fowler added a comment -

        Is the bug reproducible in an emulator or just on a device? I tried the app with a Nexus 7 emulator started from Eclipse ADT and did not get the alert.
        These are set in NativeToJsMessageQueue:
        static final boolean ENABLE_LOCATION_CHANGE_EXEC_MODE = true;
        static final boolean DISABLE_EXEC_CHAINING = true;
        and "Use two echos at once" is checked.
        I will attach a window capture.

        Show
        Angela Fowler added a comment - Is the bug reproducible in an emulator or just on a device? I tried the app with a Nexus 7 emulator started from Eclipse ADT and did not get the alert. These are set in NativeToJsMessageQueue: static final boolean ENABLE_LOCATION_CHANGE_EXEC_MODE = true; static final boolean DISABLE_EXEC_CHAINING = true; and "Use two echos at once" is checked. I will attach a window capture.
        Hide
        Angela Fowler added a comment - - edited

        Also in Nexus S i.e. no alerts
        Correction : Nexus44KitKat in screen shot is a Nexus 7.

        Show
        Angela Fowler added a comment - - edited Also in Nexus S i.e. no alerts Correction : Nexus44KitKat in screen shot is a Nexus 7.
        Hide
        Andrew Grieve added a comment -

        It was reproducible on both for me. Note that it's a bug that affects Android KitKat only (don't think KitKat made it to Nexus S).

        Show
        Andrew Grieve added a comment - It was reproducible on both for me. Note that it's a bug that affects Android KitKat only (don't think KitKat made it to Nexus S).
        Hide
        Angela Fowler added a comment -

        Which emulator would you recommend to reproduce the bug?
        Does the screen shot look like it has the right settings to reproduce?

        Show
        Angela Fowler added a comment - Which emulator would you recommend to reproduce the bug? Does the screen shot look like it has the right settings to reproduce?
        Hide
        Andrew Grieve added a comment -

        Screenshot looks good (except might not need the async native->JS checkbox... not sure).

        What version of Cordova are you trying this with?

        Show
        Andrew Grieve added a comment - Screenshot looks good (except might not need the async native->JS checkbox... not sure). What version of Cordova are you trying this with?
        Hide
        Angela Fowler added a comment -

        Its the one from the framework.zip included in mobilespec as an Android library.
        var CORDOVA_JS_BUILD_LABEL = '3.0.0rc1-1-g1965a39';

        Show
        Angela Fowler added a comment - Its the one from the framework.zip included in mobilespec as an Android library. var CORDOVA_JS_BUILD_LABEL = '3.0.0rc1-1-g1965a39';
        Hide
        Marcel Kinard added a comment -

        Andrew, I am also unable to reproduce the problem using the mobilespec.zip and framework.zip attached here. I'm basically getting the same results as Angela. I'm testing on a Nexus 5 with both 4.4.0 and 4.4.2, and in a 4.4.0 emulator. I'm not getting any alerts, and the page is always loading fine. Do you have any advice?

        Show
        Marcel Kinard added a comment - Andrew, I am also unable to reproduce the problem using the mobilespec.zip and framework.zip attached here. I'm basically getting the same results as Angela. I'm testing on a Nexus 5 with both 4.4.0 and 4.4.2, and in a 4.4.0 emulator. I'm not getting any alerts, and the page is always loading fine. Do you have any advice?
        Hide
        Andrew Grieve added a comment -

        I'll have a look some time this week.

        Show
        Andrew Grieve added a comment - I'll have a look some time this week.
        Hide
        Marcel Kinard added a comment -

        FYI, I ran the attached mobile-spec test against 3.0.0, 2.6.0, and 2.3.0 and was unable to recreate the issue. I did modify the source in each platform to set ENABLE_LOCATION_CHANGE_EXEC_MODE = true and DISABLE_EXEC_CHAINING = true, and did not introduce any external online events. This was running on a Nexus 5 with 4.4.0. All the messages seemed to echo back and I didn't get any alerts.

        Show
        Marcel Kinard added a comment - FYI, I ran the attached mobile-spec test against 3.0.0, 2.6.0, and 2.3.0 and was unable to recreate the issue. I did modify the source in each platform to set ENABLE_LOCATION_CHANGE_EXEC_MODE = true and DISABLE_EXEC_CHAINING = true, and did not introduce any external online events. This was running on a Nexus 5 with 4.4.0. All the messages seemed to echo back and I didn't get any alerts.
        Hide
        Andrew Grieve added a comment -

        Yep, I can't repo either. Seems probable that the webview team fixed this in the 11th hour... Will try and follow up with them.

        Show
        Andrew Grieve added a comment - Yep, I can't repo either. Seems probable that the webview team fixed this in the 11th hour... Will try and follow up with them.
        Hide
        Andrew Grieve added a comment -

        Okay, heard back that we're not crazy and that the different behaviour was infact fixed at the last second. So - there's no problem then with older cordova versions that I'm aware of

        Show
        Andrew Grieve added a comment - Okay, heard back that we're not crazy and that the different behaviour was infact fixed at the last second. So - there's no problem then with older cordova versions that I'm aware of

          People

          • Assignee:
            Andrew Grieve
            Reporter:
            Andrew Grieve
          • Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development