-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Android crash / NullPointerException #2477
Comments
Please see the linked comment for the exact line of code - I highlighted it on the PR where it went in - #2437 The crash was observed using reanimated v2.3.0-beta.2 (just released) in combination with react-native 0.66.0-rc.4 as I was checking the release build that combo produced. I was able to reproduce it using my app (which is not terribly fancy) by setting minifyEnabled true, so it should be pretty easy to reproduce, but at the same time I think my analysis of the NullPointerException is pretty easy to follow? I can try to pull one of the examples here and set it up for repro if needed though |
It occurs to me that the reason this likely crashes on boot is that the first thing my app does is load up a react-navigation tab set which is thus transitively dependent on reanimated This example would serve but it's pretty stale on react-native + reanimated https://github.com/react-navigation/react-navigation/blob/fa45dde59b0c2e386280f00ad08393881539c16d/example/package.json#L31-L36 |
It also happened on me, i'm also using react nativagtion with bottom tab. Do you already found the solution ? |
I was able to get around this error by downgrading to v2.2.2 and building the aar for RN 0.66 from that tag. |
react-native-reanimated 2.3.0-beta (that is, from dev branch on 2021/09/30) "postinstall": "patch-package && cp patches/react-native-reanimated-66-hermes.aar node_modules/react-native-reanimated/android/", |
…imator (#2478) ## Description mPendingDeletionsForTag is only initialized in some constructor paths, in others it might be null, so we cannot always blindly dereference it Fixes #2477 ## Test code and steps to reproduce For me, I'm able to reproduce a crash here anytime minifyEnabled is true in my build (you can set it in debug, to check it), and it crashes on startup for me.
@mikehardy the zipped aar file cannot unzipped on my mac. See below Any change we get an updated beta soon instead? |
It's not actually a zip, sorry. It is literally just the .aar file with .zip added to it because GitHub will simply not allow you to attach an .aar (which is...technically a zip 😆 ) but it will allow a .zip. I'll amend my instructions. You can try |
With sincere apologies I realize the aar I packed up and attached above does not contain the actual class that I fixed in the related PR. Why is that? Because in order to really test the fix I removed those exact classes from the aar and worked on the java file in my own app's source tree. I got it working then of course forgot to put them back in the AAR I put here. So if anyone tried to use it before, you would have crashed on startup with a NoClassDefFoundError on ReanimatedNativeHierarchyManager. I've put the classes in their rightful home in the AAR here and I'm re-attaching it. I only noticed myself when I went to take my own fix and put it in another app and couldn't realize why it was crashing !?!. Apologies |
@mikehardy I'm still getting this issue with 2.3.1. Do I downgrade to 2.3.0-beta and apply the patch? |
This was fixed and released in the related PR. You may have a different problem, I would open a new ticket. You may also try react-native-clean-project |
I found what the issue was. The hardware acceleration requirement for reanimated doesn't play well with Flipper. While using Flipper to debug, it is fine, but when you quit Flipper while the debug version is running, it has an inadvertent crash. Is this a fixable issue? |
I would definitely open a separate ticket for that with related information (stack trace from adb logcat etc, versions in play, exact steps to reproduce). It is not related to this issue |
separately: wow, subtle interaction there, and I don't use flipper to debug, explains why it does not happen to me |
For some reason, in android release builds on my app (or debug builds if I configure minifyEnabled true for debug buildType) this crashes on this line (I carefully deobfuscated the stack trace, and it's definitely crashing here - no idea why minify triggers it when it's not the classic ClassNotFoundException or NoClassDef etc that proguard would normally throw)
And the relevant portion of
android/app/build/outputs/mapping/debug/mapping.txt
showing whath5.f.r
is:So it's in ReanimatedNativeHierarchyManager::manageChildren on line 218 - right where
mPendingDeletionsForTag
is dereferenced for a.get
with no null check.I believe that since mPendingDeletionsForTag is initialized to null, and only set to a valid HashMap in one of the constructors but not the other, I must be using the other constructor in my app.
Then when this line is hit, I get a null pointer exception.
I think this whole chunk could be wrapped in an
if (mPendingDeletionsForTag != null) { /* ... */ }
Originally posted by @mikehardy in #2437 (comment)
The text was updated successfully, but these errors were encountered: