-[UIThreadSafeNode canPerformAction:withSender:]: unrecognized selector sent to instance - ios

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:
Upgrade your deprecated UIWebView to a WKWebView
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:

Related

iOS13 Crash -[UIWindowScene _enumerateWindowsIncludingInternalWindows:onlyVisibleWindows:asCopy:stopped:withBlock:]?

Since iOS 13.0 was released, I've been seeing a lot of occurrencies of this crash in our app:
Fatal Exception: NSRangeException
0 CoreFoundation 0x1846cf278 __exceptionPreprocess
1 libobjc.A.dylib 0x1843f80a4 objc_exception_throw
2 Foundation 0x184998480 -[NSConcretePointerArray dealloc]
3 UIKitCore 0x1888da3b8 -[UIWindowScene _enumerateWindowsIncludingInternalWindows:onlyVisibleWindows:asCopy:stopped:withBlock:]
4 UIKitCore 0x1888d9f74 -[UIWindowScene _topVisibleWindowPassingTest:]
5 UIKitCore 0x1886fc4c4 +[UIWindow _hitTestToPoint:forEvent:windowServerHitTestWindow:]
6 UIKitCore 0x1886fc854 -[UIWindow _targetWindowForPathIndex:atPoint:forEvent:windowServerHitTestWindow:]
7 UIKitCore 0x18873c080 ____updateTouchesWithDigitizerEventAndDetermineIfShouldSend_block_invoke.52
8 UIKitCore 0x18874b738 _UIEventHIDEnumerateChildren
9 UIKitCore 0x18873f8d0 __dispatchPreprocessedEventFromEventQueue
10 UIKitCore 0x188742dc4 __handleEventQueueInternal
11 UIKitCore 0x18873bc38 __handleHIDEventFetcherDrain
12 CoreFoundation 0x18464d090 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__
13 CoreFoundation 0x18464cfe8 __CFRunLoopDoSource0
14 CoreFoundation 0x18464c780 __CFRunLoopDoSources0
15 CoreFoundation 0x1846478cc __CFRunLoopRun
16 CoreFoundation 0x18464716c CFRunLoopRunSpecific
17 GraphicsServices 0x18e47f328 GSEventRunModal
18 UIKitCore 0x1886b1d0c UIApplicationMain
19 MyApp 0x100d3ba64 main + 18 (main.swift:18)
20 libdyld.dylib 0x1844d2424 start
It only happens in iOS 13.0.0 (17A577)
We don't have much context on what steps are causing this, all we have at the moment is that stack trace.
Is anybody else experiencing something similar?
Any ideas on what might be causing this?
Have strong reference to UIWindow which you created
Use makeKeyAndVisible instead of setting window.hidden = false

-[_NSObserverList setCursorPosition:]

I am getting #560 NSInvalidArgumentException error as shown below;
-[_NSObserverList setCursorPosition:]: unrecognized selector sent to instance 0x1702a6ea0
CoreFoundation ___exceptionPreprocess
Fatal Exception: NSInvalidArgumentException
0 CoreFoundation 0x1854f21c0 __exceptionPreprocess
1 libobjc.A.dylib 0x183f2c55c objc_exception_throw
2 CoreFoundation 0x1854f9278 __methodDescriptionForSelector
3 CoreFoundation 0x1854f6278 ___forwarding___
4 CoreFoundation 0x1853f059c _CF_forwarding_prep_0
5 UIKit 0x18b830418 -[_UIKeyboardTextSelectionController selectTextWithGranularity:atPoint:executionContext:]
6 UIKit 0x18b8304b0 -[_UIKeyboardTextSelectionController selectTextWithGranularity:atPoint:completionHandler:]
7 UIKit 0x18b895928 -[_UIKeyboardBasedNonEditableTextSelectionGestureController oneFingerForcePan:]
8 UIKit 0x18b91b59c -[UIGestureRecognizerTarget _sendActionWithGestureRecognizer:]
9 UIKit 0x18b91eca4 _UIGestureRecognizerSendTargetActions
10 UIKit 0x18b4e02e8 _UIGestureRecognizerSendActions
11 UIKit 0x18b37e828 -[UIGestureRecognizer _updateGestureWithEvent:buttonEvent:]
12 UIKit 0x18b90ece8 _UIGestureEnvironmentUpdate
13 CoreFoundation 0x18549f7dc __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__
14 CoreFoundation 0x18549d40c __CFRunLoopDoObservers
15 CoreFoundation 0x18549d89c __CFRunLoopRun
16 CoreFoundation 0x1853cc048 CFRunLoopRunSpecific
17 GraphicsServices 0x186e52198 GSEventRunModal
18 UIKit 0x18b3b82fc -[UIApplication _run]
19 UIKit 0x18b3b3034 UIApplicationMain
20 MyAppName 0x100050054 main (main.m:16)
21 libdispatch.dylib 0x1843b05b8 (Missing)
Can anyone please suggest me what can be the issue?
This kind of NSInvalidArgumentException, especially because it's on a private class, is probably due to a Zombie object. You are sending a message "setCursorPosition:" to an object that no longer exist, but another one is in it's place. In this case "_NSObserverList".
Try running with the "Zombie Objects" diagnostics objects to trace down which is the object that should receive that message but was gone. That option keeps the objects in memory when they are released, but marked as zombies.

iOS Exception Backtrace - App entry not symbolicating

I have received the below exception backtrace from Apple for an app I had submitted to the app store. I have symbolicated the log but my app's entry has not symbolicated. Any idea what I can do to achieve that? Please see Entry # 14 below which provides more detail. Any help would be much appreciated
Last Exception Backtrace:
0 CoreFoundation 0x1810cadb0 __exceptionPreprocess + 124
1 libobjc.A.dylib 0x18072ff80 objc_exception_throw + 56
2 UIKit 0x186b6d268 -[UIPopoverPresentationController presentationTransitionWillBegin] + 2884
3 UIKit 0x186581fb0 __71-[UIPresentationController _initViewHierarchyForPresentationSuperview:]_block_invoke + 1640
4 UIKit 0x1865800c8 __56-[UIPresentationController runTransitionForCurrentState]_block_invoke + 332
5 UIKit 0x1864d30c8 _runAfterCACommitDeferredBlocks + 292
6 UIKit 0x1864e0a80 _cleanUpAfterCAFlushAndRunDeferredBlocks + 92
7 UIKit 0x1862125a4 _afterCACommitHandler + 96
8 CoreFoundation 0x181080728 _CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 32
9 CoreFoundation 0x18107e4cc __CFRunLoopDoObservers + 372
10 CoreFoundation 0x18107e8fc __CFRunLoopRun + 928
11 CoreFoundation 0x180fa8c50 CFRunLoopRunSpecific + 384
12 GraphicsServices 0x182890088 GSEventRunModal + 180
13 UIKit 0x18628a088 UIApplicationMain + 204
14 MyApp 0x1000fb144 0x1000e4000 + 94532
15 libdyld.dylib 0x180b468b8 start + 4
Finally solved the problem. I was invoking UIAlertController in my code to present an action sheet with various options. To cater to devices that don't have a camera, I had added a conditional statement to directly present an ImagePicker instead of an action sheet.
iPAD testing was carried out only on the simulator which doesn't have a camera, thus directly invoking the ImagePicker. When he Conditional statement was removed, it tried presenting the Action Sheet through a PopoverPresentationController and crashed - as is evident in statement 2 of the Exception Backtrace.
I subsequently added the following code to fix the oversight:
if let popOver = optionMenu.popoverPresentationController {
popOver.sourceRect = sender.bounds
popOver.sourceView = sender
}

[UIThreadSafeNode createPeripheral]: unrecognized selector sent to instance

I tried to search about createPeripheral and i had no luck finding any information about it. Is there anyone here who had the same crash as this?
[UIThreadSafeNode createPeripheral]: unrecognized selector sent to instance
Which class does createPeripheral belong to?
How do you handle this crash?
note: there's not much information in the crash log
stackTrace =
(
0 CoreFoundation 0x31dcd2bb <redacted> + 186
1 libobjc.A.dylib 0x39a7297f objc_exception_throw + 30
2 CoreFoundation 0x31dd0e07 <redacted> + 170
3 CoreFoundation 0x31dcf531 <redacted> + 392
4 CoreFoundation 0x31d26f68 _CF_forwarding_prep_0 + 24
5 UIKit 0x33d4bf99 <redacted> + 52
6 UIKit 0x33bda80f <redacted> + 38
7 UIKit 0x33bda431 <redacted> + 404
8 UIKit 0x33f1ad19 <redacted> + 236
9 libdispatch.dylib 0x39e98621 <redacted> + 80
9 libdispatch.dylib 0x39e98621 <redacted> + 80
10 libdispatch.dylib 0x39e894b7 <redacted> + 22
11 libdispatch.dylib 0x39e8adcb <redacted> + 226
12 CoreFoundation 0x31da0f3b <redacted> + 1290
13 CoreFoundation 0x31d13ebd CFRunLoopRunSpecific + 356
14 CoreFoundation 0x31d13d49 CFRunLoopRunInMode + 104
15 GraphicsServices 0x358d72eb GSEventRunModal + 74
16 UIKit 0x33c29301 UIApplicationMain + 1120
...
);
Apologies for adding to an old post, but I do have a strong reproduction case for this bug. Open any software keyboard on the iPhone6+ (or iPhone6+ simulator) in a WebView. Put something in the paste-buffer, then click the paste button.
I haven't solved it yet, but I thought this might help if anyone is lost in google for this bug.
I've just got a similar crash report.
There is UIWebBrowserView in the call stack. Maybe it is a bug in it.
Our application uses UIWebView to show a simple html page, and I receive random crashes in WebView regulary. I have no idea what to do with it.
In my case this error occured when I tried to customize -inputaccessoryview on contenteditable div.
I believe createPeripheral has something to deal with Keyboard display as
webView.keyboardDisplayRequiresUserAction = NO;
solved this crash for me.

Displaying a new View in IOS

I am trying to display a view that contains details of the user's account. Being fairly new to iOS development, the following code is what should work (based the docs and searches). Yet, the application crashes and I get a an error stating unrecognized selector:
2012-03-13 16:32:25.616 UrbanAgendaApp[4993:207] Displaying profile view
2012-03-13 16:32:25.635 UrbanAgendaApp[4993:207] -[UAFirstViewController presentViewController:animated:completion:]: unrecognized selector sent to instance 0x4b45240
2012-03-13 16:32:25.674 UrbanAgendaApp[4993:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UAFirstViewController presentViewController:animated:completion:]: unrecognized selector sent to instance 0x4b45240'
*** Call stack at first throw:
(
0 CoreFoundation 0x00fbabe9 __exceptionPreprocess + 185
1 libobjc.A.dylib 0x0110f5c2 objc_exception_throw + 47
2 CoreFoundation 0x00fbc6fb -[NSObject(NSObject) doesNotRecognizeSelector:] + 187
3 CoreFoundation 0x00f2c366 ___forwarding___ + 966
4 CoreFoundation 0x00f2bf22 _CF_forwarding_prep_0 + 50
5 UrbanAgendaApp 0x00002308 -[UAFirstViewController showProfileView] + 168
6 UrbanAgendaApp 0x00002254 -[UAFirstViewController myUaBtnTouch:] + 52
7 UIKit 0x00014a6e -[UIApplication sendAction:to:from:forEvent:] + 119
8 UIKit 0x000a31b5 -[UIControl sendAction:to:forEvent:] + 67
9 UIKit 0x000a5647 -[UIControl(Internal) _sendActionsForEvents:withEvent:] + 527
10 UIKit 0x000a41f4 -[UIControl touchesEnded:withEvent:] + 458
11 UIKit 0x000390d1 -[UIWindow _sendTouchesForEvent:] + 567
12 UIKit 0x0001a37a -[UIApplication sendEvent:] + 447
13 UIKit 0x0001f732 _UIApplicationHandleEvent + 7576
14 GraphicsServices 0x00cbea36 PurpleEventCallback + 1550
15 CoreFoundation 0x00f9c064 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 52
16 CoreFoundation 0x00efc6f7 __CFRunLoopDoSource1 + 215
17 CoreFoundation 0x00ef9983 __CFRunLoopRun + 979
18 CoreFoundation 0x00ef9240 CFRunLoopRunSpecific + 208
19 CoreFoundation 0x00ef9161 CFRunLoopRunInMode + 97
20 GraphicsServices 0x00cbd268 GSEventRunModal + 217
21 GraphicsServices 0x00cbd32d GSEventRun + 115
22 UIKit 0x0002342e UIApplicationMain + 1160
23 UrbanAgendaApp 0x00001c2a main + 170
24 UrbanAgendaApp 0x00001b75 start + 53
25 ??? 0x00000001 0x0 + 1
)
terminate called after throwing an instance of 'NSException'
The method where this occurs is in a method in FirstViewController, which gets called as a result of a touch up event inside a button:
-(void)showProfileView {
NSLog( #"%#", #"Displaying profile view" ); // ***
UAProfileView *profileView = [[UAProfileView alloc] init];
[self presentViewController:profileView animated:TRUE completion:0];
}
This UAProfielView is a subclass of UIViewController and was was created along with an appropriate .xib file.
So the question is, how do I display this new view in my iPhone application? Using a storyboard is not an option because I have to support iOS 4.0.
The documentation for presentViewController:animated:completion: states that it is only supported on iOS 5.0 and up. You mentioned support for iOS 4.0.
Try presentModalViewController:animated: instead. Alternatively, use a nagivationController and do pushViewController:animated:
#Mike, make sure you connected the nib to the file's owner.
Presumably, the base class of UAFirstViewController is also UIViewController? Are you getting any warnings when you build?
I would personally use completion:nil, but I don't think that will make a difference.
So, if you are getting no warnings, then turn zombies on and see if you are dealing with a dead object. Instructions are here
How to enable NSZombie in Xcode?
Run the program and see if you get a zombie warning in the console. If that's the case, then the memory management is wrong.
If all of that is ok, post the code where you call showProfileView.

Resources