wxik / react-native-rich-editor

Lightweight React Native (JavaScript, H5) rich text editor
https://wxik.github.io/react-native-rich-editor/web
MIT License
792 stars 303 forks source link

Sporadic Crash on iOS #188

Open marcoizzo opened 3 years ago

marcoizzo commented 3 years ago

Hello,

thanks for this package, very useful! I'm facing crashes on iOS app in production, attached stack trace from firebase crashlytics and screen

Schermata 2021-07-01 alle 09 49 10

Arresto anomalo: com.apple.main-thread 
EXC_BAD_ACCESS KERN_INVALID_ADDRESS 0x00000009d5bfa200

Crashed: com.apple.main-thread
0  libobjc.A.dylib                0x183bd891c objc_msgSend + 28
1  <App_Name>                     0x100d58510 -[_SwizzleHelperWK inputAccessoryView] + 39 (RNCWebView.m:39)
2  UIKit                          0x18e783a74 -[UIPeripheralHost(UIKitInternal) _inputViewsForResponder:withAutomaticKeyboard:] + 1044
3  UIKit                          0x18e622080 -[UIPeripheralHost(UIKitInternal) _reloadInputViewsForResponder:] + 1016
4  UIKit                          0x18e7832b4 -[UIResponder(UIResponderInputViewAdditions) reloadInputViews] + 80
5  UIKit                          0x18e6c4ab4 -[UIResponder becomeFirstResponder] + 836
6  UIKit                          0x18e6c4ed0 -[UIView(Hierarchy) becomeFirstResponder] + 156
7  WebKit                         0x1946cbb58 -[WKContentView(WKInteraction) becomeFirstResponderForWebView] + 104
8  WebKit                         0x1947289cc -[WKWebView becomeFirstResponder] + 140
9  WebKit                         0x1946cf0c8 -[WKContentView(WKInteraction) _singleTapCommited:] + 112
10 UIKit                          0x18e7f96e8 -[UIGestureRecognizerTarget _sendActionWithGestureRecognizer:] + 64
11 UIKit                          0x18ed663b4 _UIGestureRecognizerSendTargetActions + 124
12 UIKit                          0x18e95be38 _UIGestureRecognizerSendActions + 320
13 UIKit                          0x18e7f8740 -[UIGestureRecognizer _updateGestureWithEvent:buttonEvent:] + 764
14 UIKit                          0x18ed57bd4 _UIGestureEnvironmentUpdate + 1096
15 UIKit                          0x18e7f24d8 -[UIGestureEnvironment _deliverEvent:toGestureRecognizers:usingBlock:] + 404
16 UIKit                          0x18e7f2010 -[UIGestureEnvironment _updateGesturesForEvent:window:] + 276
17 UIKit                          0x18e7f1874 -[UIWindow sendEvent:] + 3132
18 UIKit                          0x18e7f01d0 -[UIApplication sendEvent:] + 340
19 UIKit                          0x18efd1d1c __dispatchPreprocessedEventFromEventQueue + 2340
20 UIKit                          0x18efd42c8 __handleEventQueueInternal + 4744
21 UIKit                          0x18efcd368 __handleHIDEventFetcherDrain + 152
22 CoreFoundation                 0x1849b3404 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 24
23 CoreFoundation                 0x1849b2c2c __CFRunLoopDoSources0 + 276
24 CoreFoundation                 0x1849b079c __CFRunLoopRun + 1204
25 CoreFoundation                 0x1848d0da8 CFRunLoopRunSpecific + 552
26 GraphicsServices               0x1868b6020 GSEventRunModal + 100
27 UIKit                          0x18e8f0758 UIApplicationMain + 236
28 <App_Name>                     0x1006e0b84 main + 14 (main.m:14)
29 libdyld.dylib                  0x184361fc0 start + 4

Any idea on how to fix? Thanks

marcoizzo commented 3 years ago

After more investigation, the issues seems to be systematic on iOS 11

marcoizzo commented 3 years ago

Workaround is to add return nil; on top of the inputAccessoryView inside RNCWebView.m file of react-native-webview package but honestly I do not know what is the impact... I use this package only for the editor and seems work..

#if !TARGET_OS_OSX
// runtime trick to remove WKWebView keyboard default toolbar
// see: http://stackoverflow.com/questions/19033292/ios-7-uiwebview-keyboard-issue/19042279#19042279
@interface _SwizzleHelperWK : UIView
@property (nonatomic, copy) WKWebView *webView;
@end
@implementation _SwizzleHelperWK
-(id)inputAccessoryView
{

    return nil; // <-- Add this here

    if (_webView == nil) {
        return nil;
    }

    if ([_webView respondsToSelector:@selector(inputAssistantItem)]) {
        UITextInputAssistantItem *inputAssistantItem = [_webView inputAssistantItem];
        inputAssistantItem.leadingBarButtonGroups = @[];
        inputAssistantItem.trailingBarButtonGroups = @[];
    }
    return nil;
}
@end
#endif // !TARGET_OS_OSX