Closed gtokman closed 1 year ago
@gtokman I guess it happens on latest version of the library, right?
As an intermediate solution I can suggest to revert back to 1.4.4
In a meantime I'll try to find a solution and provide a fix đ
@kirillzyusko yes, on the latest version of the library and 2.14 for reanimated.
@gtokman could you please also tell more about how do you use the library and when this exception occurs?
How many KeyboardProviders
do you have? When this exception occurs (I guess when keyboard becomes hidden, but how long do you need to show/hide keyboard before you meet an exception? Maybe you see the exception when you switch between different type of keyboards (like number/alphabetical keyboard)?
@gtokman also, if you are able to test, could you please try to change:
keyboardView?.removeObserver(self, forKeyPath: "center", context: nil)
to
_keyboardView?.removeObserver(self, forKeyPath: "center", context: nil)
Just add _
to keyboardView
variable.
I have an assumption, that when we refer to keyboardView
it may re-run a process of finding a view and return a new instance without a listener đ¤ˇââď¸
@gtokman could you please check whether https://github.com/kirillzyusko/react-native-keyboard-controller/pull/157 fixes the problem?
@gtokman could you please check whether #157 fixes the problem?
@kirillzyusko I had the same issue and applying the patch from your PR fixes the crash for me. Thank you đ
Awesome @cgav Glad to know the fix is actually working! I'm going to merge this PR within this week and prepare a new release, since it's quite impactful change đ
FYI I'm also having this issue. I'm just using the KeyboardProvider in my App.tsx, and then in one place in my app:
React.useEffect(() => {
const show = KeyboardEvents.addListener('keyboardWillShow', () => {
bottomSheetRef.current?.expand();
});
return () => {
show.remove();
};
}, []);
The thing is that I can't reproduce this myself but Sentry has reported over 2.5k users experiencing this. What's weird to me about that 2.5k number is that the feature where the above code is, isn't much used. Could it be that the crash occurs when just applying the KeyboardProvider?
Hi @gunnartorfis
Yes, the issue will occur when you've wrapped app into KeyboardProvider
(underhood it'll render KeyboardControllerView
which setup all listeners and etc.).
@gunnartorfis could you please try to apply patch from https://github.com/kirillzyusko/react-native-keyboard-controller/pull/157 and see whether the amount of errors will be decreased?
Hi @gunnartorfis
Yes, the issue will occur when you've wrapped app into
KeyboardProvider
(underhood it'll renderKeyboardControllerView
which setup all listeners and etc.).@gunnartorfis could you please try to apply patch from #157 and see whether the amount of errors will be decreased?
I see, thanks. Since I'm unable to reproduce the issue myself I don't want to release the patch to production until it has been released. If you have any ideas on how I might reproduce this myself then I'd be happy to. It seems to be hitting quite the range of iOS versions, etc - I'm on 16.3 myself.
@gunnartorfis that's the problem that I don't know how to reproduce this crash đ¤ˇââď¸ I can not reproduce the problem in example app and I don't have reproducible example.
I have only guesses, that the reference to the keyboard view is changing and I'm trying to remove an observer which doesn't exist anymore... I really hope this patch can fix everything - if not, then I'll be happy to continue investigation on how to resolve the problem. The new version of the library 1.5.4
will be published today.
@gunnartorfis since you are not using other functionality apart of keyboardWillShow
you can safely downgrade keyboard-controller
version to 1.4.4
- this version will not have crashes, since I'm not using KVO mechanism in this version.
@kirillzyusko Thanks for the info. I will downgrade for now and keep a close eye on this.
Feel free to tag me if there's anything I can do to help out.
GitHub automatically closed this issue since PR that had a reference to this issue was merged.
I've published 1.5.4
to npm-registry. Hopefully the issue is resolved, but in any case feel free to re-open this issue or feel free to create a new one.
I'm seeing this issue in bugsnag with 1.10.3
Here's the stack trace:
Hardware Model: iPhone14,5
Process: App
Identifier: com.app
Role: Foreground
OS Version: iOS 16.5
NSRangeException: Cannot remove an observer <KeyboardMovementObserver 0x283160310> for the key path "center" from <UIInputSetHostView 0x10b613c70> because it is not registered as an observer.
0 CoreFoundation +0x9cb0 ___exceptionPreprocess
1 libobjc.A.dylib +0x183cc _objc_exception_throw
2 Foundation +0x6621c -[NSObject(NSKeyValueObserverRegistration) _removeObserver:forProperty:]
3 Foundation +0x65f5c -[NSObject(NSKeyValueObserverRegistration) removeObserver:forKeyPath:]
4 Foundation +0x65e6c -[NSObject(NSKeyValueObserverRegistration) removeObserver:forKeyPath:context:]
5 App +0x571850 KeyboardMovementObserver.removeKVObserver() (KeyboardMovementObserver.swift:98:20)
6 App +0x572b50 @objc KeyboardMovementObserver.keyboardWillAppear(_:)
7 CoreFoundation +0x3758c ___CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__
8 CoreFoundation +0xdb824 ____CFXRegistrationPost_block_invoke
9 CoreFoundation +0xbe8b4 __CFXRegistrationPost
10 CoreFoundation +0x4baf8 __CFXNotificationPost
11 Foundation +0x5cd34 -[NSNotificationCenter postNotificationName:object:userInfo:]
12 UIKitCore +0xb7ed9c -[UIInputWindowController postNotificationName:userInfo:]
13 UIKitCore +0x39245c ___68-[UIInputWindowController postValidatedStartNotifications:withInfo:]_block_invoke
14 UIKitCore +0x3b2e28 -[UIInputWindowController postValidatedStartNotifications:withInfo:]
15 UIKitCore +0x314424 -[UIInputWindowController postStartNotifications:withInfo:]
16 UIKitCore +0xb7fad4 ___77-[UIInputWindowController moveFromPlacement:toPlacement:starting:completion:]_block_invoke_4
17 UIKitCore +0x3d8ad0 +[UIView(UIViewAnimationWithBlocksPrivate) _modifyAnimationsWithPreferredFrameRateRange:updateReason:animations:]
18 UIKitCore +0xcd2ac +[UIView _setupAnimationWithDuration:delay:view:options:factory:animations:start:animationStateGenerator:completion:]
19 UIKitCore +0x5538c0 +[UIView(UIViewAnimationWithBlocks) _animateWithDuration:delay:options:animations:start:completion:]
20 UIKitCore +0x2ce2b4 -[UIInputViewAnimationStyle launchAnimation:afterStarted:completion:forHost:fromCurrentPosition:]
21 UIKitCore +0x2ce174 -[_UIViewControllerKeyboardAnimationStyle _launchAnimation:afterStarted:completion:forHost:fromCurrentPosition:]
22 UIKitCore +0x2cde80 +[UIView(Animation) _performWithAnimation:]
23 UIKitCore +0x2cddc8 -[_UIViewControllerKeyboardAnimationStyle launchAnimation:afterStarted:completion:forHost:fromCurrentPosition:]
24 UIKitCore +0xb807d0 ___77-[UIInputWindowController moveFromPlacement:toPlacement:starting:completion:]_block_invoke.459
25 UIKitCore +0x36f4e4 -[UIInputWindowController chainPlacementsIfNecessaryFrom:toPlacement:transition:completion:]
26 UIKitCore +0x36ca9c -[UIInputWindowController moveFromPlacement:toPlacement:starting:completion:]
27 UIKitCore +0x36bc00 -[UIInputWindowController setInputViewSet:]
28 UIKitCore +0x36b638 -[UIInputWindowController performOperations:withAnimationStyle:]
29 UIKitCore +0x27b92c -[UIKeyboardSceneDelegate setKeyWindowSceneInputViews:animationStyle:]
30 UIKitCore +0x27ae20 -[UIKeyboardSceneDelegate setInputViews:animationStyle:]
31 UIKitCore +0x204678 -[UIKeyboardSceneDelegate setInputViews:animated:]
32 UIKitCore +0x20168c -[UIKeyboardSceneDelegate setInputViews:]
33 UIKitCore +0x8ea2e4 ___102-[UIKeyboardSceneDelegate _reloadInputViewsForKeyWindowSceneResponder:force:fromBecomeFirstResponder:]_block_invoke.329
34 UIKitCore +0x8e9d74 -[UIKeyboardSceneDelegate _reloadInputViewsForKeyWindowSceneResponder:force:fromBecomeFirstResponder:]
35 UIKitCore +0x8e8a30 -[UIKeyboardSceneDelegate _reloadInputViewsForResponder:force:fromBecomeFirstResponder:]
36 UIKitCore +0x27c8c0 -[UIResponder(UIResponderInputViewAdditions) reloadInputViews]
37 UIKitCore +0x21a44c -[UIResponder becomeFirstResponder]
38 UIKitCore +0xfdb73c ___99-[_UIRemoteViewController _serviceWantsKeyboardEventsWithPromotedFirstResponder:completionHandler:]_block_invoke
@bcgilliom can you please test 1.11.0 and if it's still reproducible, then open a new issue? đ
And maybe you can shed some light on additional aspects, such as how frequently it happens, how much users are affected (in percentage, like 0.02% or smth like that), and maybe when it happens (maybe user navigated from modal screen to non-modal or something else)?
@kirillzyusko it seems to be extremely rare - we had a few reports early on, so I wasn't sure at first. I'll bump the library to latest and report back đ Thanks for all of your help and work on this lib. It's been great!
Describe the bug
We have a crash that occurs on iOS when reading the reanimated keyboard height.
Code snippet
Repo for reproducing It's in our main application. I can't provided a project to reproduce at this time.
Expected behavior A clear and concise description of what you expected to happen.
Screenshots
Smartphone (please complete the following information):