Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash delegate #74

Closed
AlexisQapa opened this issue Jul 1, 2019 · 6 comments
Closed

Crash delegate #74

AlexisQapa opened this issue Jul 1, 2019 · 6 comments

Comments

@AlexisQapa
Copy link

AlexisQapa commented Jul 1, 2019

Prerequisites

  • [X ] Put an X between the brackets on this line if you have done all of the following:
    • read our Wiki;
    • read the entire Known issues section;
    • checked that my issue isn't already filled;
    • searched StackOverflow's input-mask tag for similar problems.

Describe the bug

I have a crash related to UITextView delegate. I'm not sure it's related to your library thought, I only use it with your library and the bug appeared in the same version I updated the library.

Here is a stack trace:

Fatal Exception: NSInvalidArgumentException
0 CoreFoundation 0x2329ca3a8 __exceptionPreprocess
1 libobjc.A.dylib 0x231bcfd00 objc_exception_throw
2 CoreFoundation 0x2328e29f8 -[NSOrderedSet initWithSet:copyItems:]
3 CoreFoundation 0x2329cfd54 forwarding
4 CoreFoundation 0x2329d1b50 _CF_forwarding_prep_0
5 UIKitCore 0x25ffdffc8 -[UITextView keyboardInputChangedSelection:]
6 UIKitCore 0x25ff518cc -[UITextInteractionAssistant(UITextInteractionAssistant_Internal) notifyKeyboardSelectionChanged]
7 UIKitCore 0x25ff3c54c -[UITextNonEditableInteraction oneFingerTapInUneditable:]
8 UIKitCore 0x25f8ac420 -[UIGestureRecognizerTarget _sendActionWithGestureRecognizer:]
9 UIKitCore 0x25f8b48e0 _UIGestureRecognizerSendTargetActions
10 UIKitCore 0x25f8b21dc _UIGestureRecognizerSendActions
11 UIKitCore 0x25f8b16b0 -[UIGestureRecognizer _updateGestureWithEvent:buttonEvent:]
12 UIKitCore 0x25f8a5474 _UIGestureEnvironmentUpdate
13 UIKitCore 0x25f8a4ba0 -[UIGestureEnvironment _deliverEvent:toGestureRecognizers:usingBlock:]
14 UIKitCore 0x25f8a4970 -[UIGestureEnvironment _updateForEvent:window:]
15 UIKitCore 0x25fcd7cac -[UIWindow sendEvent:]
16 UIKitCore 0x25fcb6f50 -[UIApplication sendEvent:]
17 UIKitCore 0x25fd82150 __dispatchPreprocessedEventFromEventQueue
18 UIKitCore 0x25fd8490c __handleEventQueueInternal
19 UIKitCore 0x25fd7d9c4 __handleHIDEventFetcherDrain
20 CoreFoundation 0x23295a444 CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION
21 CoreFoundation 0x23295a3c0 __CFRunLoopDoSource0
22 CoreFoundation 0x232959c7c __CFRunLoopDoSources0
23 CoreFoundation 0x232954950 __CFRunLoopRun
24 CoreFoundation 0x232954254 CFRunLoopRunSpecific
25 GraphicsServices 0x234b93d8c GSEventRunModal
26 UIKitCore 0x25fc9c4c0 UIApplicationMain

Steps to reproduce the behaviour:

The crash happens rarely. Tried every gesture or input on all my textview ^^ as the stack trace doesn't contain any ref to my code.

Platform information

  • OS version: 9.0+
  • Library version: 4.1.1+
  • Language: 5.0.1

Additional context
I use RxSwift/RxCocoa which can swizzle delegates thought each place I use this lib Rx is not used.

@taflanidi
Copy link
Collaborator

Hey @AlexisQapa,
I'll take a look. Though I've got to clarify, how have you concluded it has to do with the delegate?

@AlexisQapa
Copy link
Author

Indeed, over the stack I get :
Fatal Exception: NSInvalidArgumentException
-[RxCocoa.RxTextViewDelegateProxy keyboardInputChangedSelection:]: unrecognized selector sent to instance 0x280828620
So the delegate is indeed swizzled and it crash when forwarding the call to the delegate.

@taflanidi
Copy link
Collaborator

taflanidi commented Jul 1, 2019

Holy cow, that's why I don't like those «fancy» Rx things, too much uncontrolled magic under the hood.

keyboardInputChangedSelection: is not a delegate selector, it is a part of the actual UITextView instance.

Long story short, long time ago, the NextStep delegate pattern assumed you were supposed to implement your delegates in a way that they would process all unrecognised selectors from the main object. Imagine you've got a UITextField instance upon which you call a random [textField abc]; selector — in this case your textField.delegate instance is supposed to answer the abc selector properly (a redirection from the textField instance).

My guess is, it looks like RxCocoa while overriding (swizzling) the UITextView had forgotten to address the keyboardInputChangedSelection: call, thus their "delegate proxy" throws and crashes.

I'll need more time to dig into this just in case, so please keep this issue open, though I don't think it has anything to do with our library.

@AlexisQapa
Copy link
Author

Thanks for the input ! I'll open an issue on Rx repo.

@AlexisQapa
Copy link
Author

I found something in my code that might be the cause. I'll close this while investigating

@AlexisQapa
Copy link
Author

The bug was on my side.
For anyone getting here from Google, I was indirectly setting a textview as its own delegate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants