react-native-reanimated icon indicating copy to clipboard operation
react-native-reanimated copied to clipboard

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

Open pronevich opened this issue 2 years ago • 22 comments

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

  • [x] Android

pronevich avatar Oct 07 '21 19:10 pronevich

Issue validator

The issue is invalid!

  • Section required but not found: expected behavior(for label 🐞 bug)
  • Section required but not found: actual behavior & steps to reproduce(for label 🐞 bug)

github-actions[bot] avatar Oct 07 '21 19:10 github-actions[bot]

The same

andybui090 avatar Oct 11 '21 15:10 andybui090

also seeing this crash for react-native version 0.66.0

michaelknoch avatar Oct 12 '21 09:10 michaelknoch

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

amitkumar3968 avatar Oct 12 '21 21:10 amitkumar3968

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

michaelknoch avatar Oct 12 '21 23:10 michaelknoch

good to know, its working on local device. for CI, please update if you fixed it.

amitkumar3968 avatar Oct 13 '21 08:10 amitkumar3968

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;
                }
            };
        }
      };

pronevich avatar Oct 13 '21 08:10 pronevich

1.please check your release crashlytics logs. 2. try removing watermelon in release build, just for testing, and returning only return new ReanimatedJSIModulePackage(); in Mainapplication.java as per link https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/installation/#android

amitkumar3968 avatar Oct 13 '21 09:10 amitkumar3968

I'm also having this issue in v2.3.0-beta.2, also seems to be happening at random

escobar5 avatar Oct 13 '21 15:10 escobar5

@amitkumar3968 looks like issue exists also in other projects without several jsi modules. Later I will try to return only reanimated module as per docs for the test.

pronevich avatar Oct 14 '21 14:10 pronevich

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

amitkumar3968 avatar Oct 19 '21 05:10 amitkumar3968

Hey @pronevich! Can you (or anyone) confirm this crash occurs on latest release version & reanimated is installed properly?

kkafar avatar Jan 28 '22 10:01 kkafar

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

pronevich avatar Jan 28 '22 11:01 pronevich

@kkafar I don't see this crash in Crashlytics, but after update to the stable version has risen this issue:

Fatal Exception: com.facebook.react.uimanager.IllegalViewOperationException: Trying to resolve view with tag 913 which doesn't exist
       at com.facebook.react.uimanager.NativeViewHierarchyManager.resolveView(NativeViewHierarchyManager.java:102)
       at com.facebook.react.uimanager.UIManagerModule.resolveView(UIManagerModule.java:964)
       at com.swmansion.reanimated.layoutReanimation.AnimationsManager.removeLeftovers(AnimationsManager.java:236)
       at com.swmansion.reanimated.layoutReanimation.AnimationsManager.lambda$scheduleCleaning$0$AnimationsManager(AnimationsManager.java:286)
       at com.swmansion.reanimated.layoutReanimation.-$$Lambda$AnimationsManager$wJRqdL09xrx99sALjL4PPWgrOyU.run(:4)
       at android.os.Handler.handleCallback(Handler.java:938)
       at android.os.Handler.dispatchMessage(Handler.java:99)
       at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:27)
       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)

pronevich avatar Feb 08 '22 08:02 pronevich

@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.

kinigitbyday avatar Feb 24 '22 18:02 kinigitbyday

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.

elGatoMantocko avatar Feb 28 '22 18:02 elGatoMantocko

@kinigitbyday and @elGatoMantocko you can always build with the latest from master by doing the following: https://docs.swmansion.com/react-native-reanimated/docs/2.2.0/installation/#using-main-branch-builds

You can then get a build working based on the sha that you want 👍

limaAniceto avatar Mar 16 '22 16:03 limaAniceto

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 avatar Mar 17 '22 13:03 kkafar

@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

limaAniceto avatar Mar 21 '22 10:03 limaAniceto

We are also seeing this issue in our crashlytics:

Screenshot 2022-05-26 at 08 12 43

RN: 0.67.3 reanimated: 2.4.1 react-navigation: 6.1.1

alexfoxy avatar May 26 '22 07:05 alexfoxy

We need to look at this again

piaskowyk avatar May 26 '22 12:05 piaskowyk

@alexfoxy are you still seeing that error? Maybe 2.8.0 fixed it for you? It includes this fix: https://github.com/software-mansion/react-native-reanimated/pull/3162

Which seems to be the NPE you're seeing

nickcruz avatar Jul 26 '22 01:07 nickcruz

Im still seeing this error, but some times.

image

image

image

RN: 0.66.3 reanimated: ^2.9.1

rokkoo avatar Oct 10 '22 08:10 rokkoo

@nickcruz Yes it seems fixed for us at least 🙏

alexfoxy avatar Dec 05 '22 08:12 alexfoxy