WkWebView Crashed on iOS14

Hello, I ecnountered a crash on OS14. here is the case:
push a wkwebview vc, long press and wake the menu, then pop the webview vc;then anonther push wkwebview vc ,long press again,then it’ll crash。
here is the crash stack
  • thread #1, queue = 'com.apple.main-thread', stop reason = EXCBADACCESS (code=1, address=0x20)

  frame #0: 0x00000001ac4e3070 libobjc.A.dylibobjc_retain + 16   frame #1: 0x00000001b095d97c UIKitCore-[UIInputResponderController prepareToMoveKeyboardForInputViewSet:animationStyle:] + 372
  frame #2: 0x00000001b095be7c UIKitCore-[UIInputResponderController setKeyWindowSceneInputViews:animationStyle:] + 636   frame #3: 0x00000001b095bbd8 UIKitCore-[UIInputResponderController setInputViews:animationStyle:] + 216
  frame #4: 0x00000001b095d1f8 UIKitCore-[UIInputResponderController setInputViews:animated:] + 100   frame #5: 0x00000001b095d268 UIKitCore-[UIInputResponderController setInputViews:] + 80
  frame #6: 0x00000001b095aa3c UIKitCore__74-[UIInputResponderController _reloadInputViewsForKeyWindowSceneResponder:]_block_invoke.612 + 40   frame #7: 0x00000001b095a5a8 UIKitCore-[UIInputResponderController _reloadInputViewsForKeyWindowSceneResponder:] + 3708
  frame #8: 0x00000001b095970c UIKitCore-[UIInputResponderController _reloadInputViewsForResponder:] + 164   frame #9: 0x00000001b0f1e5e0 UIKitCore-[UIResponder(UIResponderInputViewAdditions) reloadInputViews] + 132
  frame #10: 0x00000001b0f196bc UIKitCore-[UIResponder becomeFirstResponder] + 780   frame #11: 0x00000001b13f0fcc UIKitCore-[UIView(Hierarchy) becomeFirstResponder] + 164
  frame #12: 0x00000001b4e74c7c WebKit-[WKContentView(WKInteraction) becomeFirstResponderForWebView] + 152   frame #13: 0x00000001b50e57e4 WebKit-[WKWebView(WKViewInternalIOS) becomeFirstResponder] + 148
  frame #14: 0x00000001b11ab1bc UIKitCore-[UITextInteractionAssistant(UITextInteractionAssistant_Internal) setFirstResponderIfNecessaryActivatingSelection:] + 196   frame #15: 0x00000001b0936844 UIKitCore-[UITextLoupeTouchBehavior textLoupeInteraction:gestureChangedWithState:location:translation:velocity:modifierFlags:shouldCancel:] + 596
  frame #16: 0x00000001b1184ec8 UIKitCore-[UITextLoupeInteraction loupeGestureWithState:location:translation:velocity:modifierFlags:shouldCancel:] + 164   frame #17: 0x00000001b11846b8 UIKitCore-[UITextLoupeInteraction loupeGesture:] + 648
  frame #18: 0x00000001b0a53144 UIKitCore-[UIGestureRecognizerTarget _sendActionWithGestureRecognizer:] + 56   frame #19: 0x00000001b0a5c8c0 UIKitCore_UIGestureRecognizerSendTargetActions + 116
  frame #20: 0x00000001b0a59560 UIKitCore_UIGestureRecognizerSendActions + 284   frame #21: 0x00000001b0a58ae0 UIKitCore-[UIGestureRecognizer _updateGestureForActiveEvents] + 636
  frame #22: 0x00000001b0a4ce2c UIKitCore_UIGestureEnvironmentUpdate + 2000   frame #23: 0x00000001ac72a30c CoreFoundationCFRUNLOOPISCALLINGOUTTOANOBSERVERCALLBACKFUNCTION + 36
  frame #24: 0x00000001ac724aa4 CoreFoundation__CFRunLoopDoObservers + 520   frame #25: 0x00000001ac724fbc CoreFoundation__CFRunLoopRun + 1060
  frame #26: 0x00000001ac724788 CoreFoundationCFRunLoopRunSpecific + 564   frame #27: 0x00000001b85ff820 GraphicsServicesGSEventRunModal + 164
  frame #28: 0x00000001b0ee31d8 UIKitCore-[UIApplication _run] + 1072   frame #29: 0x00000001b0ee90b8 UIKitCoreUIApplicationMain + 1876
  • frame #30: 0x0000000102e21c6c testwebviewmain(argc=1, argv=0x000000016cfe7880) at main.m:18:12
  frame #31: 0x00000001ac5b03d4 libdyld.dylibstart + 4
I met the same questions, hope workaround . and by the way ,we met another wkwebview's crash On iOS14.0. the crash thread info like below:

1
libobjc.A.dylib
objcrootReleaseWasZero (in libobjc.A.dylib) + 72
2
UIKitCore
  • [UIFocusContainerGuideMapEntry setFocusContainmentFrame:] (in UIKitCore) + 16

3
UIKitCore
  • [

UIFocusRegionMapEntry mapEntriesByOccludingWithFrame:] (in UIKitCore) + 3444
UIKitCore
  • [

UIFocusRegionMapSnapshot .cxxdestruct] (in UIKitCore) + 965
UIKitCore
  • [

UIFocusableRegionMapEntry description] (in UIKitCore) + 1166
UIKitCore
  • [UIFocusableRegionMapEntry description] (in UIKitCore) + 228

