WKWebView crash on iOS 15 beta running in simulator

I built a simple demo app that implements the code that Apple provides here for instantiating an WKWebView.

https://developer.apple.com/documentation/webkit/wkwebview

This code causes a crash when launched from Xcode but I don't seem to have a problem if I run the installed app directly from the simulator.

Has anyone else run into this issue while testing iOS 15? Are there new considerations that I need take into account when migrating my app to support iOS 15?

I'm running Xcode version 13.0 beta 5 (13A5212g).

Thank you!

Here's the backtrace:

* thread #7, queue = 'com.apple.root.default-qos', stop reason = EXC_BREAKPOINT (code=1, subcode=0x10058c530)

  * frame #0: 0x000000010058c530 libdispatch.dylib`_dispatch_sema4_timedwait.cold.3 + 36

    frame #1: 0x0000000100555f84 libdispatch.dylib`_dispatch_sema4_timedwait + 128

    frame #2: 0x0000000100556508 libdispatch.dylib`_dispatch_semaphore_wait_slow + 72

    frame #3: 0x0000000196af2a0c MediaAccessibility`_copyResultPreferenceXPCCall(__CFString const*, bool, void const*, bool*) + 236

    frame #4: 0x0000000196af1ea8 MediaAccessibility`MAPreferencesCopyProfileValue + 136

    frame #5: 0x0000000196af20a0 MediaAccessibility`MAPreferencesCopyProfileValueWithExpectedType + 28

    frame #6: 0x0000000196aefcc8 MediaAccessibility`MACaptionAppearancePrefCopyPreferredLanguages + 40

    frame #7: 0x0000000196aeb990 MediaAccessibility`MACaptionAppearanceCopySelectedLanguages + 32

    frame #8: 0x000000018af971c0 WebCore`WebCore::CaptionUserPreferencesMediaAF::platformPreferredLanguages() + 40

    frame #9: 0x000000018921c244 WebKit`invocation function for block in WebKit::WebProcessPool::setMediaAccessibilityPreferences(WebKit::WebProcessProxy&) + 36

    frame #10: 0x0000000100554028 libdispatch.dylib`_dispatch_call_block_and_release + 24

    frame #11: 0x0000000100555828 libdispatch.dylib`_dispatch_client_callout + 16

    frame #12: 0x0000000100558118 libdispatch.dylib`_dispatch_queue_override_invoke + 960

    frame #13: 0x0000000100567d24 libdispatch.dylib`_dispatch_root_queue_drain + 432

    frame #14: 0x0000000100568814 libdispatch.dylib`_dispatch_worker_thread2 + 188

    frame #15: 0x00000001c80effec libsystem_pthread.dylib`_pthread_wqthread + 212
Answered by Sandro@ROQAPPS in 687006022

This is not a problem with WKWebView. It's a general issue with dispatch semaphores in the current beta of iOS 15. It's acknowledged as a known issue under Debugging in the release notes of iOS 15.

See: https://developer.apple.com/documentation/ios-ipados-release-notes/ios-ipados-15-beta-release-notes

Under Debugging > Known issues

Using dispatch semaphores in an iOS app running in a device simulator on a Mac with Apple silicon running macOS 11 will cause the app to crash. (81783378)

There is also a workaround for this issue:

Workaround: In Xcode, select Product > Scheme > Edit Scheme, then deselect Run > Options > Queue Debugging > “Enable backtrace recording.”

This workaround is working and solved this problem for me. I can now work with the simulator again. I need to have a closer look at the release notes in the future to spot this issues earlier.

I have the same problem here. Whenever I'm trying to show a WKWebkitView in a SwiftUI environment the app stops with the following error: Thread 8: EXC_BREAKPOINT (code=1, subcode=0x1053a8530)

And this stack trace:

