Log in or register to post comments

Launch Timeout on iOS/Unity

June 3, 2012 - 5:14pm #1

Has anybody else experienced launch timeouts when launching on iOS? It's not all that common but when it happens it looks like something in either Unity or QCAR is looping forever.

Here's a crash report from apple:

failed to launch in time

Elapsed total CPU time (seconds): 7.410 (user 7.410, system 0.000), 37% CPU 
Elapsed application CPU time (seconds): 1.521, 8% CPU

Thread 0 name:  Dispatch queue: com.apple.main-thread
Thread 0:
0   libsystem_kernel.dylib        	0x31557004 mach_msg_trap + 20
1   libsystem_kernel.dylib        	0x315571fa mach_msg + 50
2   AudioToolbox                  	0x36925c16 AUIOClient_StartIO + 102
3   AudioToolbox                  	0x369310a4 AURemoteIO::Start() + 1060
4   AudioToolbox                  	0x36968726 _ZL13AUMethodStartPv + 130
5   AudioToolbox                  	0x36966eb6 AudioOutputUnitStart + 26
6   viewa                         	0x00818a34 QCAR::DataSet::~DataSet() + 2286372
7   viewa                         	0x0082e56c QCAR::DataSet::~DataSet() + 2375260
8   viewa                         	0x008280f8 QCAR::DataSet::~DataSet() + 2349544
9   viewa                         	0x006b4bfc QCAR::DataSet::~DataSet() + 828652
10  viewa                         	0x006b59b0 QCAR::DataSet::~DataSet() + 832160
11  viewa                         	0x006b85e0 QCAR::DataSet::~DataSet() + 843472
12  viewa                         	0x00795624 QCAR::DataSet::~DataSet() + 1748756
13  viewa                         	0x006c13e0 QCAR::DataSet::~DataSet() + 879824
14  viewa                         	0x006ac0e8 QCAR::DataSet::~DataSet() + 793048
15  viewa                         	0x007662ac QCAR::DataSet::~DataSet() + 1555356
16  viewa                         	0x0075b48c QCAR::DataSet::~DataSet() + 1510780
17  viewa                         	0x0064e5a0 QCAR::DataSet::~DataSet() + 409232
18  viewa                         	0x0005e494 0x00004494
19  viewa                         	0x0005e838 0x00004838
20  UIKit                         	0x310bccfa -[UIApplication _callInitializationDelegatesForURL:payload:suspended:] + 1262
21  UIKit                         	0x310b67d6 -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 402
22  UIKit                         	0x31084abc -[UIApplication handleEvent:withNewEvent:] + 1004
23  UIKit                         	0x31084560 -[UIApplication sendEvent:] + 48
24  UIKit                         	0x31083f34 _UIApplicationHandleEvent + 5820
25  GraphicsServices              	0x33ac6224 PurpleEventCallback + 876
26  CoreFoundation                	0x3738451c __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 32
27  CoreFoundation                	0x373844be __CFRunLoopDoSource1 + 134
28  CoreFoundation                	0x3738330c __CFRunLoopRun + 1364
29  CoreFoundation                	0x3730649e CFRunLoopRunSpecific + 294
30  CoreFoundation                	0x37306366 CFRunLoopRunInMode + 98
31  UIKit                         	0x310b5864 -[UIApplication _run] + 544
32  UIKit                         	0x310b2cce UIApplicationMain + 1074
33  viewa                         	0x0005f7cc 0x000057cc
34  viewa                         	0x0005d190 0x00003190

Thread 1 name:  Dispatch queue: com.apple.libdispatch-manager
Thread 1:
0   libsystem_kernel.dylib        	0x315573a8 kevent + 24
1   libdispatch.dylib             	0x304dcea4 _dispatch_mgr_invoke + 708
2   libdispatch.dylib             	0x304dcbc2 _dispatch_mgr_thread + 30

Thread 2 name:  WebThread
Thread 2:
0   libsystem_kernel.dylib        	0x31557004 mach_msg_trap + 20
1   libsystem_kernel.dylib        	0x315571fa mach_msg + 50
2   CoreFoundation                	0x373843ec __CFRunLoopServiceMachPort + 120
3   CoreFoundation                	0x37383124 __CFRunLoopRun + 876
4   CoreFoundation                	0x3730649e CFRunLoopRunSpecific + 294
5   CoreFoundation                	0x37306366 CFRunLoopRunInMode + 98
6   WebCore                       	0x32cafc9c _ZL12RunWebThreadPv + 396
7   libsystem_c.dylib             	0x33c2572e _pthread_start + 314
8   libsystem_c.dylib             	0x33c255e8 thread_start + 0

