发布iPhone应用程序崩溃

问题描述:

我们从iTunes连接收到崩溃日志,这有点奇怪。发布iPhone应用程序崩溃

我们很早就遇到了问题,我们的应用程序花了很长时间才从ApplicationDidFinishLaunching返回。这是由于在applicationDidFinishLaunching中做了太多的工作而造成的,我们在较慢的设备上超过了20秒的时间。

为了解决这个问题,我们将所有设置代码都移出了ApplicationDidFinishLaunching,并将其移入一个特殊的secondaryLoadingController中。最重要的是,我们将该控制器内的设置代码移到了一个单独的线程中。

但是,即使崩溃日志显示致电[UIApplication _reportAppLaunchFinished],我们仍然会看到崩溃日志,表示我们的应用无法及时启动。对我来说,这表示应用程序已经启动完毕,只要我们想运行我们的设置代码,我们就可以*采取行动。下面是崩溃日志。

感谢您提供任何帮助。

Incident Identifier: 429360D5-6B02-49BE-9A0F-164DC521BE36 
Hardware Model:  iPod2,1 
Process:   XYZ [357] 
Path:   /var/mobile/Applications/D5038F26-CC5B-48E5-824E-090163B5C0C4/XYZ.app/XYZ 
Identifier:  XYZ 
Version:   ??? (???) 
Code Type:  ARM (Native) 
Parent Process: launchd [1] 



Date/Time:  2010-09-28 13:35:25.138 -0700 
OS Version:  iPhone OS 4.0 (8A293) 
Report Version: 104 



Exception Type: 00000020 
Exception Codes: 0x8badf00d 
Highlighted Thread: 0 



Application Specific Information: 
com.xyz.xyz failed to launch in time 
elapsed total CPU time (seconds): 20.180 (user 15.910, system 4.270), 100% CPU 
elapsed application CPU time (seconds): 10.960, 54% CPU 



Thread 0: 
0 libobjc.A.dylib     0x3523a50c objc_msgSend + 44 
1 CoreFoundation     0x363bf568 -[__NSArrayM addObject:] 
2 XYZ      0x0000a152 -[Database fetchDrinks:] + 290 
3 XYZ      0x0000677c -[Database getAllDrinks] + 136 
4 XYZ      0x0003a164 -[SecondaryLoadingViewController viewDidLoad] + 208 
5 UIKit        0x323e582c -[UIViewController view] 
6 UIKit        0x323f9628 -[UIViewController viewControllerForRotation] 
7 UIKit        0x323f9574 -[UIViewController _visibleView] 
8 UIKit        0x323f94fc -[UIViewController rotatingContentViewForWindow:] 
9 UIKit        0x3249a514 -[UIClientRotationContext initWithClient:toOrientation:duration:andWindow:] 
10 UIKit        0x32499314 -[UIWindow _setRotatableClient:toOrientation:duration:force:] 
11 UIKit        0x32497d78 -[UIWindowController transition:fromViewController:toViewController:target:didEndSelector:] 
12 UIKit        0x32497534 -[UIViewController presentModalViewController:withTransition:] 
13 UIKit        0x324977fc -[UIViewController _tryRecursivelyPresentModalViewController:withTransition:] 
14 UIKit        0x324977c0 -[UIViewController _tryRecursivelyPresentModalViewController:withTransition:] 
15 UIKit        0x32496e00 -[UIViewController presentModalViewController:withTransition:] 
16 UIKit        0x3249699c -[UIViewController presentModalViewController:animated:] 
17 XYZ      0x000044a2 -[HomeViewController viewDidLoad] + 82 
18 UIKit        0x323e582c -[UIViewController view] 
19 UIKit        0x323fd68c -[UIViewController contentScrollView] 
20 UIKit        0x323fd4ac -[UINavigationController _computeAndApplyScrollContentInsetDeltaForViewController:] 
21 UIKit        0x323fd358 -[UINavigationController _layoutViewController:] 
22 UIKit        0x323fccb8 -[UINavigationController _startTransition:fromViewController:toViewController:] 
23 UIKit        0x323fca1c -[UINavigationController _startDeferredTransitionIfNeeded] 
24 UIKit        0x323fc90c -[UINavigationController viewWillLayoutSubviews] 
25 UIKit        0x323fc43c -[UILayoutContainerView layoutSubviews] 
26 UIKit        0x32370ab0 -[UIView(CALayerDelegate) _layoutSublayersOfLayer:] 
27 CoreFoundation     0x363c85ba -[NSObject(NSObject) performSelector:withObject:] 
28 QuartzCore      0x30c8c61c 0x30c82000 + 42524 
29 QuartzCore      0x30c8c2a4 0x30c82000 + 41636 
30 QuartzCore      0x30c8bbb0 0x30c82000 + 39856 
31 QuartzCore      0x30c8b7d8 0x30c82000 + 38872 
32 QuartzCore      0x30c8b684 0x30c82000 + 38532 
33 UIKit        0x323d99d4 -[UIApplication _reportAppLaunchFinished] 
34 UIKit        0x3251d77c -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] 
35 UIKit        0x323d87b8 -[UIApplication handleEvent:withNewEvent:] 
36 UIKit        0x323d7eb4 -[UIApplication sendEvent:] 
37 UIKit        0x323d77e8 _UIApplicationHandleEvent 
38 GraphicsServices     0x33c4dedc PurpleEventCallback 
39 CoreFoundation     0x364142ac __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ 
40 CoreFoundation     0x364161d6 __CFRunLoopDoSource1 
41 CoreFoundation     0x3641718e __CFRunLoopRun 
42 CoreFoundation     0x363be0bc CFRunLoopRunSpecific 
43 CoreFoundation     0x363bdfca CFRunLoopRunInMode 
44 UIKit        0x32363b18 -[UIApplication _run] 
45 UIKit        0x32361fb8 UIApplicationMain 
46 XYZ      0x00002b20 main + 36 
47 XYZ      0x00002af0 start + 32 

