iOS 11 WKWebView应用程序在播放音频时从Watchdog获取SIGKILL

时间:2017-11-17 10:34:22

标签: audio background ios11 wkwebview sigkill

我有一个应用程序通过WKWebView加载它的内容。此WebView有时具有<audio> - 用户可以播放的内容。目的是当应用程序处于后台模式或设备被锁定时,此音频内容继续播放。到目前为止,这在iOS&lt; = 10上运行良好,但自iOS11以来,应用程序被监视器杀死。

Exception Type:  EXC_CRASH (SIGKILL)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Exception Note:  EXC_CORPSE_NOTIFY
Termination Reason: Namespace <0xF>, Code 0x8badf00d
Triggered by Thread:  0

Filtered syslog:
None found

Thread 0 name:  Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0   libsystem_kernel.dylib          0x0000000183f45150 __psynch_cvwait + 8
1   libsystem_pthread.dylib         0x000000018405efc0 _pthread_cond_wait$VARIANT$armv81 + 624
2   JavaScriptCore                  0x000000018ad690ac WTF::ThreadCondition::timedWait+ 53420 (WTF::Mutex&, double) + 148
3   JavaScriptCore                  0x000000018b676a1c WTF::BinarySemaphore::wait+ 9546268 (WTF::TimeWithDynamicClockType) + 88
4   WebKit                          0x00000001934d3d2c IPC::Connection::waitForSyncReply+ 208172 (unsigned long long, WTF::Seconds, WTF::OptionSet<IPC::SendSyncOption>) + 276
5   WebKit                          0x00000001934d3524 IPC::Connection::sendSyncMessage+ 206116 (unsigned long long, std::__1::unique_ptr<IPC::Encoder, std::__1::default_delete<IPC::Encoder> >, WTF::Seconds, WTF::OptionSet<IPC::SendSyncOption>) + 348
6   WebKit                          0x00000001936f5f78 bool IPC::Connection::sendSync<Messages::WebProcess::ProcessWillSuspendImminently>+ 2445176 (Messages::WebProcess::ProcessWillSuspendImminently&&, Messages::WebProcess::ProcessWillSuspendImminently::Reply&&, unsigned long long, WTF::Seconds, WTF::OptionSet<IPC::SendSyncOption>) + 144
7   WebKit                          0x00000001936f0d74 bool WebKit::ChildProcessProxy::sendSync<Messages::WebProcess::ProcessWillSuspendImminently>+ 2424180 (Messages::WebProcess::ProcessWillSuspendImminently&&, Messages::WebProcess::ProcessWillSuspendImminently::Reply&&, unsigned long long, WTF::Seconds, WTF::OptionSet<IPC::SendSyncOption>) + 120
8   WebKit                          0x00000001936f0cec WebKit::WebProcessProxy::sendProcessWillSuspendImminently+ 2424044 () + 76
9   WebKit                          0x0000000193582164 -[WKProcessAssertionBackgroundTaskManager _notifyClientsOfImminentSuspension] + 228
10  WebKit                          0x000000019358246c __64-[WKProcessAssertionBackgroundTaskManager _updateBackgroundTask]_block_invoke + 172
11  UIKit                           0x000000018dacad14 -[UIApplication workspaceNoteAssertionExpirationImminent:] + 284
12  libdispatch.dylib               0x0000000183db1048 _dispatch_client_callout + 16
13  libdispatch.dylib               0x0000000183decb10 _dispatch_block_invoke_direct$VARIANT$armv81 + 280
14  FrontBoardServices              0x0000000186b0d9f4 __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__ + 36
15  FrontBoardServices              0x0000000186b0d698 -[FBSSerialQueue _performNext] + 404
16  FrontBoardServices              0x0000000186b0dc34 -[FBSSerialQueue _performNextFromRunLoopSource] + 56
17  CoreFoundation                  0x00000001843d62e8 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 24
18  CoreFoundation                  0x00000001843d6268 __CFRunLoopDoSource0 + 88
19  CoreFoundation                  0x00000001843d5af0 __CFRunLoopDoSources0 + 204
20  CoreFoundation                  0x00000001843d36c8 __CFRunLoopRun + 1048
21  CoreFoundation                  0x00000001842f3fb8 CFRunLoopRunSpecific + 436
22  GraphicsServices                0x000000018618bf84 GSEventRunModal + 100
23  UIKit                           0x000000018d8c82e8 UIApplicationMain + 208
24  My.App.bundle           0x000000010286c43c main + 492604 (main.m:14)
25  libdyld.dylib                   0x0000000183e1656c start + 4

...

崩溃日志不会对我的代码给出任何指示。有没有人知道是什么导致看门狗在iOS11上杀死我的应用程序?

我最近使用WKWebView构建了一个测试应用程序,该应用程序只包含带有音频标记的静态HTML文件。这不会被看门人杀死。

我还认识到测试应用程序显示正确的媒体控件,其中包含正在进行的时间指示,而#34; live&#34; -app冻结媒体控件并且不提供时间指示器更新。我认为这表明某种主线程延迟/锁定..!?

1 个答案:

答案 0 :(得分:0)

我做了一项研究,花了我一天的时间,最后我发现WkWebview和音频标签在我的案例中没有任何内容。

它是由未完成的后台任务引起的。因此,使用“beginBackgroundTaskWithExpirationHandler”和“beginBackgroundTaskWithName:”搜索代码,确保每个后台任务都正确结束。

在创建新的后台任务之前,请记住结束旧的后台任务,并将新的任务分配给成员变量。