Thread 3 name:  com.apple.NSURLConnectionLoader
Thread 3:
0   libsystem_kernel.dylib        	0x31557004 mach_msg_trap + 20
1   libsystem_kernel.dylib        	0x315571fa mach_msg + 50
2   CoreFoundation                	0x373843ec __CFRunLoopServiceMachPort + 120
3   CoreFoundation                	0x37383124 __CFRunLoopRun + 876
4   CoreFoundation                	0x3730649e CFRunLoopRunSpecific + 294
5   CoreFoundation                	0x37306366 CFRunLoopRunInMode + 98
6   Foundation                    	0x37b96bb2 +[NSURLConnection(Loader) _resourceLoadLoop:] + 302
7   Foundation                    	0x37b96a7a -[NSThread main] + 66
8   Foundation                    	0x37c2a58a __NSThread__main__ + 1042
9   libsystem_c.dylib             	0x33c2572e _pthread_start + 314
10  libsystem_c.dylib             	0x33c255e8 thread_start + 0

Thread 4 name:  com.apple.CFSocket.private
Thread 4:
0   libsystem_kernel.dylib        	0x31567570 __select + 20
1   CoreFoundation                	0x3738863a __CFSocketManager + 726
2   libsystem_c.dylib             	0x33c2572e _pthread_start + 314
3   libsystem_c.dylib             	0x33c255e8 thread_start + 0

Thread 5:
0   libsystem_kernel.dylib        	0x31567cd4 __workq_kernreturn + 8
1   libsystem_c.dylib             	0x33c1ff36 _pthread_wqthread + 610
2   libsystem_c.dylib             	0x33c1fcc8 start_wqthread + 0

Thread 6:
0   libsystem_kernel.dylib        	0x31567cd4 __workq_kernreturn + 8
1   libsystem_c.dylib             	0x33c1ff36 _pthread_wqthread + 610
2   libsystem_c.dylib             	0x33c1fcc8 start_wqthread + 0

Thread 7:
0   libsystem_kernel.dylib        	0x31567cd4 __workq_kernreturn + 8
1   libsystem_c.dylib             	0x33c1ff36 _pthread_wqthread + 610
2   libsystem_c.dylib             	0x33c1fcc8 start_wqthread + 0

Thread 8 name:  com.apple.coremedia.player.async
Thread 8:
0   libsystem_kernel.dylib        	0x31567068 __psynch_cvwait + 24
1   libsystem_c.dylib             	0x33c25a46 _pthread_cond_wait + 634
2   libsystem_c.dylib             	0x33c257c2 pthread_cond_wait + 34
3   CoreMedia                     	0x367fd868 FigSemaphoreWaitRelative + 268
4   MediaToolbox                  	0x353473e6 fpa_AsyncMovieControlThread + 22
5   CoreMedia                     	0x3681c8b4 figThreadMain + 168
6   libsystem_c.dylib             	0x33c2572e _pthread_start + 314
7   libsystem_c.dylib             	0x33c255e8 thread_start + 0

Thread 9:
0   libsystem_kernel.dylib        	0x31557054 semaphore_wait_trap + 8
1   viewa                         	0x00a8ea44 QCAR::DataSet::~DataSet() + 4866868
2   viewa                         	0x009f38c8 QCAR::DataSet::~DataSet() + 4231608
3   viewa                         	0x00a6ba00 QCAR::DataSet::~DataSet() + 4723440
4   viewa                         	0x00a86d78 QCAR::DataSet::~DataSet() + 4834920
5   viewa                         	0x00aa2a54 QCAR::DataSet::~DataSet() + 4948804
6   libsystem_c.dylib             	0x33c2572e _pthread_start + 314
7   libsystem_c.dylib             	0x33c255e8 thread_start + 0

Thread 10:
0   libsystem_kernel.dylib        	0x31557054 semaphore_wait_trap + 8
1   viewa                         	0x00816210 QCAR::DataSet::~DataSet() + 2276096
2   viewa                         	0x008328b8 QCAR::DataSet::~DataSet() + 2392488
3   libsystem_c.dylib             	0x33c2572e _pthread_start + 314
4   libsystem_c.dylib             	0x33c255e8 thread_start + 0

Thread 11 name:  AURemoteIO::IOThread
Thread 11:
0   libsystem_kernel.dylib        	0x31557004 mach_msg_trap + 20
1   libsystem_kernel.dylib        	0x315571fa mach_msg + 50
2   AudioToolbox                  	0x36930312 AURemoteIO::IOThread::Run() + 98
3   AudioToolbox                  	0x36933f42 AURemoteIO::IOThread::Entry(void*) + 2
4   AudioToolbox                  	0x36870c9c CAPThread::Entry(CAPThread*) + 208
5   libsystem_c.dylib             	0x33c2572e _pthread_start + 314
6   libsystem_c.dylib             	0x33c255e8 thread_start + 0

Unknown thread crashed with unknown flavor: 5, state_count: 1

Dataset destructor calls (QCAR::DataSet::~DataSet()) stand out to me as being a bit weird, as I'm not loading a dataset at launch?

Re: Launch Timeout on iOS/Unity

