-
-
Notifications
You must be signed in to change notification settings - Fork 530
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
NullPointerException - LifecycleRegistry.removeObserver #1776
Comments
Hey! 👋 The issue doesn't seem to contain a minimal reproduction. Could you provide a snack or a link to a GitHub repository under your username that reproduces the problem? |
We can't even repro in our own app. It seems to be happening intermittently for some users only. |
I have this issue too, |
@sregg do you find any solutions? |
I'm gonna do a patch using patch-package today and see if that fixes it. |
|
May I have your patch? |
That was my plan for the patch |
Please share your patch result. |
Here's the patch: diff --git a/node_modules/react-native-screens/android/src/main/java/com/swmansion/rnscreens/LifecycleHelper.kt b/node_modules/react-native-screens/android/src/main/java/com/swmansion/rnscreens/LifecycleHelper.kt
index 41bfc80..5925472 100644
--- a/node_modules/react-native-screens/android/src/main/java/com/swmansion/rnscreens/LifecycleHelper.kt
+++ b/node_modules/react-native-screens/android/src/main/java/com/swmansion/rnscreens/LifecycleHelper.kt
@@ -43,6 +43,9 @@ class LifecycleHelper {
}
fun <T> unregister(view: T) where T : View, T : LifecycleObserver? {
+ if (view == null) {
+ return
+ }
mViewToLifecycleMap[view]?.removeObserver(view)
} |
@sregg I have this issue in sentry again. |
Even after that patch? |
Yeap. |
I have the same problem, but my react-native-screen version (3.20.0) doesn't contain the file you patched anymore or any other removeObserver call. There are removeObserver calls in other dependencies though. Mostly expo libraries in my case. I tried to patch one suspicious file, that does some compatibility stuff between Expo and React Native Screens, but it didn't work. |
@matous94 Can you reproduce this issue on a real device? |
It actually happens only on real device, in preview/production build, which makes testing quite tedious, since it's not happening in Expo dev-client. Also I just noticed the "Steps to reproduce" for this issue are different from mine. For me it happens when I call Updates.reloadAsync. I use it to reload app at logout, expired session token etc. But I think it's quite possible that the underlying issue is the same/similiar. |
@sregg RNScreen 3.2 doesn't contain the file that we patched yesterday. |
Does that mean it's fixed? |
Nope, I published on production with version 3.2.0 and i have same issues in sentry. |
I just got the following, more detailed error message in dev in terminal after hot-reloading. I will look into it later, but it seems the error might be coming from sentry package? Possibly the same issue
|
Thanks @matous94 |
I also have sdk 33. how can I solve this problem |
Description
We're getting a few NPE in our app in prod.
Searching for
removeObserver
in our entire project returns only this line inreact-native-screens
:react-native-screens/android/src/main/java/com/swmansion/rnscreens/LifecycleHelper.kt
Line 46 in 6272e44
Steps to reproduce
We can't seem to reproduce.
It seems to be happening only on Android. Maybe on app start (we don't see any breadcrumbs in Sentry).
Snack or a link to a repository
Couldn't repro in snack.
Screens version
3.18.2
React Native version
0.71.8
Platforms
Android
JavaScript runtime
Hermes
Workflow
React Native (without Expo)
Architecture
Paper (Old Architecture)
Build type
Release mode
Device
Real device
Device model
Redmi Note 9 Pro Max - Android 11
Acknowledgements
Yes
The text was updated successfully, but these errors were encountered: