-
Notifications
You must be signed in to change notification settings - Fork 24.9k
Fix handling removal of transitioning views #47634
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
Closed
Closed
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
0c310cb
Prevent removal from parent when transitioning
kkafar ca9a22d
Track children removed while transitioning
kkafar 00e0e52
Merge main && refactor the code to comply with recent changes
kkafar 150c15e
Cleanup
kkafar 48b90ad
Cleanup 2
kkafar 6e15352
Cleanup 3
kkafar 4d6b796
Prevent bug when setting removeClippedSubviews to `false` after `endV…
kkafar 93b0a35
Add missing import
kkafar c3da8d0
Allocate hashset only when necessary
kkafar 09b7c62
Merge branch 'main' into @kkafar/support-for-view-transition
kkafar eb4e4fd
Get rid of redundant null check
kkafar c14e026
Review part one
kkafar a7c7af3
Just clear the hash set, do not release it
kkafar f54164d
Support cases where not all children are transitioning at once
kkafar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
Oops, something went wrong.
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.
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.
Hmm, this is really interesting, and may explain a crash we're seeing. I wonder why we were previously removing this subview twice - potentially messing up some state in ReactViewGroup.
What's your reasoning for removing this?
Uh oh!
There was an error while loading. Please reload this page.
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.
@javache thanks for review. My logic was as follows:
before 0b22b95 you relied on
handleRemoveView
being called to perform side effects regarding child drawing order. Implementation ofReactViewgroup.removeView
took care of handling these sideeffects and detaching child view from parent.On the other hand
ReactViewGroup.removeViewWithSubviewClippingEnabled
had also two responsibilities:mAllChildren
array, which also retained children already detached due to clipping.Notice, that it had not performed
handleRemoveView
.My theory is that in clipping view manager you had call to
parent.removeView(child)
to ensure sideeffects ofhandleRemoveView
were performed and then you calledparent.removeViewWithSubviewClippingEnabled(child)
to remove child frommAllChildren
array, relying on the guard from (1), which prevented Android crash potentially caused by removing twice the same child view.After 0b22b95 side effects of
handleRemoveView
have been moved toonViewRemoved
which is called on any attempt of child removal by the Android framework. Therefore we can remove the call toparent.removeView
as all required side effects will be performed by the call toparent.removeViewWithSubviewClippingEnabled(child)
- drawing order code, removal frommAllChildren
and child detachment. I've left the check for nullish child, as I couldn't determine what was the logic behind it.