June 6, 2012 - 6:14am #8

The 8GB 3rd generation iPod is not equivalent to an iPhone 4.

The 8GB version is the same almost as the second gen iPod.

It doesn't support OpenGL ES 2.0. It has a slower CPU.

Apple released the iPod Touch 2nd gen as the iPod Touch 3rd gen 8GB. They also released a 32GB and 64GB version which use updated hardware.

Re: Launch Timeout on iOS/Unity

June 5, 2012 - 5:59am #7

Ok thanks for clarifying

We are investigating this issue.

N

Re: Launch Timeout on iOS/Unity

June 5, 2012 - 2:14am #6

I meant iPod 3G as in, iPod 3rd generation, which is roughly iPhone 4ish in spec, but the device has no bearing on my findings you can repeat it on anything that will run QCAR :)

Re: Launch Timeout on iOS/Unity

June 5, 2012 - 1:56am #5

I think I know what the problem might be.

You are using an iPhone 3G which is not officially supported.

The "lowest" device supported is a 3GS.

HTH

N

Re: Launch Timeout on iOS/Unity

June 5, 2012 - 1:21am #4

http://charlesproxy.com/) I noticed that the app on first launch does a http POST to http://dp.qcarsdk.com/ and downloads something.

The post params are:

POST /arws/config/ HTTP/1.1
Host: dp.qcarsdk.com
User-Agent: XXXXX/XX CFNetwork/548.1.4 Darwin/11.0.0
Content-Length: 0
Accept: */*
X-Qcar-Software-Env-Version: 0.0.0
X-Qcar-Software-Env-Type: unityPlayer
X-Qcar-Sdk-Wrapper-Version: 1.5.10
X-Qcar-Sdk-Wrapper-Type: unityWrapper
X-Qcar-Sdk-Version: 1.5.8
X-Qcar-Os-Version: 5
X-Qcar-Os-Type: iOS
X-Qcar-Os-Kernel-Version: 5.1
X-Qcar-Market-Id: XXXXXXXXXXXX
X-Qcar-Device-Profile-Version: 0.0
X-Qcar-Device-Model: iPod4,1
X-Qcar-Device-Manufacturer: Apple
X-Qcar-Device-Id: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
X-Qcar-Device-Hardware: N81AP
X-Qcar-App-Version: 102
X-Qcar-App-Id: XXXXXXXXXXXXXXXXXXXXXX
X-Qcar-Analytics-Config-Version: 0.0
Content-Type: application/x-www-form-urlencoded
Accept-Language: en-gb
Accept-Encoding: gzip, deflate
Connection: keep-alive
Proxy-Connection: keep-alive

If I throttle the connection such that its really SLOW, the app will often take ages to launch, and be killed by iOS. Launching again immediately after seems to work.

So i did a test where I would delete the application, install it fresh, and then launch it and time how long it takes, with both (severely) throttled internet, and unthrottled internet (adsl2/wifi).

Test Results
--------------

Device: iPod 3G, 8GB, iOS 5.1

Connection unthrottled
-------------------------
Launch 1 - 15 seconds, OK
Launch 2 - 15 seconds, OK
Launch 3 - 15 seconds, OK
Launch 4 - 15 seconds, OK
Launch 5 - 15 seconds, OK

Connection to dp.qcarsdk.com throttled to 0.001kbps, 2500ms latency
-------------------------------------------------------------------------------
Launch 1 - 22 seconds, crash
Launch 2 - 24 seconds, crash
Launch 3 - 23 seconds, crash
Launch 4 - 23 seconds, crash
Launch 5 - 24 seconds, crash

It seems to start working again somewhere between 10 and 100kbps. If you have no internet at all, it works fine.

My first thought to work around this is to replace the "Default.png" launch image with my own image, and then return from the "applicationDidFinishLaunching:" method immediately, and then start up unity and QCAR at a later time - that would keep the iOS watch-dog happy and stop it from killing my app before it has finished launching.

The downside to doing that is, if someone has a TERRIBLE internet connection (i.e. Optus in Australia ;)), they're still going to be stuck looking at my Default.png image for possibly up to 30-60 seconds (whatever your CFURLConnection timeout is...probably 60 seconds?), which I'm not sure is any better than just having it crash after 22 seconds and then trying again.

Obviously I need a better work around but I'm not sure what...

Re: Launch Timeout on iOS/Unity

June 4, 2012 - 8:14pm #3

Not reproduceable but I have seen it happen myself. I'd estimate maybe 1-2% of app launches do it, at most. Seems to be more likely on the slower devices.

This is using unity 3.4. I tried updating to 3.52 yesterday but
It seemed to make everything slower and I don't think it fixed the launch bug either.

Re: Launch Timeout on iOS/Unity

June 4, 2012 - 1:09am #2

Hi Tom,

Is this reproduceable?

Also, what device etc. are you using?

N

Log in or register to post comments