-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Fix Android crash when worklet throws error #3558
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
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ade7e9d to
8a51e6a
Compare
e00480f to
b3afa8b
Compare
piaskowyk
approved these changes
Oct 12, 2022
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
piaskowyk
pushed a commit
that referenced
this pull request
Oct 12, 2022
This PR improves developer experience of error handling in worklets by showing a RedBox with full error message rather than crashing the whole app on Android. **Note:** Android with Fabric enabled works only if building with NDK 21 via `yarn react-native run-android [--active-arch-only]`, crashes when building with NDK 24 from Android Studio, see Shopify/flash-list#550 (comment) for details (this is not an issue with Reanimated) <table> <thead> <tr> <th rowspan="2">Scenario</th> <th colspan="2">Before</th> <th colspan="2">After</th> </tr> <tr> <th>Paper</th> <th>Fabric</th> <th>Paper</th> <th>Fabric</th> </thead> <tbody> <tr> <td>worklet</td> <td align="center">💥</td> <td align="center">💥</td> <td align="center">✅</td> <td align="center">✅</td> </tr> <tr> <td>nested worklet</td> <td align="center">💥</td> <td align="center">💥</td> <td align="center">✅</td> <td align="center">✅</td> </tr> <tr> <td>useAnimatedStyle</td> <td align="center">💥</td> <td align="center">💥</td> <td align="center">✅</td> <td align="center">✅</td> </tr> <tr> <td>useDerivedValue</td> <td align="center">💥</td> <td align="center">💥</td> <td align="center">✅</td> <td align="center">✅</td> </tr> <tr> <td>useFrameCallback</td> <td align="center">💥</td> <td align="center">💥</td> <td align="center">✅</td> <td align="center">✅</td> </tr> <tr> <td>GestureDetector</td> <td align="center">💥</td> <td align="center">💥</td> <td align="center">✅</td> <td align="center">✅</td> </tr> <tr> <td>useAnimatedGestureHandler</td> <td align="center">💥</td> <td align="center">💥</td> <td align="center">✅</td> <td align="center">✅</td> </tr> <tr> <td>useAnimatedScrollHandler</td> <td align="center">💥</td> <td align="center">💥</td> <td align="center">✅</td> <td align="center">✅</td> </tr> <tr> <td>useScrollViewOffset</td> <td align="center">💥</td> <td align="center">💥</td> <td align="center">✅</td> <td align="center">✅</td> </tr> </tbody> </table> https://github.com/software-mansion/react-native-reanimated/blob/48af341d51ca289dc007fdfd81d124ae0c267523/FabricExample/android/build.gradle#L11-L17 ```diff - ndkVersion = "24.0.8215888" + ndkVersion = "21.4.7075529" ``` `ERROR: Unknown host CPU architecture: arm64` ```console code ~/Library/Android/sdk/ndk/21.4.7075529/ndk-build ``` ```diff DIR="$(cd "$(dirname "$0")" && pwd)" -$DIR/build/ndk-build "$@" +arch -x86_64 $DIR/build/ndk-build "$@" ``` - [ ] Included code example that can be used to test this change - [ ] Updated TS types - [ ] Added TS types tests - [ ] Added unit / integration tests - [ ] Updated documentation - [ ] Ensured that CI passes
fluiddot
pushed a commit
to wordpress-mobile/react-native-reanimated
that referenced
this pull request
Jun 5, 2023
## Description This PR improves developer experience of error handling in worklets by showing a RedBox with full error message rather than crashing the whole app on Android. **Note:** Android with Fabric enabled works only if building with NDK 21 via `yarn react-native run-android [--active-arch-only]`, crashes when building with NDK 24 from Android Studio, see Shopify/flash-list#550 (comment) for details (this is not an issue with Reanimated) <table> <thead> <tr> <th rowspan="2">Scenario</th> <th colspan="2">Before</th> <th colspan="2">After</th> </tr> <tr> <th>Paper</th> <th>Fabric</th> <th>Paper</th> <th>Fabric</th> </thead> <tbody> <tr> <td>worklet</td> <td align="center">💥</td> <td align="center">💥</td> <td align="center">✅</td> <td align="center">✅</td> </tr> <tr> <td>nested worklet</td> <td align="center">💥</td> <td align="center">💥</td> <td align="center">✅</td> <td align="center">✅</td> </tr> <tr> <td>useAnimatedStyle</td> <td align="center">💥</td> <td align="center">💥</td> <td align="center">✅</td> <td align="center">✅</td> </tr> <tr> <td>useDerivedValue</td> <td align="center">💥</td> <td align="center">💥</td> <td align="center">✅</td> <td align="center">✅</td> </tr> <tr> <td>useFrameCallback</td> <td align="center">💥</td> <td align="center">💥</td> <td align="center">✅</td> <td align="center">✅</td> </tr> <tr> <td>GestureDetector</td> <td align="center">💥</td> <td align="center">💥</td> <td align="center">✅</td> <td align="center">✅</td> </tr> <tr> <td>useAnimatedGestureHandler</td> <td align="center">💥</td> <td align="center">💥</td> <td align="center">✅</td> <td align="center">✅</td> </tr> <tr> <td>useAnimatedScrollHandler</td> <td align="center">💥</td> <td align="center">💥</td> <td align="center">✅</td> <td align="center">✅</td> </tr> <tr> <td>useScrollViewOffset</td> <td align="center">💥</td> <td align="center">💥</td> <td align="center">✅</td> <td align="center">✅</td> </tr> </tbody> </table> ## Test code and steps to reproduce ### Building with NDK 21 on M1-based Mac https://github.com/software-mansion/react-native-reanimated/blob/48af341d51ca289dc007fdfd81d124ae0c267523/FabricExample/android/build.gradle#L11-L17 ```diff - ndkVersion = "24.0.8215888" + ndkVersion = "21.4.7075529" ``` `ERROR: Unknown host CPU architecture: arm64` ```console code ~/Library/Android/sdk/ndk/21.4.7075529/ndk-build ``` ```diff #!/bin/sh DIR="$(cd "$(dirname "$0")" && pwd)" -$DIR/build/ndk-build "$@" +arch -x86_64 $DIR/build/ndk-build "$@" ``` ## Checklist - [ ] Included code example that can be used to test this change - [ ] Updated TS types - [ ] Added TS types tests - [ ] Added unit / integration tests - [ ] Updated documentation - [ ] Ensured that CI passes
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.

Description
This PR improves developer experience of error handling in worklets by showing a RedBox with full error message rather than crashing the whole app on Android.
Note: Android with Fabric enabled works only if building with NDK 21 via
yarn react-native run-android [--active-arch-only], crashes when building with NDK 24 from Android Studio, see Shopify/flash-list#550 (comment) for details (this is not an issue with Reanimated)Test code and steps to reproduce
Building with NDK 21 on M1-based Mac
react-native-reanimated/FabricExample/android/build.gradle
Lines 11 to 17 in 48af341
ERROR: Unknown host CPU architecture: arm64code ~/Library/Android/sdk/ndk/21.4.7075529/ndk-buildChecklist