software-mansion / react-native-reanimated

React Native's Animated library reimplemented
https://docs.swmansion.com/react-native-reanimated/
MIT License
9.04k stars 1.31k forks source link

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

Closed pronevich closed 1 year ago

pronevich commented 3 years ago

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

Affected platforms

github-actions[bot] commented 3 years ago

Issue validator

The issue is invalid!

andybui090 commented 3 years ago

The same

michaelknoch commented 3 years ago

also seeing this crash for react-native version 0.66.0

amitkumar3968 commented 3 years ago

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

michaelknoch commented 3 years ago

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

amitkumar3968 commented 3 years ago

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

pronevich commented 3 years ago

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;
                }
            };
        }
      };
amitkumar3968 commented 3 years ago

1.please check your release crashlytics logs.

  1. 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
escobar5 commented 3 years ago

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

pronevich commented 3 years ago

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

amitkumar3968 commented 3 years ago

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

kkafar commented 2 years ago

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

pronevich commented 2 years ago

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

pronevich commented 2 years ago

@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)
kinigitbyday commented 2 years ago

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

elGatoMantocko commented 2 years ago

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.

limaAniceto commented 2 years ago

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

kkafar commented 2 years ago

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.

limaAniceto commented 2 years ago

@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

alexfoxy commented 2 years ago

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

piaskowyk commented 2 years ago

We need to look at this again

nickcruz commented 2 years ago

@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

rokkoo commented 2 years ago

Im still seeing this error, but some times.

image

image

image

RN: 0.66.3 reanimated: ^2.9.1

alexfoxy commented 1 year ago

@nickcruz Yes it seems fixed for us at least 🙏