Skip to content
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

Fix android layout animation z-index bug #5769

Merged
merged 1 commit into from
Mar 8, 2024

Conversation

bartlomiejbloniarz
Copy link
Contributor

@bartlomiejbloniarz bartlomiejbloniarz commented Mar 8, 2024

Summary

This PR fixes the bug that was causing z-index to behave incorrectly on Android after a layout animation was triggered. The issue was that sometimes our layout animation implementation was causing removeView to be called more than once for the same view. This is not a problem on plain Android, since there is a conditional check there for removal. However, react-native's implementation of ReactViewGroup does not check if the view is a part of this ViewGroup when handling removal.

Screenshot 2024-03-08 at 11 17 45

Screenshot 2024-03-08 at 11 12 28
The handler code decreases the counter, that maintains the number of views that have 'z-index' defined by the user. Calling removeView too many times causes the counter to go into negative numbers, causing react to disable custom z-index order, even when there are views with user defined z-index.

We decided to add an additional check when calling the removeView function in AnimationsManager.java. There is a possibility we could remove it altogether, but as of now this is not certain and requires further investigation.

closes #5715

Test plan

Check if the repro from #5715 works properly

Copy link
Member

@tomekzaw tomekzaw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@bartlomiejbloniarz bartlomiejbloniarz added this pull request to the merge queue Mar 8, 2024
Merged via the queue into main with commit 187ff54 Mar 8, 2024
10 checks passed
@bartlomiejbloniarz bartlomiejbloniarz deleted the @bartlomiejbloniarz/fix-android-z-index branch March 8, 2024 13:57
@mmmoussa
Copy link

mmmoussa commented May 2, 2024

This PR needs to be reverted. It broke a core part of our app. We have an animated view which we show and hide when tapping somewhere else on the screen which is no longer being removed correctly.

@mmmoussa
Copy link

mmmoussa commented May 3, 2024

It seems the offending PR was actually merged in 3.9.0 and is not this one. Apologies for the confusion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Android] Layout animations break z-index behavior when unmouting/remounting Views
4 participants