Sync settled props when app resumes#9588
Open
sorinc03 wants to merge 1 commit into
Open
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
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.
Summary
Fixes #9574.
FORCE_REACT_RENDER_FOR_SETTLED_ANIMATIONSsyncs completed animated props back into React on a polling interval. On Android, a press-drivenLinking.openURLcan pause the app before the next polling tick, leaving React state behind the final native animated value until the app resumes.This registers an
AppStatelistener while the settled-props collector is active and triggers an immediate sync when the app becomesactive, so React catches up as soon as the app returns instead of waiting for the next interval tick.Test plan
Added a Jest regression test for the app-resume sync:
yarn workspace react-native-reanimated test PropsRegistryGarbageCollector.test.ts --runInBand yarn eslint packages/react-native-reanimated/src/PropsRegistryGarbageCollector.ts packages/react-native-reanimated/__tests__/PropsRegistryGarbageCollector.test.tsI also smoke-tested the linked Android repro on an API 35 emulator:
git clone https://github.com/lujjjh/reanimated-settled-props-repro pnpm install pnpm exec expo prebuild --platform android --clean pnpm androidI ran the press-driven flow from #9574 repeatedly on the published
4.4.0package and on this branch wired throughfile:../react-native-reanimated/packages/react-native-reanimated. The issue did not reproduce in this emulator run, but the patched build compiled, installed, launched, and kept the modal open through 8 browser-return loops with the same modal bounds after returning.