You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There was a specific fix for the Animated API where we on animation end make a state update to actually re-render the component with the latest animated value to sync back to the shadow tree:
While this fix works on animation end it doesn't work for running animations.
In these recordings you can see how the onPress is fired while animating while on new arch its not, so its a regression:
Old Arch
New Arch
Works on every press during animation:
Doesn't work:
1000000790.mp4
1000000791.mp4
Now, this problem isn't exactly just limited to RNs Animated API. There are examples from other libraries, for example reanimated. They don't sync the values back on the JS thread yet in any way once an animation is done. Now we could blame reanimated for it and ask them to fix it, but ultimately it would suffer the same problem as RNs Animated API that it will be broken during animation. Issues for reference:
One solution is to switch the native implementation for the measure function back to how it's working on paper: measuring on the native view hierarchy.
This way when a touch gets dispatched on the native side and we calculate the area of the view, we know 100% for sure that it will be accurately the same to what we have on the screen right now:
In a lot of those issues it's recommended to switch to use Pressable from react-native-gesture-handler. This works because RNGH also uses the native view hierarchy to figure out where things are.
We might either want to fully switch measure and measureInWindow or create separate methods like measureNative and use those for press-ability (or just add a param like measureOnUI)?
The only downside I can see is that measureNative would be async. That would be fine for the pressability use case but I am not sure if thats causing issues in other places for Meta? Right now measure is also async by callback although it could become sync as far as I can see.
Another solution might be to still commit those updates to the shadow tree but ask to not mount the updates?
Steps to reproduce
Get the reproducer
yarn install
yarn android
Try pressing on the blue area
(In gradle.proeprties turn off new arch and test again, notice how its working)
Description
Historically there have been issues with Pressability on the new arch:
There was a specific fix for the Animated API where we on animation end make a state update to actually re-render the component with the latest animated value to sync back to the shadow tree:
While this fix works on animation end it doesn't work for running animations.
In these recordings you can see how the
onPressis fired while animating while on new arch its not, so its a regression:1000000790.mp4
1000000791.mp4
Now, this problem isn't exactly just limited to RNs Animated API. There are examples from other libraries, for example reanimated. They don't sync the values back on the JS thread yet in any way once an animation is done. Now we could blame reanimated for it and ask them to fix it, but ultimately it would suffer the same problem as RNs Animated API that it will be broken during animation. Issues for reference:
Potential solutions
One solution is to switch the native implementation for the
measurefunction back to how it's working on paper: measuring on the native view hierarchy.This way when a touch gets dispatched on the native side and we calculate the area of the view, we know 100% for sure that it will be accurately the same to what we have on the screen right now:
In a lot of those issues it's recommended to switch to use Pressable from react-native-gesture-handler. This works because RNGH also uses the native view hierarchy to figure out where things are.
We might either want to fully switch
measureandmeasureInWindowor create separate methods likemeasureNativeand use those for press-ability (or just add a param likemeasureOnUI)?The only downside I can see is that
measureNativewould be async. That would be fine for the pressability use case but I am not sure if thats causing issues in other places for Meta? Right nowmeasureis also async by callback although it could become sync as far as I can see.Another solution might be to still commit those updates to the shadow tree but ask to not mount the updates?
Steps to reproduce
React Native Version
0.79.2
Affected Platforms
Runtime - Android, Runtime - iOS
Areas
Fabric - The New Renderer
Output of
npx @react-native-community/cli infoStacktrace or Logs
MANDATORY Reproducer
https://github.com/hannojg/rn-animated-pressability
Screenshots and Videos
See description above