7
UIKitCore
  • [

UIFocusRegionMapSnapshot visualRepresentationWithMinimumArea:] (in UIKitCore) + 18448
UIKitCore
  • [UIFocusRegionMapSnapshot visualRepresentationWithMinimumArea:] (in UIKitCore) + 672

9
UIKitCore
  • [

UIFocusRegionMapSnapshot snapshotByFulfillingPromiseFocusRegionEntry:] (in UIKitCore) + 84810
UIKitCore
  • [

UIStateMachine(Legacy) setStaticTransitionFromState:withEvent:toState:] (in UIKitCore) + 12811
UIKitCore
  • [UIEstimatedTouchRecord initWithLiveTouch:freezeTouch:contextID:] (in UIKitCore) + 4

12
UIKitCore
  • [UIWebDocumentView(Interaction) deepestNodeAtViewportLocation:] (in UIKitCore) + 96

13
WebKit
  • [WKProcessAssertionBackgroundTaskManager

updateBackgroundTask] (in WebKit) + 27214
WebKit
bool IPC::MessageSender::send<Messages::WebPaymentCoordinator::DidAuthorizePayment>(Messages::WebPaymentCoordinator::DidAuthorizePayment const&, unsigned long long, WTF::OptionSet<IPC::SendOption>) (in WebKit) + 28
15
WebKit
  • [WKContentView(WKInteractionPreview) presentedViewControllerForPreviewItemController:] (in WebKit) + 1564

16
UIKitCore
  • [UIBezierPath encodeWithCoder:] (in UIKitCore) + 140

17
UIKitCore
21+[UIColor blackColor]blockinvoke (in UIKitCore) + 140
18
UIKitCore
  • [UIDisplayP3Color initWithDisplayP3Red:green:blue:alpha:] (in UIKitCore) + 196

19
UIKitCore
  • [UIDeviceRGBColor set] (in UIKitCore) + 48

20
UIKitCore
83+[UIAppearance applyInvocationsTo:window:matchingSelector:onlySystemInvocations:]blockinvoke (in UIKitCore) + 312
21
UIKitCore
  • [

UIAppearance appearancesAtNode:withObject:] (in UIKitCore) + 99222
UIKitCore
_processEventQueue (in UIKitCore) + 8700
23
UIKitCore
UIDrawViewRectAfterCommit (in UIKitCore) + 708
24
UIKitCore
  • [UIStatusBarLockView animateUnlockWithCompletionBlock:] (in UIKitCore) + 704

25
UIKitCore
  • [

UIStatusBarDualCellularSignalView setTopConstraint:] (in UIKitCore) + 026
CoreFoundation
  • [_NSDictionary0 copy] (in CoreFoundation) + 0

27
CoreFoundation
copyhelperblocke832o40o48b56o64r (in CoreFoundation) + 16
28
CoreFoundation
destroyhelperblocke832o40o48b56r64r (in CoreFoundation) + 16
29
CoreFoundation
CFRunLoopTimerSetNextFireDate (in CoreFoundation) + 1072
30
CoreFoundation
CFRunLoopTimerCreate (in CoreFoundation) + 384
31
GraphicsServices
GSSendEvent (in GraphicsServices) + 252
32
UIKitCore
  • [UISearchControllerATVSearchBarAnimator updateLayoutForGridKeyboard:animated:] (in UIKitCore) + 4092

33
UIKitCore
  • [_UISearchFormSheetPresentationController presentationTransitionWillBegin] (in UIKitCore) + 20

34
JD4iPhone
main (in JD4iPhone) (main.m:15)
35
libdyld.dylib
0x00000001802bb3d4 (in libdyld.dylib)


Hope Reply from Apple and workaround!!!!!!
I meet the same problem.

It seems -[UIInputViewSet restorableResponder] returns a wild pointer. This property is neither weak nor strong.
I added a symbol breakpoint to -[UIInputViewSet restorableResponder] and -[UIInputViewSet setRestorableResponder:], the assembly code shows they have neither store_weak nor store_strong code.

I used a workaround, hook -[UIInputViewSet restorableResponder] and return nil. Maybe it will cause another problem. But after testing it seems work well.


Thank you for reporting the exact steps for reproduction. We also have this problem.
@SHUANGQING: how do you hook -[UIInputViewSet restorableResponder]?
I also met this problem,do you have any solution now?
My workaround is to ban long press gesture for WKWebview until Apple fix it.

Code Block
if (IOS14_OR_LATER) {
    NSString *noneSelectString = @"document.documentElement.style.webkitTouchCallout='none';document.documentElement.style.webkitUserSelect='none';";
    WKUserScript *noneSelectScript = [[WKUserScript alloc] initWithSource:noneSelectString injectionTime:WKUserScriptInjectionTimeAtDocumentEnd forMainFrameOnly:true];
    [wkConfig.userContentController addUserScript:noneSelectScript];
  }


Daddy Apple, please deal with this problem as soon as possible.
I have met same crash @huangturen2015,The stack are same. Does you have any fixed idea or reproduce means?
Same issue has occurred on our app, hope apple can fix it asap.
I have *not* been able to reproduce this on iOS 14 beta 3.
Can anyone confirm?
Thanks.
WkWebView Crashed on iOS14
 
 
Q