我正在調試我們的應用程序的用戶報告,在iOS11的背景下重複退出,即使在主動使用期間(例如,用戶背景我們並返回一些幾秒或一分鐘,只能發現它重新啓動)。崩潰日誌都顯示相同的原因:看門狗超時。下面是一個這樣的崩潰日誌的相關位:iOS11看門狗超時崩潰(0x8badf00d)但代碼不在堆棧
Exception Type: EXC_CRASH (SIGKILL)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Exception Note: EXC_CORPSE_NOTIFY
Termination Reason: Namespace <0xF>, Code 0x8badf00d
Triggered by Thread: 0
我認識到,我們的代碼具有的接收推送通知或轉到後臺運行時,在此期間操作時有限的一段時間。我們絕對不使用UIBackgroundTasks(與Alamofire Networking,FWIW),我們也有到期處理程序做到這一點:
backgroundTask = [application beginBackgroundTaskWithExpirationHandler:^{
[application endBackgroundTask:backgroundTask];
backgroundTask = UIBackgroundTaskInvalid; // Set the task to be invalid
DebugLog(@"Ended because expiration");
}];
這些崩潰報告中最令人困惑的事情是,我們的代碼是無處上的堆棧。我們從this Apple discussion of the 0x8badf00d exception code可以看到,實際上,在主線程上主動執行有問題的代碼。
但是,在我的情況下,沒有任何堆棧有任何我的代碼正在執行。下面是一個代表性的樣本:
Thread 0 name: Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0 libsystem_kernel.dylib 0x0000000183208bc4 0x183208000 + 3012
1 libsystem_kernel.dylib 0x0000000183208a3c 0x183208000 + 2620
2 CoreFoundation 0x00000001836b9c4c 0x1835d0000 + 957516
3 CoreFoundation 0x00000001836b7818 0x1835d0000 + 948248
4 CoreFoundation 0x00000001835d7e78 0x1835d0000 + 32376
5 GraphicsServices 0x000000018546cf84 0x185462000 + 44932
6 UIKit 0x000000018d37a0bc 0x18d307000 + 471228
7 MyApp 0x0000000102a6572c main + 87852 (main.m:22)
8 libdyld.dylib 0x00000001830fa56c 0x1830f9000 + 5484
Thread 1 name: com.apple.uikit.eventfetch-thread
Thread 1:
0 libsystem_kernel.dylib 0x0000000183208bc4 0x183208000 + 3012
1 libsystem_kernel.dylib 0x0000000183208a3c 0x183208000 + 2620
2 CoreFoundation 0x00000001836b9c4c 0x1835d0000 + 957516
3 CoreFoundation 0x00000001836b7818 0x1835d0000 + 948248
4 CoreFoundation 0x00000001835d7e78 0x1835d0000 + 32376
5 Foundation 0x00000001840006e4 0x183ff4000 + 50916
6 Foundation 0x000000018401fafc 0x183ff4000 + 178940
7 UIKit 0x000000018ded9630 0x18d307000 + 12396080
8 Foundation 0x0000000184101860 0x183ff4000 + 1103968
9 libsystem_pthread.dylib 0x000000018333c31c 0x18333a000 + 8988
10 libsystem_pthread.dylib 0x000000018333c1e8 0x18333a000 + 8680
11 libsystem_pthread.dylib 0x000000018333ac28 0x18333a000 + 3112
Thread 2 name: com.twitter.crashlytics.ios.MachExceptionServer
Thread 2:
0 libsystem_kernel.dylib 0x0000000183208bc4 0x183208000 + 3012
1 libsystem_kernel.dylib 0x0000000183208a3c 0x183208000 + 2620
2 MyApp 0x0000000102cdaad8 CLSMachExceptionServer + 100
3 libsystem_pthread.dylib 0x000000018333c31c 0x18333a000 + 8988
4 libsystem_pthread.dylib 0x000000018333c1e8 0x18333a000 + 8680
5 libsystem_pthread.dylib 0x000000018333ac28 0x18333a000 + 3112
Thread 3 name: com.apple.NSURLConnectionLoader
Thread 3:
0 libsystem_kernel.dylib 0x0000000183208bc4 0x183208000 + 3012
1 libsystem_kernel.dylib 0x0000000183208a3c 0x183208000 + 2620
2 CoreFoundation 0x00000001836b9c4c 0x1835d0000 + 957516
3 CoreFoundation 0x00000001836b7818 0x1835d0000 + 948248
4 CoreFoundation 0x00000001835d7e78 0x1835d0000 + 32376
5 CFNetwork 0x0000000183d41de0 0x183c93000 + 716256
6 Foundation 0x0000000184101860 0x183ff4000 + 1103968
7 libsystem_pthread.dylib 0x000000018333c31c 0x18333a000 + 8988
8 libsystem_pthread.dylib 0x000000018333c1e8 0x18333a000 + 8680
9 libsystem_pthread.dylib 0x000000018333ac28 0x18333a000 + 3112
Thread 4 name: AVAudioSession Notify Thread
Thread 4:
0 libsystem_kernel.dylib 0x0000000183208bc4 0x183208000 + 3012
1 libsystem_kernel.dylib 0x0000000183208a3c 0x183208000 + 2620
2 CoreFoundation 0x00000001836b9c4c 0x1835d0000 + 957516
3 CoreFoundation 0x00000001836b7818 0x1835d0000 + 948248
4 CoreFoundation 0x00000001835d7e78 0x1835d0000 + 32376
5 AVFAudio 0x0000000189615774 0x189591000 + 542580
6 AVFAudio 0x0000000189640018 0x189591000 + 716824
7 libsystem_pthread.dylib 0x000000018333c31c 0x18333a000 + 8988
8 libsystem_pthread.dylib 0x000000018333c1e8 0x18333a000 + 8680
9 libsystem_pthread.dylib 0x000000018333ac28 0x18333a000 + 3112
Thread 5:
0 libsystem_kernel.dylib 0x0000000183229150 0x183208000 + 135504
1 libsystem_pthread.dylib 0x000000018333ed30 0x18333a000 + 19760
2 libc++.1.dylib 0x00000001828e3ea4 0x1828dc000 + 32420
3 JavaScriptCore 0x000000018b157d00 0x18a812000 + 9723136
4 JavaScriptCore 0x000000018b157c28 0x18a812000 + 9722920
5 JavaScriptCore 0x000000018b157f8c 0x18a812000 + 9723788
6 libsystem_pthread.dylib 0x000000018333c31c 0x18333a000 + 8988
7 libsystem_pthread.dylib 0x000000018333c1e8 0x18333a000 + 8680
8 libsystem_pthread.dylib 0x000000018333ac28 0x18333a000 + 3112
Thread 6 name: WebThread
Thread 6:
0 libsystem_kernel.dylib 0x0000000183208bc4 0x183208000 + 3012
1 libsystem_kernel.dylib 0x0000000183208a3c 0x183208000 + 2620
2 CoreFoundation 0x00000001836b9c4c 0x1835d0000 + 957516
3 CoreFoundation 0x00000001836b7818 0x1835d0000 + 948248
4 CoreFoundation 0x00000001835d7e78 0x1835d0000 + 32376
5 WebCore 0x000000018bc1c75c 0x18bbdb000 + 268124
6 libsystem_pthread.dylib 0x000000018333c31c 0x18333a000 + 8988
7 libsystem_pthread.dylib 0x000000018333c1e8 0x18333a000 + 8680
8 libsystem_pthread.dylib 0x000000018333ac28 0x18333a000 + 3112
Thread 7 name: WebCore: LocalStorage
Thread 7:
0 libsystem_kernel.dylib 0x0000000183229150 0x183208000 + 135504
1 libsystem_pthread.dylib 0x000000018333ed30 0x18333a000 + 19760
2 JavaScriptCore 0x000000018a81fa18 0x18a812000 + 55832
3 JavaScriptCore 0x000000018b13da04 0x18a812000 + 9615876
4 WebKitLegacy 0x000000018d00f5fc 0x18cf7c000 + 603644
5 WebKitLegacy 0x000000018d01226c 0x18cf7c000 + 615020
6 WebKitLegacy 0x000000018d011998 0x18cf7c000 + 612760
7 JavaScriptCore 0x000000018a81c010 0x18a812000 + 40976
8 JavaScriptCore 0x000000018a81bf50 0x18a812000 + 40784
9 libsystem_pthread.dylib 0x000000018333c31c 0x18333a000 + 8988
10 libsystem_pthread.dylib 0x000000018333c1e8 0x18333a000 + 8680
11 libsystem_pthread.dylib 0x000000018333ac28 0x18333a000 + 3112
Thread 8 name: com.apple.CFSocket.private
Thread 8:
0 libsystem_kernel.dylib 0x0000000183229570 0x183208000 + 136560
1 CoreFoundation 0x00000001836c2184 0x1835d0000 + 991620
2 libsystem_pthread.dylib 0x000000018333c31c 0x18333a000 + 8988
3 libsystem_pthread.dylib 0x000000018333c1e8 0x18333a000 + 8680
4 libsystem_pthread.dylib 0x000000018333ac28 0x18333a000 + 3112
Thread 9:
0 libsystem_pthread.dylib 0x000000018333ac1c 0x18333a000 + 3100
Thread 10:
0 libsystem_kernel.dylib 0x0000000183229dbc 0x183208000 + 138684
1 libsystem_pthread.dylib 0x000000018333afa0 0x18333a000 + 4000
2 libsystem_pthread.dylib 0x000000018333ac20 0x18333a000 + 3104
Thread 11:
0 libsystem_pthread.dylib 0x000000018333ac1c 0x18333a000 + 3100
Thread 0 crashed with ARM Thread State (64-bit):
x0: 0x0000000010004005 x1: 0x0000000007000806 x2: 0x0000000000000000 x3: 0x0000000000000c00
x4: 0x0000000000002b03 x5: 0x00000000ffffffff x6: 0x0000000000000000 x7: 0x0000000000000000
x8: 0x00000000fffffbbf x9: 0x0000000007000000 x10: 0x0000000007000100 x11: 0x0000000000000040
x12: 0xffffffffffffffff x13: 0x0000000000000001 x14: 0x01e8540001e85400 x15: 0x0000000000000000
x16: 0xffffffffffffffe1 x17: 0x00000000ffffffff x18: 0x0000000000000000 x19: 0x0000000000000000
x20: 0x00000000ffffffff x21: 0x0000000000002b03 x22: 0x0000000000000c00 x23: 0x000000016d3aed38
x24: 0x0000000007000806 x25: 0x0000000000000000 x26: 0x0000000007000806 x27: 0x0000000000000c00
x28: 0x0000000000000001 fp: 0x000000016d3aec30 lr: 0x0000000183208a3c
sp: 0x000000016d3aebe0 pc: 0x0000000183208bc4 cpsr: 0x60000000
的運行我的代碼只有一部分是main.m文件,22行,這是
int retVal = UIApplicationMain(argc, argv, nil, @"PSSMyAppDelegate");
因此,我很困惑,我的應用程序怎麼可能因爲看起來我的代碼實際上並沒有運行,所以會因爲運行時間違規而反覆殺死。 iOS 11中是否有新內容可以改變看門狗進程的行爲?如果沒有,我怎麼知道我的代碼的哪一部分是違反運行時間過長的部分?