#0	0x00000001053a8530 in _dispatch_sema4_timedwait.cold.3 ()
#1	0x0000000105371f84 in _dispatch_sema4_timedwait ()
#2	0x0000000105372508 in _dispatch_semaphore_wait_slow ()
#3	0x0000000196af2a0c in _copyResultPreferenceXPCCall(__CFString const*, bool, void const*, bool*) ()
#4	0x0000000196af1ea8 in MAPreferencesCopyProfileValue ()
#5	0x0000000196af20a0 in MAPreferencesCopyProfileValueWithExpectedType ()
#6	0x0000000196aefcc8 in MACaptionAppearancePrefCopyPreferredLanguages ()
#7	0x0000000196aeb990 in MACaptionAppearanceCopySelectedLanguages ()
#8	0x000000018af971c0 in WebCore::CaptionUserPreferencesMediaAF::platformPreferredLanguages() ()
#9	0x000000018921c244 in invocation function for block in WebKit::WebProcessPool::setMediaAccessibilityPreferences(WebKit::WebProcessProxy&) ()
#10	0x0000000105370028 in _dispatch_call_block_and_release ()
#11	0x0000000105371828 in _dispatch_client_callout ()
#12	0x0000000105374118 in _dispatch_queue_override_invoke ()
#13	0x0000000105383d24 in _dispatch_root_queue_drain ()
#14	0x0000000105384814 in _dispatch_worker_thread2 ()
#15	0x00000001c80effec in _pthread_wqthread ()
Enqueued from com.apple.main-thread (Thread 1) Queue : com.apple.main-thread (serial)
#0	0x0000000105375c54 in dispatch_async ()
#1	0x000000018921c1b0 in WebKit::WebProcessPool::setMediaAccessibilityPreferences(WebKit::WebProcessProxy&) ()
#2	0x00000001892e5110 in WebKit::WebProcessPool::initializeNewWebProcess(WebKit::WebProcessProxy&, WebKit::WebsiteDataStore*, WebKit::WebProcessProxy::IsPrewarmed) ()
#3	0x00000001892e5490 in WebKit::WebProcessPool::createNewWebProcess(WebKit::WebsiteDataStore*, WebKit::WebProcessProxy::IsPrewarmed) ()
#4	0x00000001892e6ac0 in WebKit::WebProcessPool::processForRegistrableDomain(WebKit::WebsiteDataStore&, WebKit::WebPageProxy*, WebCore::RegistrableDomain const&) ()
#5	0x00000001892e6ddc in WebKit::WebProcessPool::createWebPage(WebKit::PageClient&, WTF::Ref<API::PageConfiguration, WTF::RawPtrTraits<API::PageConfiguration> >&&) ()
#6	0x0000000189648214 in -[WKContentView _commonInitializationWithProcessPool:configuration:] ()
#7	0x0000000189648cac in -[WKContentView initWithFrame:processPool:configuration:webView:] ()
#8	0x00000001891667f0 in -[WKWebView _initializeWithConfiguration:] ()
#9	0x00000001891679ec in -[WKWebView initWithFrame:configuration:] ()
#10	0x0000000104f8a404 in @nonobjc WKWebView.init(frame:configuration:) ()
#11	0x0000000104f896a0 in WKWebView.__allocating_init(frame:configuration:) ()

I'm using an M1 MacBook Air with macOS 11.5.2, Xcode 13.0 beta 5 (13A5212g) and the iOS 15 simulator. This only happens on the simulator. It works just fine on my iPhone SE 2020 running iOS 15 beta 8.

I also see this somewhat cryptic message in the debug, both when running on simulator and on device:

Writing analzed variants.

Accepted Answer

This is not a problem with WKWebView. It's a general issue with dispatch semaphores in the current beta of iOS 15. It's acknowledged as a known issue under Debugging in the release notes of iOS 15.

See: https://developer.apple.com/documentation/ios-ipados-release-notes/ios-ipados-15-beta-release-notes

Under Debugging > Known issues

Using dispatch semaphores in an iOS app running in a device simulator on a Mac with Apple silicon running macOS 11 will cause the app to crash. (81783378)

There is also a workaround for this issue:

Workaround: In Xcode, select Product > Scheme > Edit Scheme, then deselect Run > Options > Queue Debugging > “Enable backtrace recording.”

This workaround is working and solved this problem for me. I can now work with the simulator again. I need to have a closer look at the release notes in the future to spot this issues earlier.

I also have the same problem here with Intel processor. The code crashes when I am launching from Xcode but I don't seem to have a problem if I run the installed app directly from the simulator by tapping on app icon.

I am using Xcode 13.2.1. And iOS version is 15.2. If I run app on iOS 14.5. It is working fine. Also on real device working fine. And macOS Version 12.0.1(macOS Monterey)

