Apache Cordova
  1. Apache Cordova
  2. CB-53

Bug when connect/disconnect while make ajax request (iOS)

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Minor Minor
    • Resolution: Cannot Reproduce
    • Affects Version/s: None
    • Fix Version/s: 2.2.0
    • Component/s: iOS
    • Labels:
      None

      Description

      reported at: https://github.com/phonegap/phonegap-iphone/issues/331
      by: https://github.com/prsolucoes

      Hi,

      I post it on start project because the link to iphone on wiki is wrong, but now i found it searching on github.

      The problem is my app is make an ajax call every 1 second on my server and if i start the app without internet connect and connect on wifi/3g the application is killed (fatal error). Other situation is when im on my app connected and making ajax pooling and the connection (wifi or 3g) is dropped, the application is killed too (fatal error).

      So, if you are making ajax call and your connection change state (connected/disconnected) your app get a fatal error and close.

        Activity

        Hide
        Shazron Abdullah added a comment -

        This sorely needs a test case. Sounds like something else is going on (Reachability crash?) but without further info this can't be acted on.

        Show
        Shazron Abdullah added a comment - This sorely needs a test case. Sounds like something else is going on (Reachability crash?) but without further info this can't be acted on.
        Hide
        Eric C added a comment - - edited

        This is a big problem for the project I'm working on since the wifi is very spotty.

        The project is written in Sencha Touch 1.1 and uses Ext.Ajax.request to make AJAX calls every 10 seconds.

        The way I've reproduced this issue is:

        • Be connected to wifi
        • Open up the PhoneGap app on iOS device
        • Walk out of range of wifi
        • App crashes

        The reverse wifi situation will also cause a crash: Start app when disconnected from wifi and then walk into wifi range.

        Now, I'm unsure if the repetitive AJAX calls have anything to do with this, but looking at the previous comment, it seems to be a factor. I'll try and do a test with my AJAX requests off and see if it crashes. Also, in addition to testing on a physical iOS device, I tested the app on the simulator by pulling out and putting back in the ethernet cable. The simulator fired off the online/offline events correctly and did not crash.

        Show
        Eric C added a comment - - edited This is a big problem for the project I'm working on since the wifi is very spotty. The project is written in Sencha Touch 1.1 and uses Ext.Ajax.request to make AJAX calls every 10 seconds. The way I've reproduced this issue is: Be connected to wifi Open up the PhoneGap app on iOS device Walk out of range of wifi App crashes The reverse wifi situation will also cause a crash: Start app when disconnected from wifi and then walk into wifi range. Now, I'm unsure if the repetitive AJAX calls have anything to do with this, but looking at the previous comment, it seems to be a factor. I'll try and do a test with my AJAX requests off and see if it crashes. Also, in addition to testing on a physical iOS device, I tested the app on the simulator by pulling out and putting back in the ethernet cable. The simulator fired off the online/offline events correctly and did not crash.
        Hide
        Randy McMillan added a comment - - edited

        Use

        if (navigator.onLine){} else {}

        or

        if (!navigator.onLine){} else {}

        NOTE:

        navigator.onLine will always be true in the simulator.

        Also:

        If the type is unknown it is better to assume the app is offline.

        if (navigator.network.connection.type == "unknown")

        { console.log('Assume app offLine'); onOffline(); //trigger onOffline event }

        function onOffline (){}

        https://raw.github.com/RandyMcMillan/SenchaTouch/master/www/src/demos/myDemos/Accelerometer.js

        Show
        Randy McMillan added a comment - - edited Use if (navigator.onLine){} else {} or if (!navigator.onLine){} else {} NOTE: navigator.onLine will always be true in the simulator. Also: If the type is unknown it is better to assume the app is offline. if (navigator.network.connection.type == "unknown") { console.log('Assume app offLine'); onOffline(); //trigger onOffline event } function onOffline (){} https://raw.github.com/RandyMcMillan/SenchaTouch/master/www/src/demos/myDemos/Accelerometer.js
        Hide
        Shazron Abdullah added a comment -

        Assigning to 2.2.0 for investigation and resolution.

        Show
        Shazron Abdullah added a comment - Assigning to 2.2.0 for investigation and resolution.
        Hide
        Shazron Abdullah added a comment -

        More like a "can't fix". If ajax calls are crashing, it's something internal to WebKit anyway and we can't fix those. Crash logs will re-open this

        Show
        Shazron Abdullah added a comment - More like a "can't fix". If ajax calls are crashing, it's something internal to WebKit anyway and we can't fix those. Crash logs will re-open this

          People

          • Assignee:
            Shazron Abdullah
            Reporter:
            Shazron Abdullah
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development