UPDATE 我试图运行耗时导入代码在一个单独的线程的时间(只有可能发生在应用程序更新)。我甚至使用具有嵌入式进度条的AlertView更新GUI,以便用户知道仍在发生某些事情。在我们的测试过程中,这工作正常。以下是似乎不工作的线程代码。崩溃日志似乎表明所有工作都在主线程上完成。

if ([database appDidUpdate] == YES) { 
    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; 
    dbImportThread = [[NSThread alloc] initWithTarget:self selector:@selector(import) object:nil]; 
    [dbImportThread start]; 
    [pool release]; 

- (void)import { 
//do importing work and update the gui with the progress 
} 
+1

是你所加载的所有这些信息是否需要立即通过应用程序?延迟加载应该是你在移动设备上的朋友。 – 2010-11-30 20:38:24

+0

@Jesse Naugher +1。如果您的移动应用设计要求您的用户在应用启动时保持20多秒的时间,您的问题就会比崩溃更严重。这只是糟糕的设计。您只需加载需要立即显示的数据,即可解决您的所有问题并全面改善应用程序。 – TechZen 2010-11-30 20:50:03

您仍然阻止主线程时间过长 - 无论是在启动期间还是之后。只在主线程上做轻量级GUI工作。如果您在第二个线程上执行工作,但在主线程中等待结果,主线程也会被阻塞。

乐器是你的朋友在这里。

虽然我没有与这种直接的经验,阅读你的崩溃日志之后,看来该设备注意到您的应用程序启动后以100%的CPU时间略超过20秒。看起来即使这种CPU使用率不在applicationDidFinishLaunching:方法中,操作系统也不会被愚弄并终止您的应用程序。

它设置了一个看门狗定时器。它阻塞主线程20秒以上。如前所述,你需要延迟加载。只加载在第一个屏幕上可见的内容。

在其上运行一段时间配置文件中使用的仪器, 尝试修复任何特别低效,并尝试踢尽可能多的可以到后台线程脱身。(IE东西都不会被更新UI) 您可以在后台线程上加载大量数据,并且一旦数据对象已经设置,将它们传递回主线程,并从那里运行更新选择器。

似乎一切都在主线程上执行......(我是对吗?)如果是这种情况,它可能会卡住你的用户界面。您是否考虑在另一个线程上加载数据库信息并在获取数据时更新GUI?其次,您可以测量每个代码块在时间关系中的性能,并查看究竟需要多少时间才能加载。