Skip to content

perf: Skip the pre-draw repair on frames without React mounts - #10263

Merged
MatiPl01 merged 2 commits into
mainfrom
@matipl01/android-css-mount-gated-repair
Aug 13, 2026
Merged

MatiPl01 merged 2 commits into
mainfrom
@matipl01/android-css-mount-gated-repair

Conversation

@MatiPl01

@MatiPl01 MatiPl01 commented Aug 13, 2026 •

Copy link
Copy Markdown
Contributor

The pre-draw repair re-asserts every running platform transition on every frame, but React can only overwrite an animated value on frames where it wrote props. A UIManagerListener records mounts and the repair returns immediately on all other frames, so the walk over running transitions happens at write rate rather than at the display refresh rate.

That matters most after a transition settles: a persistent hold keeps its entry, so without the gate every later frame the window draws keeps walking the map. Measured on an emulator during a 3s transition, 201 of 240 pre-draw callbacks returned early.

Synchronous updates run their mount item inline (FabricUIManager.synchronouslyUpdateViewOnUIThread), bypassing MountItemDispatcher, so no listener fires for them even though opacity is one of the props they carry. They therefore open the gate explicitly, which makes the invariant true by construction rather than by coincidence. Measured on device, such writes are rare and always landed on a frame where a mount had already opened the gate, so this is insurance rather than an observed fix.

Identical in content to #10168, which this replaces. That one was based on the head branch of #10061, and closing #10061 instead of merging it left the base pointing at a branch with no live PR, so merging would not have reached main. GitHub refuses to change the base of a pull request that belongs to a stack, so recreating it was the only way to target main.

React can overwrite an animated value only on frames where a mount ran, so
a UIManagerListener records mounts and the repair returns immediately on
every other frame instead of walking all running transitions.
@MatiPl01 MatiPl01 self-assigned this Aug 13, 2026
@coderabbitai

coderabbitai Bot commented Aug 13, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 237cb581-0cdc-42de-86c9-da6a64761b83

📥 Commits

Reviewing files that changed from the base of the PR and between 267eb5f and dd32131.

📒 Files selected for processing (2)
  • packages/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/NativeProxy.kt
  • packages/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/css/CSSPlatformTransitionsManager.kt

📝 Walkthrough

Summary by CodeRabbit

  • Bug Fixes
    • Improved synchronization of UI property updates with platform transitions.
    • Prevented unnecessary transition repair work when no React-driven updates occur.
    • Improved handling of transition state during component mounting and lifecycle changes.

Walkthrough

The change adds React mount-write tracking to CSSPlatformTransitionsManager. NativeProxy reports synchronous UI property writes. Transition repair now runs only when React writes occurred since the previous draw.

Changes

CSS transition reconciliation

Layer / File(s) Summary
React mount write tracking
packages/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/css/CSSPlatformTransitionsManager.kt
The manager registers a FabricUIManager listener, records React writes on the UI thread, and removes the listener during invalidation.
Synchronous write notification and repair gating
packages/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/NativeProxy.kt, packages/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/css/CSSPlatformTransitionsManager.kt
NativeProxy reports synchronous prop writes. The manager skips repair when no React write occurred since the previous draw while preserving active animator state.

Estimated code review effort: 2 (Simple) | ~10 minutes

Mergeability Score: ⚪ Minimal · up to dd321

The change limits transition repair work to frames where React may have written props, while preserving coverage for synchronous updates. No actionable merge-blocking risk remains beyond normal checks and review.

Possibly related PRs

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly summarizes the main change: skipping pre-draw repair on frames without React mounts.
Description check ✅ Passed The description accurately explains mount-gated repair, synchronous updates, performance impact, and the pull request context.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch @matipl01/android-css-mount-gated-repair

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@MatiPl01
MatiPl01 requested a review from pawicao August 13, 2026 12:40
@MatiPl01
MatiPl01 merged commit 8bd685a into main Aug 13, 2026
18 checks passed
@MatiPl01
MatiPl01 deleted the @matipl01/android-css-mount-gated-repair branch August 13, 2026 12:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants