ios 卡在splash页研究

类似的问题http://answers.unity3d.com/questions/1078647/ios-9-unity-sometimes-hangs-in-main-ios-kills-proc.html

开始以为是在ios主线程进行的网络操作导致的卡住
以下开始认为的解决方案
以下这段代码要放到子线程执行, 否则有可能会导致主线程阻塞时间过长, 导致ios kill掉进程
- (BOOL)addSkipBackupAttributeToItemAtPath:(NSString *) filePathString
{
    NSURL* URL= [NSURL fileURLWithPath: filePathString];
    assert([[NSFileManager defaultManager] fileExistsAtPath: [URL path]]);

    NSError *error = nil;
    BOOL success = [URL setResourceValue: [NSNumber numberWithBool: YES]
                                  forKey: NSURLIsExcludedFromBackupKey error: &error];
    if(!success){
        NSLog(@"Error excluding %@ from backup %@", [URL lastPathComponent], error);
    }
    return success;
}

最新找到的解决方案, Ad Hoc的签名会在启动时被ios检查
Captive Network: Ad Hoc app force crashing FBApplicationProcess 0x000000008badf00d
There's a new issue reported on my app (on AdHoc profile) for this release which is app crashing on startup when in captive network.
The exact scenario is: Have a device with expired service (but still connected to the provider), turn off wifi. Have the app cold-launched and it'll get stuck on the screen for sometime and the crashed.

Mar 23 16:08:52 QA-iPhone-4S-Sprint SpringBoard[48] : Forcing crash report of (reason: 1, description: com.myapp.iphone.AppName failed to launch after 20.00s (launchIntent: foreground-interactive))
Mar 23 16:08:52 QA-iPhone-4S-Sprint com.apple.xpc.launchd[1] (UIKitApplication:com.myapp.iphone.AppName[0x8816][183]) : Service exited due to signal: Killed: 9


Googling the message you'd get a bunch of stack overflow posts saying that's because it takes too long to launch, and maybe you're doing some network requests on main thread.

Well in this issue that's not the case at all. I confirmed that AppDelegate's init() or didFinishLaunchingWithOptions() hasn't even been called when the crash happened, so that can't be the program's code. It must've been pre-launch sequence which failed, that is in iOS-land.

Here's the state of the app when this crashes happen:
- What's new about the release's the inclusion of Swift dynamic framework. Tested with a build before & after the inclusion, I proved that this inclusion caused the crash
- Exporting ipa via XCode forces code-signing using "XC Adhoc" notice the XC prefix (XC = Xcode managed prefix) - instead of standard "Adhoc". There's no way to change it as of XCode 7.2.1.
- App crashed even before AppDelegate is executed. It's not programmer's code.


Long story short, after a day worth of trial and error and going back in time in git log, I found out what went wrong. Here's the conclusion:

On startup, iOS always re-verify the integrity of dynamic frameworks if the app is signed with "XC Adhoc" (Xcode-Managed) profiles.

It's proven by using TestFlight distributed app (signed with Distribution profile), and the issue's not reproducible anymore.
Posted by naldikt at 11:29 AM

猜你喜欢

转载自wanzhanzhuce.iteye.com/blog/2293706
今日推荐