diff --git a/apps/common-app/src/apps/reanimated/examples/AndroidDrawPassExample.tsx b/apps/common-app/src/apps/reanimated/examples/AndroidDrawPassExample.tsx new file mode 100644 index 000000000000..8b00d222d791 --- /dev/null +++ b/apps/common-app/src/apps/reanimated/examples/AndroidDrawPassExample.tsx @@ -0,0 +1,181 @@ +import { useNavigation } from '@react-navigation/native'; +import type { NativeStackNavigationProp } from '@react-navigation/native-stack'; +import { createNativeStackNavigator } from '@react-navigation/native-stack'; +import React, { useCallback } from 'react'; +import { Button, StyleSheet, Text, View } from 'react-native'; +import Animated, { + interpolate, + useAnimatedScrollHandler, + useAnimatedStyle, + useSharedValue, +} from 'react-native-reanimated'; + +type AndroidDrawPassParamList = { + Description: undefined; + ScrollList: undefined; +}; + +const Stack = createNativeStackNavigator(); +const LIST_ITEM_COUNT = 80; + +export default function AndroidDrawPassExample() { + return ( + + + + + + + ); +} + +function DescriptionScreen() { + const navigation = + useNavigation>(); + + return ( + + Android Draw Pass Fix + + This example reproduces a bug that was fixed on Android where committing + updates during a draw pass caused a crash. + + + Previously, if you navigated to the scroll list and went back{' '} + while actively scrolling, + the app would crash. This happened because Reanimated was attempting to + commit UI updates while Android was in the middle of a draw pass, and + sometimes React would have some hierarchy mutations queued up that would + get bundled with these updates, triggering the crash. + + + The fix detects when a draw pass is in progress and pushes only + non-layout updates through the synchronous update path, while layout + updates are deferred to the next frame. This ensures that we never + attempt to mutate the view hierarchy during a draw pass. + +