Repository navigation
fix: Drop Android CSS transition animators when the React context goes - #10241
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughSummary by CodeRabbit
WalkthroughCSS platform transition cleanup now tracks listener instances, rejects stale observers, blocks work after invalidation, cancels active animators, clears pending transitions, and runs from ChangesCSS transition invalidation
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant NativeProxy
participant CSSPlatformTransitionsManager
participant ActiveAnimators
participant CSSPlatformTransitionReconciler
NativeProxy->>CSSPlatformTransitionsManager: invalidate()
CSSPlatformTransitionsManager->>CSSPlatformTransitionsManager: mark invalidated and clear pending starts
CSSPlatformTransitionsManager->>ActiveAnimators: cancel active animators on UI thread
CSSPlatformTransitionsManager->>CSSPlatformTransitionReconciler: invalidate()
CSSPlatformTransitionReconciler->>CSSPlatformTransitionReconciler: remove tracked pre-draw listeners
Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
a874e64 to
cb87314
Compare
c5a0a61 to
1acacee
Compare
cb87314 to
180e3db
Compare
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In
`@packages/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/css/CSSPlatformTransitionReconciler.kt`:
- Around line 15-22: Update the tracking flow around track, invalidate, and
retire to resolve and retain the post-attachment window ViewTreeObserver as the
listener owner before pruning dead observers, ensuring listeners are removed
even when the temporary detached observer is invalidated. Preserve the
one-listener-per-window behavior and add a regression test covering detached
tracking, attachment, and invalidate().
In
`@packages/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/css/CSSPlatformTransitionsManager.kt`:
- Around line 94-104: Make CSSPlatformTransitionsManager invalidation terminal
by adding a flag set before the UI-thread cleanup is posted. Guard
animateTransition() at entry and again inside its UI-thread lambda, returning
when invalidated so queued work cannot repopulate startTokens, create animators,
or call reconciler.track() after invalidate().
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: 1891504d-ceed-479e-ab50-7a768a274e65
📒 Files selected for processing (3)
packages/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/NativeProxy.ktpackages/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/css/CSSPlatformTransitionReconciler.ktpackages/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/css/CSSPlatformTransitionsManager.kt
c0dd12a to
ca4506b
Compare
180e3db to
4419a63
Compare
ca4506b to
3cdb9b0
Compare
4419a63 to
1f30248
Compare
3cdb9b0 to
59515a8
Compare
59515a8 to
2a9450d
Compare
The pre-draw listeners are registered on the window's
ViewTreeObserver, which survives a React context teardown, so nothing removed them: after a reload they kept running every frame and retained the dead context through the manager.NativeProxy.invalidate()now tears the manager down alongsidepseudoSelectorManager, cancelling the animators, dropping the pending starts and removing the listeners. The reconciler keepsobserver -> listenerpairs so removal is possible at all; aHashSetof observers gave nothing to pass toremoveOnPreDrawListener.