Titanium JIRA Archive
Appcelerator Community (AC)

[AC-2201] iOS: Apps hang at startup when network connection is poor

GitHub Issuen/a
TypeBug
Priorityn/a
StatusClosed
ResolutionNeeds more info
Resolution Date2013-02-22T17:10:03.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsTitanium SDK & CLI
Labelsanalytics, crash, hang, ios, modules, network, startup, triage
ReporterLuke Bartolomeo
AssigneeShak Hossain
Created2012-10-01T18:48:29.000+0000
Updated2016-03-08T07:41:11.000+0000

Description

Let me start by giving a general description of the behavior I am witnessing. When using Titanium 2.x, targeting iOS 5 or 6.... If I launch my app in a situation where the device or simulator BELIEVES it has a network connection, but where one is not actually available, the app will hang. True, this might seem to be a rare situation, but it happens quite frequently here in downtown Chicago. My phone reports a 4g connection with AT&T, but the network is unresponsive. I have witnessed all of the following depending upon my app and whether I am running on the device or in simulator.

The app hangs forever on the splash screen.

The app makes it past the startup screen, but the UI is unresponsive.

The app hangs on the startup screen for a long time, but eventually finishes launching normally.

The app hangs on the startup screen, and then iOS shuts it down (for taking to long to launch?)

Occasionally, the console shows the error "Timing out waiting on main thread. Possibly a deadlock? in TiThreadPerformOnMainThread (TiBase.m:238)"

I know that a while back, this type of problem could be traced to having analytics enabled, but I am seeing this even with false in my tiapp.xml It also appears that the issue is somehow related to the loading of modules, as my apps which do not use modules do not exhibit the bug.

Steps to reproduce:

Create a new default Titanium Mobile project. Run in simulator to show that it is working correctly (you can switch between tabs). Now, set analytics to false in tiapp.xml (just to rule that out as the cause). Then, fool your computer into thinking you have a network connection when you actually do not. The easiest way to do this is with Apple's Network Link Conditioner Preference pane. You will need to create a new profile with 0% bandwidth and 100% of up and down packets dropped. Confirm that your computer appears to have a network connection, but an attempt to access a web page yields NO response. Run the test app in the simulator. It works just as before. But finally, try adding a module to the project. I used ti.storekit for my testing. Also, be sure to actually require the module at the beginning of the app.js code. Run the app in the simulator, and you should find that it either hangs for a long time on the default splash screen, or that the window is unresponsive when you attempt to switch tabs-- for a long time or FOREVER. As I said, the conditions under which this bug would appear are fairly rare. Apps launch fine when the device knows there is no network connection, and they launch fine when the device HAS a network connection. Usually even when the connection is marginal, the app will eventually launch. But when the device (or simulator) thinks it has a connection but it actuality it does not, the app will hang at launch. If anyone could verify that they can reproduce this behavior, I will feel a little better that it is not something wonky on my end. Although, it still won't leave us with a solution yet.

UPDATE

When using Little Snitch to monitor network activity, it seems that my little test app STILL is trying to connect to api.appcelerator.com on port 443 at launch. This is even after analytics is set to FALSE in tiapp.xml Maybe this issue IS related to TIMOB-9090 (reported fixed) and TIMOB-2984 (still open).

Comments

  1. Craig Jones 2012-10-16

    +1 for the above. I have an app that connects to the Twitter API and I've getting the same situation in hanging splash screens etc... Same as above, Analytics disabled, Ti 2.x, iOS 5 & 6.
  2. Eduardo Gomez 2013-02-21

    Luke, can you please provide us logs (Titanium Mobile stack traces) and crash reports, if any?
  3. Eduardo Gomez 2013-02-22

    When time allows, please check and complete [JIRA Ticket Checklist](http://docs.appcelerator.com/titanium/latest/#!/guide/How_to_Submit_a_Bug_Report-section-29004732_HowtoSubmitaBugReport-JIRATicketChecklist) in order to escalate this issue quicker, thanks.
  4. Mostafizur Rahman 2014-01-18

    Hello, We tested this issue with latest Ti Studio and SDK 3.2. We can't reproduce this problem.

    Test Environment

    Mac OX x 10.8.5 Ti CLI 3.2.0 Ti SDK 3.2.0.GA IOS Simulator 7.0.3

    Test Code

       var win = Titanium.UI.createWindow({
       	backgroundColor : 'orange'
       });
       
       c = Titanium.Network.createHTTPClient();
       c.setTimeout(10000);
       
       c.onload = function() {
       	Ti.API.info('IN ONLOAD ');
       	Ti.API.info("response " + c.responseData);
       
       };
       c.ondatastream = function(e) {
       
       };
       c.onerror = function(e) {
       	Ti.API.info('XHR Error ' + e.error);
       };
       
       // open the client
       
       c.open('GET', 'https://raw.github.com/appcelerator/Documentation-Examples/master/HTTPClient/data/json.txt');
       
       // send the data
       c.send();
       win.open();
       
       

    Step to Test

    Create new project for Ti Classic

    Update app.js file with test code

    Disconnected networks connection

    Set analytics false in project tiapp.xml

    Run this project in iOS simulator

    App will run with 'orange' background color

    Thanks
  5. Shota Watanabe 2015-02-16

    +1 for this I just use 'Network Link Conditioner' and set '100% loss' , it finally reproduced.

JSON Source