-[UIThreadSafeNode canPerformAction:withSender:]:无法识别的选择器已发送到实例 [英] -[UIThreadSafeNode canPerformAction:withSender:]: unrecognized selector sent to instance

查看:106
本文介绍了-[UIThreadSafeNode canPerformAction:withSender:]:无法识别的选择器已发送到实例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在iOS应用中面临崩溃.

 致命异常:NSInvalidArgumentException0 CoreFoundation 0x1b9079c30 __exceptionPreprocess1个libobjc.A.dylib 0x1b8d940c8 objc_exception_throw2 CoreFoundation 0x1b8f77fc0-[NSOrderedSet initWithSet:copyItems:]3 CoreFoundation 0x1b907e3d4 ___转发___4 CoreFoundation 0x1b9080570 _CF_forwarding_prep_05 UIKitCore 0x1bcf33444-[UIKeyboardImpl deleteForwardAndNotify:]6 UIKitCore 0x1bcf39154 __57- [UIKeyboardImpl acceptPredictiveInput:executionContext:] _ block_invoke7 UIKitCore 0x1bcf5b0c8-[UIKeyboardTaskExecutionContext returnExecutionToParentWithInfo:]8 UIKitCore 0x1bcf366ec __100- [UIKeyboardImpl addWordTerminator:afterSpace:afterAcceptingCandidate:elapsedTime:executionContext:] _ block_invoke9 UIKitCore 0x1bcf5b0c8-[UIKeyboardTaskExecutionContext returnExecutionToParentWithInfo:]10 UIKitCore 0x1bcf2bdc0 __55- [UIKeyboardImpl handleKeyboardInput:executionContext:] _ block_invoke_211 UIKitCore 0x1bcf5cd70-[UIKeyboardTaskEntry执行:]12 UIKitCore 0x1bcf5b6d4-[UIKeyboardTaskQueue continueExecutionOnMainThread]13 libobjc.A.dylib 0x1b8d8faf0-[NSObject performSelector:withObject:]14 Foundation 0x1b946ec10 __NSThreadPerformPerform15 CoreFoundation 0x1b8ff5260 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__16 CoreFoundation 0x1b8ff51b4 __CFRunLoopDoSource017 CoreFoundation 0x1b8ff4920 __CFRunLoopDoSources018 CoreFoundation 0x1b8fef7ec __CFRunLoopRun19 CoreFoundation 0x1b8fef098 CFRunLoopRunSpecific20 GraphicsServices 0x1c3159534 GSEventRunModal21 UIKitCore 0x1bd10f7ac UIApplicationMain22 Haraj 0x102fc6058 main + 15(main.m:15)23 libdyld.dylib 0x1b8e6ef30< acted; 

到目前为止,已经报告了超过100次崩溃.仅在iOS 12和iOS 13中会发生这种情况.

我找不到这是怎么回事以及如何复制它.

堆栈跟踪不显示我的任何应用程序代码.

我已经在

I am facing this crash in my iOS app.

Fatal Exception: NSInvalidArgumentException
0  CoreFoundation                 0x1b9079c30 __exceptionPreprocess
1  libobjc.A.dylib                0x1b8d940c8 objc_exception_throw
2  CoreFoundation                 0x1b8f77fc0 -[NSOrderedSet initWithSet:copyItems:]
3  CoreFoundation                 0x1b907e3d4 ___forwarding___
4  CoreFoundation                 0x1b9080570 _CF_forwarding_prep_0
5  UIKitCore                      0x1bcf33444 -[UIKeyboardImpl deleteForwardAndNotify:]
6  UIKitCore                      0x1bcf39154 __57-[UIKeyboardImpl acceptPredictiveInput:executionContext:]_block_invoke
7  UIKitCore                      0x1bcf5b0c8 -[UIKeyboardTaskExecutionContext returnExecutionToParentWithInfo:]
8  UIKitCore                      0x1bcf366ec __100-[UIKeyboardImpl addWordTerminator:afterSpace:afterAcceptingCandidate:elapsedTime:executionContext:]_block_invoke
9  UIKitCore                      0x1bcf5b0c8 -[UIKeyboardTaskExecutionContext returnExecutionToParentWithInfo:]
10 UIKitCore                      0x1bcf2bdc0 __55-[UIKeyboardImpl handleKeyboardInput:executionContext:]_block_invoke_2
11 UIKitCore                      0x1bcf5cd70 -[UIKeyboardTaskEntry execute:]
12 UIKitCore                      0x1bcf5b6d4 -[UIKeyboardTaskQueue continueExecutionOnMainThread]
13 libobjc.A.dylib                0x1b8d8faf0 -[NSObject performSelector:withObject:]
14 Foundation                     0x1b946ec10 __NSThreadPerformPerform
15 CoreFoundation                 0x1b8ff5260 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__
16 CoreFoundation                 0x1b8ff51b4 __CFRunLoopDoSource0
17 CoreFoundation                 0x1b8ff4920 __CFRunLoopDoSources0
18 CoreFoundation                 0x1b8fef7ec __CFRunLoopRun
19 CoreFoundation                 0x1b8fef098 CFRunLoopRunSpecific
20 GraphicsServices               0x1c3159534 GSEventRunModal
21 UIKitCore                      0x1bd10f7ac UIApplicationMain
22 Haraj                          0x102fc6058 main + 15 (main.m:15)
23 libdyld.dylib                  0x1b8e6ef30 <redacted>

So far over a 100 crashes has been reported. This is happening only in iOS 12 and iOS 13.

I am not able to find how this is happening and how to reproduce it.

The stack trace does not show any of my app's code.

I have uploaded the full crash report here.

Any help would be highly appreciated.

解决方案

This seems to be a regression of an ancient bug related to "forward delete" on iOS text entry: http://www.openradar.me/15114422

I believe it has regressed because of the new "swipe to type" keyboard.

You have 2 options to fix:

  1. Upgrade your deprecated UIWebView to a WKWebView
  2. Hacky solution: insert the missing selector on UIThreadSafeNode at runtime.

Here's a code example of how to insert the missing selector:

BOOL canPerformAction(id withSender) {
    return false;
} 

- (void)viewDidLoad {
   [super viewDidLoad];

   Class class = NSClassFromString(@"UIThreadSafeNode");
   class_addMethod(class, @selector(canPerformAction:withSender:), (IMP)canPerformAction, "@@:");
}

You should probably put the method insertion somewhere that only loads once, like in the AppDelegate.

Here's the full example project if you need it: https://github.com/elliotfiske/UIWebView-TextEntry-CrashFix/tree/master

How to reproduce:

Create a text entry form in a UIWebView, type some words, then move the cursor to the exact END of a word in the middle of the sentence.

Then, choose any of the predictive text suggestions. See the bug in action here:

这篇关于-[UIThreadSafeNode canPerformAction:withSender:]:无法识别的选择器已发送到实例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