3

I've got an app that loads it's content via WKWebView. This WebView sometimes has <audio>-Content which the user is able to play. The intention is that this audio content continues to play while the app is in background mode or the device gets locked. So far so good this works well on iOS <= 10 but since iOS11 the app gets killed by watchdog.

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

...

The crash log does not give any indication to my code. Does anyone have an idea what causes watchdog to kill my app on iOS11?

I recently built a test app with a WKWebView that just contains a static HTML file with audio tag. That does NOT get killed by watchdog.

I also recognized that the test app shows the proper media controls with an ongoing time-indicator while the "live"-app freezes the media controls and does not give a time indicator update. I think this indicates some kind of Main-thread delay/lock..!?

dibi
  • 3,257
  • 4
  • 24
  • 31

1 Answers1

1

I did a research which took me about one day, at last I found there was nothing with WkWebview and audio tag IN MY CASE.

It's caused by background task which was not ended. So search your code with "beginBackgroundTaskWithExpirationHandler" and also "beginBackgroundTaskWithName:", make sure every background task is ended correctly.

Before you create a new background task, remember to end the old one, and assign the new one to a member variable.

Robert
  • 470
  • 4
  • 12