Repository navigation
Conversation
This branch has not been deployed
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:
With view recycling on, a view can sit in the pool while it still has a parent. If that parent called
startViewTransitionon it and then left the window beforeendViewTransition, the parent drops the view from its disappearing children but keeps itself asview.getParent(). The existingremoveViewcall increateViewInstancecan't clear that, so the recycled view goes back to the mounting layer andaddViewAtcrashes with "The specified child already has a parent". react-native-screens hits this when it pops a screen.Now
createViewInstanceonly reuses a pooled view if its parent is gone after theremoveViewcall, and creates a new view otherwise. Views pooled while still attached to a non-recycling parent are reused as before.Fixes #59863
Changelog:
[ANDROID] [FIXED] - Fix "The specified child already has a parent" crash when a recycled view is still held by a parent's view transition
Test Plan:
Added
testViewStillHeldByADetachedParentIsNotRecycledtoBaseViewManagerTest. It holds a view withstartViewTransition, removes it, detaches the parent from the window, drops the view, and adds the next created view to a new parent. Without the fix it throwsIllegalStateException: The specified child already has a parent; with the fix it passes.The full ReactAndroid unit test suite passes.
format-check-javaandformat-check-kotlinare clean. I didn't run the reproducer app on a device.