react-native-reanimated: Fatal Exception: java.lang.NullPointerException (AnimationsManager.java) v2.3.0-beta.2

Description

Stack trace from Crashlytics, Android 11, Redmi Note 9 Pro:

Fatal Exception: java.lang.NullPointerException: Attempt to invoke virtual method 'android.view.WindowManager android.app.Activity.getWindowManager()' on a null object reference
       at com.swmansion.reanimated.layoutReanimation.AnimationsManager.prepareDataForAnimationWorklet(AnimationsManager.java:340)
       at com.swmansion.reanimated.layoutReanimation.AnimationsManager.onViewRemoval(AnimationsManager.java:116)
       at com.swmansion.reanimated.layoutReanimation.ReaLayoutAnimator.dfs(ReanimatedNativeHierarchyManager.java:119)
       at com.swmansion.reanimated.layoutReanimation.ReaLayoutAnimator.dfs(ReanimatedNativeHierarchyManager.java:127)
       at com.swmansion.reanimated.layoutReanimation.ReaLayoutAnimator.dfs(ReanimatedNativeHierarchyManager.java:127)
       at com.swmansion.reanimated.layoutReanimation.ReaLayoutAnimator.dfs(ReanimatedNativeHierarchyManager.java:127)
       at com.swmansion.reanimated.layoutReanimation.ReaLayoutAnimator.dfs(ReanimatedNativeHierarchyManager.java:127)
       at com.swmansion.reanimated.layoutReanimation.ReaLayoutAnimator.dfs(ReanimatedNativeHierarchyManager.java:127)
       at com.swmansion.reanimated.layoutReanimation.ReaLayoutAnimator.dfs(ReanimatedNativeHierarchyManager.java:127)
       at com.swmansion.reanimated.layoutReanimation.ReaLayoutAnimator.deleteView(ReanimatedNativeHierarchyManager.java:106)
       at com.facebook.react.uimanager.NativeViewHierarchyManager.manageChildren(NativeViewHierarchyManager.java:482)
       at com.swmansion.reanimated.layoutReanimation.ReanimatedNativeHierarchyManager.manageChildren(ReanimatedNativeHierarchyManager.java:230)
       at com.facebook.react.uimanager.UIViewOperationQueue$ManageChildrenOperation.execute(UIViewOperationQueue.java:217)
       at com.facebook.react.uimanager.UIViewOperationQueue$1.run(UIViewOperationQueue.java:914)
       at com.facebook.react.uimanager.UIViewOperationQueue.flushPendingBatches(UIViewOperationQueue.java:1025)
       at com.facebook.react.uimanager.UIViewOperationQueue.access$2600(UIViewOperationQueue.java:47)
       at com.facebook.react.uimanager.UIViewOperationQueue$2.runGuarded(UIViewOperationQueue.java:983)
       at com.facebook.react.bridge.GuardedRunnable.run(GuardedRunnable.java:31)
       at android.os.Handler.handleCallback(Handler.java:938)
       at android.os.Handler.dispatchMessage(Handler.java:99)
       at android.os.Looper.loop(Looper.java:236)
       at android.app.ActivityThread.main(ActivityThread.java:7861)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:600)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:967)

Package versions

  • React Native: 0.65.1
  • React Native Reanimated: 2.3.0-beta.2

Affected platforms

  • Android

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 2
  • Comments: 24 (5 by maintainers)

Most upvoted comments

@kkafar Just to share some insights regarding this crash:

  1. At Mixcloud we’ve recently introduced reanimated 2, and we made use of the latest SHA in master

  2. We have followed/confirmed the steps regarding the installation and they are correct.

  3. We still see the crashes as you can see in this screen-capture from firebase: image

I’d like to kindly ask if you could reopen this issue as it seems that it persists despite https://github.com/software-mansion/react-native-reanimated/pull/2982

And if there’s anything we can do to help, please let us know

Edit: @piaskowyk Just tagging you as well so you know about it. Thanks again

@kkafar are there any plans to release a version with the merged fix soon? It’s causing quite a few crashes in my app and I’d prefer to pull in an explicitly released version.

The same

Is there a reason a patch with this change hasn’t been released yet @kkafar? It’s been almost three weeks since a fix was merged and we are definitely seeing crashes in our app related to this and we can’t get a build working with a git sha.

changes from the docs are applied. It doesn’t seem to always crash. I can reliably reproduce this on our CI but not on local devices so far, I’ll keep investigating @amitkumar3968

also seeing this crash for react-native version 0.66.0

@nickcruz Yes it seems fixed for us at least 🙏

I won’t give you specifics, but release is coming within days.

However as was mentioned above you can build reanimated from source, which is extremely easy right now.

@kkafar I will update the project and look at the result, then give you feedback

i am also facing issues with this version, not crash. Seems like we have to switch to latest version or move to another library. WIP

changes from the docs are applied. It doesn’t seem to always crash. I can reliably reproduce this on our CI but not on local devices so far, I’ll keep investigating @amitkumar3968

Yeah, no issue was in dev, only after the release build. I can confirm that crashes happening sometimes.

@amitkumar3968 Hermes enabled and here is my MainApplication:

@Override
        protected JSIModulePackage getJSIModulePackage() {
            return new JSIModulePackage() {
                @Override
                public List<JSIModuleSpec> getJSIModules(
                        final ReactApplicationContext reactApplicationContext,
                        final JavaScriptContextHolder jsContext
                ) {
                    List<JSIModuleSpec> modules = Arrays.asList();

                    modules.addAll(new WatermelonDBJSIPackage().getJSIModules(reactApplicationContext, jsContext));
                    modules.addAll(new ReanimatedJSIModulePackage().getJSIModules(reactApplicationContext, jsContext));
                    // ⬅️ add more JSI packages here by conventions above

                    return modules;
                }
            };
        }
      };

try doing changes as per link https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/installation/#android enablehermes editing Mainapplication.java