Skip to content
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

fix: android layout reanimation null pointer exception (2959) #3162

Conversation

jacobarvidsson
Copy link
Contributor

Description

ReactApplicationContext.getCurentContext sometimes return null. This causes a crash (NullPointerException) in reanimated due to not checking if context exists. As per react native's examples, we can only measure device metrics when current activity is not null (https://github.com/facebook/react-native/blob/8bd3edec88148d0ab1f225d2119435681fbbba33/ReactCommon/react/nativemodule/samples/platform/android/SampleTurboModule.java#L56)

Fixes #2959.

Changes

Check if current activity is not null before measuring the device.

Copy link
Member

@piaskowyk piaskowyk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everything is ok 👌 Thanks for the help! ❤️

@piaskowyk piaskowyk merged commit e039995 into software-mansion:main Apr 11, 2022
fluiddot pushed a commit to wordpress-mobile/react-native-reanimated that referenced this pull request May 3, 2022
…re-mansion#3162)

## Description
ReactApplicationContext.getCurentContext sometimes return null. This causes a crash (NullPointerException) in reanimated due to not checking if context exists. As per react native's examples, we can only measure device metrics when current activity is not null (https://github.com/facebook/react-native/blob/8bd3edec88148d0ab1f225d2119435681fbbba33/ReactCommon/react/nativemodule/samples/platform/android/SampleTurboModule.java#L56)

Fixes software-mansion#2959.

## Changes

Check if current activity is not null before measuring the device.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

com.swmansion.reanimated.layoutReanimation.AnimationsManager.prepareDataForAnimationWorklet
2 participants