-
Notifications
You must be signed in to change notification settings - Fork 672
Patch reanimated to avoid using executeOnUIRuntimeSync #6774
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
base: develop
Are you sure you want to change the base?
Conversation
c0add7f
to
a3bb128
Compare
a3bb128
to
280531b
Compare
I tested the build and it’s a noticeable improvement. Didn’t test everything, but I didn't see any issues where shared values are used most heavily. This does create a small race window, right? In theory at least, where the |
Yes I think in theory it is possible, but in practice I am hoping it is not (unless using |
561cabb
to
2b3a375
Compare
02e857b
to
c6505a8
Compare
Been working with the reanimated team and got a version working without the possibility of race condition, using a new Synchronized value type (basically a value that can be accessed across runtimes with a lock). software-mansion/react-native-reanimated#7913, I've updated the patch to an adapted version of it that works on reanimated v3. |
After looking at the code and reading through the discussion with Reanimated team, I think there are some points to it.
I think in the end it's a matter of do we prefer better performance over being sure that we won't see random visual glitches. I think we can give it to QA team, and if they don't spot anything wrong after thoroughly testing it, I'd give it a go. |
I think with this current version the possible issue is so unlikely to happen that the perf improvement is worth it. I tried to create an artificial case that trigger the issue and wasn't able to. I will fix the conflict then I think we're good to go with this. |
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.
Approving but let's keep potential issues in mind with this one!
c6505a8
to
ba46330
Compare
Fixes APP-####
What changed (plus any additional context for devs)
This avoids usage of
executeOnUIRuntimeSync
in reanimated if the shared value has not changed yet. When an animated view is mounted, on first render, reanimated queries the value of the shared value on JS thread synchronously, but for 90% of the cases that value still has its initial value since it was created at the same time as the view. If that is the case we can avoid the expensive call and return initial value directly. Whenever the shared value changes the first time we call into JS to set the dirty flag to true and then if the shared value is connected to a view again it will fall back to slow path callingexecuteOnUIRuntimeSync
.On low end android this is by far the slowest thing in JS traces, since it need to lock JS thread to wait for a probably already very busy UI thread.
Edit:
Perf is a lot better after upgrading RN because of a fix in hermes facebook/hermes#1572.
Screen recordings / screenshots
Before:
0.74
0.79
After:
0.74
0.79
What to test
Test everything and look for broken animations.