Here is backtrace.

  `thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x10)
  frame #0: 0x00007fff20198d24 libobjc.A.dylib`class_createInstance + 125
  frame #1: 0x00007fff20112f66
  frame #2: 0x00007fff20118c19
  frame #3: 0x00007fff265e625d
  frame #4: 0x00007fff2011383a
  frame #5: 0x00007fff20114a0d
  frame #6: 0x00007fff265ff8c6
  frame #7: 0x00007fff265ffc0b
  frame #8: 0x00007fff265ff214
  frame #9: 0x00007fff2011383a
  frame #10: 0x00007fff20114a0d
  frame #11: 0x00007fff265ff1ee
  frame #12: 0x00007fff35e0245b NetworkExtension`+[NEFilterSource filterRequired] + 35
  frame #13: 0x00007fff298dde70 WebKit`WebKit::WebPageProxy::createNetworkExtensionsSandboxExtensions(WebKit::WebProcessProxy&) + 52
  frame #14: 0x00007fff298ddc99 WebKit`WebKit::WebPageProxy::addPlatformLoadParameters(WebKit::WebProcessProxy&, WebKit::LoadParameters&) + 95
  frame #15: 0x00007fff29988216 WebKit`WebKit::WebPageProxy::loadRequestWithNavigationShared(WTF::Ref<WebKit::WebProcessProxy, WTF::RawPtrTraits<WebKit::WebProcessProxy> >&&, WTF::ObjectIdentifier<WebCore::PageIdentifierType>, API::Navigation&, WebCore::ResourceRequest&&, WebCore::ShouldOpenExternalURLsPolicy, API::Object*, WebCore::ShouldTreatAsContinuingLoad, std::__1::optional<WebKit::NavigatingToAppBoundDomain>, std::__1::optional<WebKit::WebsitePoliciesData>&&, std::__1::optional<WTF::ObjectIdentifier<WebKit::NetworkResourceLoadIdentifierType> >) + 1060
  frame #16: 0x00007fff29987d0d WebKit`WebKit::WebPageProxy::loadRequest(WebCore::ResourceRequest&&, WebCore::ShouldOpenExternalURLsPolicy, API::Object*) + 787
  frame #17: 0x00007fff2983ac3b WebKit`-[WKWebView loadRequest:] + 137
  frame #18: 0x000000010c7448fa SonyLIV`___lldb_unnamed_symbol7230$$SonyLIV + 73
  frame #19: 0x000000010c6fee83 SonyLIV`___lldb_unnamed_symbol5787$$SonyLIV + 88
  frame #20: 0x000000010c6ff502 SonyLIV`GADDispatchAsyncSafeMainQueue + 45
  frame #21: 0x000000010c6fec3d SonyLIV`___lldb_unnamed_symbol5780$$SonyLIV + 211
  frame #22: 0x000000010c72aa00 SonyLIV`___lldb_unnamed_symbol6756$$SonyLIV + 622
  frame #23: 0x000000010c73e9fe SonyLIV`___lldb_unnamed_symbol7124$$SonyLIV + 207
  frame #24: 0x0000000114e1e848 libdispatch.dylib`_dispatch_call_block_and_release + 12
  frame #25: 0x0000000114e1fa2c libdispatch.dylib`_dispatch_client_callout + 8
  frame #26: 0x0000000114e2e1f1 libdispatch.dylib`_dispatch_main_queue_callback_4CF + 1197
  frame #27: 0x00007fff2036c84d CoreFoundation`__CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
  frame #28: 0x00007fff203670aa CoreFoundation`__CFRunLoopRun + 2772
  frame #29: 0x00007fff203660f3 CoreFoundation`CFRunLoopRunSpecific + 567
  frame #30: 0x00007fff2c995cd3 GraphicsServices`GSEventRunModal + 139
  frame #31: 0x00007fff25059f42 UIKitCore`-[UIApplication _run] + 928
  frame #32: 0x00007fff2505eb5e UIKitCore`UIApplicationMain + 101
  frame #33: 0x000000010ba20e9f SonyLIV`main at AppDelegate.swift:18:7
  frame #34: 0x000000011247dee9 dyld_sim`start_sim + 10
  frame #35: 0x000000011e4ea4fe dyld`start + 462`

Thank you

WKWebView crash on iOS 15 beta running in simulator
 
 
Q