Skip to content

chore(android-new-arch): reproduce modal layout issues #50704

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

Conversation

AndreiCalazans
Copy link
Contributor

@AndreiCalazans AndreiCalazans commented Apr 14, 2025

Summary:

See #50442

Note: this reproducible patch was made on top of 0.76 stable branch however this is reproducible on latest main.

We are experiencing an issue with Modals on Android when the new architecture is enabled.

When trying to render a modal, especially in a busy JS thread on Android, the rendered UI does not match expected layout. This either causes a layout glitch, where the Modal content flashes an incorrect layout, or a Modal's inner content layout fully broken (see image below).

In this example below, we were mounting then unmounting a few Modals in sequence and eventually (inconsistently happening) the app gets into a frozen state where no user input gets through the app anymore. When inspecting the UI layout on Android Studio it shows that Android's Dialog is rendered as expected fully covering the UI however its children content has incorrect width values:

image

When we attempt to reproduce this issue in rn-tester we couldn't exactly replicate the frozen UI state however we can see replicate the incorect layout issues occuring when in a busy thread:

Video of the incorrect layout rendered on Android with new architecture enabled.

Same experience without new arch enabled on Android - has o glitch despite very busy JS thread.

There seems to be a shared theme here with onLayout returning empty layout dimensions during first mount which others have observed that this also breaks layout animations from Reanimated.

Other observations. If we wrap the Modal's children with a View that has fixed width and height we do see the entire content properly rendered however the touch system is broken and the children is unable to receive presses.

Changelog:

Test Plan:

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Apr 14, 2025
@react-native-bot
Copy link
Collaborator

react-native-bot commented Apr 14, 2025

Fails
🚫

📋 Verify Changelog Format - See Changelog format

Generated by 🚫 dangerJS against de31b10

@AndreiCalazans AndreiCalazans changed the title chore: attempt reproducing modal layout issues on new arch chore(android new arch): attempt reproducing modal layout issues Apr 14, 2025
@AndreiCalazans AndreiCalazans changed the title chore(android new arch): attempt reproducing modal layout issues chore(android new arch): reproduce modal layout issues Apr 14, 2025
@AndreiCalazans AndreiCalazans changed the title chore(android new arch): reproduce modal layout issues chore(android-new-arch): reproduce modal layout issues Apr 14, 2025
@cortinico
Copy link
Contributor

@AndreiCalazans can you send this against main?

Also could you edit the RNTesterPlayground.js file to reproduce this issue?

@AndreiCalazans AndreiCalazans changed the base branch from 0.76-stable to main April 15, 2025 12:12
@AndreiCalazans AndreiCalazans changed the base branch from main to 0.76-stable April 15, 2025 12:16
@AndreiCalazans AndreiCalazans force-pushed the andrei/reproduce-modal-issue-new-arch branch from e5f8f7c to de31b10 Compare April 15, 2025 12:50
@AndreiCalazans AndreiCalazans changed the base branch from 0.76-stable to main April 15, 2025 12:50
@AndreiCalazans
Copy link
Contributor Author

@cortinico sure. updated base to main and moved code to playground instead.

@cortinico
Copy link
Contributor

Thanks for the repro @AndreiCalazans We're investigating this. I'll get back to you sometime next week

cortinico added a commit to cortinico/react-native that referenced this pull request May 1, 2025
Summary:
Fixes facebook#50442
Closes facebook#50704

Users reported that Modals on Android are first renderer anchored in 0,0.
That results in them being on the top left corner of the screen for some seconds.

This is happening because the native state of the Modal on Android as width/height set at 0,0 - which we then update in a subsequent callback.

I'm fixing this by making sure we render the Modal the first time with the right screen size - the status bar size

Changelog:
[Android] [Fixed] - Fix Modal first frame being rendered on top-left corner

Differential Revision: D73948178
cortinico added a commit to cortinico/react-native that referenced this pull request May 1, 2025
Summary:

Fixes facebook#50442
Closes facebook#50704

Users reported that Modals on Android are first renderer anchored in 0,0.
That results in them being on the top left corner of the screen for some seconds.

This is happening because the native state of the Modal on Android as width/height set at 0,0 - which we then update in a subsequent callback.

I'm fixing this by making sure we render the Modal the first time with the right screen size - the status bar size

Changelog:
[Android] [Fixed] - Fix Modal first frame being rendered on top-left corner

Differential Revision: D73948178
cortinico added a commit to cortinico/react-native that referenced this pull request May 1, 2025
Summary:

Fixes facebook#50442
Closes facebook#50704

Users reported that Modals on Android are first renderer anchored in 0,0.
That results in them being on the top left corner of the screen for some seconds.

This is happening because the native state of the Modal on Android as width/height set at 0,0 - which we then update in a subsequent callback.

I'm fixing this by making sure we render the Modal the first time with the right screen size - the status bar size

Changelog:
[Android] [Fixed] - Fix Modal first frame being rendered on top-left corner

Differential Revision: D73948178
cortinico added a commit to cortinico/react-native that referenced this pull request May 1, 2025
Summary:
Pull Request resolved: facebook#51048

Fixes facebook#50442
Closes facebook#50704

Users reported that Modals on Android are first renderer anchored in 0,0.
That results in them being on the top left corner of the screen for some seconds.

This is happening because the native state of the Modal on Android as width/height set at 0,0 - which we then update in a subsequent callback.

I'm fixing this by making sure we render the Modal the first time with the right screen size - the status bar size

Changelog:
[Android] [Fixed] - Fix Modal first frame being rendered on top-left corner

Differential Revision: D73948178
cortinico added a commit to cortinico/react-native that referenced this pull request May 2, 2025
Summary:

Fixes facebook#50442
Closes facebook#50704

Users reported that Modals on Android are first renderer anchored in 0,0.
That results in them being on the top left corner of the screen for some seconds.

This is happening because the native state of the Modal on Android as width/height set at 0,0 - which we then update in a subsequent callback.

I'm fixing this by making sure we render the Modal the first time with the right screen size - the status bar size

Changelog:
[Android] [Fixed] - Fix Modal first frame being rendered on top-left corner

Differential Revision: D73948178
@AndreiCalazans AndreiCalazans deleted the andrei/reproduce-modal-issue-new-arch branch May 2, 2025 13:34
cortinico added a commit to cortinico/react-native that referenced this pull request Jun 17, 2025
Summary:
Pull Request resolved: facebook#51048

Fixes facebook#50442
Closes facebook#50704

Users reported that Modals on Android are first renderer anchored in 0,0.
That results in them being on the top left corner of the screen for some seconds.

This is happening because the native state of the Modal on Android as width/height set at 0,0 - which we then update in a subsequent callback.

I'm fixing this by making sure we render the Modal the first time with the right screen size - the status bar size

Changelog:
[Android] [Fixed] - Fix Modal first frame being rendered on top-left corner

Differential Revision: D73948178
cortinico added a commit to cortinico/react-native that referenced this pull request Jun 18, 2025
Summary:
Pull Request resolved: facebook#51048

Fixes facebook#50442
Closes facebook#50704

Users reported that Modals on Android are first renderer anchored in 0,0.
That results in them being on the top left corner of the screen for some seconds.

This is happening because the native state of the Modal on Android as width/height set at 0,0 - which we then update in a subsequent callback.

I'm fixing this by making sure we render the Modal the first time with the right screen size - the status bar size

Changelog:
[Android] [Fixed] - Fix Modal first frame being rendered on top-left corner

Reviewed By: javache

Differential Revision: D73948178
cortinico added a commit to cortinico/react-native that referenced this pull request Jun 18, 2025
Summary:
Pull Request resolved: facebook#51048

Fixes facebook#50442
Closes facebook#50704

Users reported that Modals on Android are first renderer anchored in 0,0.
That results in them being on the top left corner of the screen for some seconds.

This is happening because the native state of the Modal on Android as width/height set at 0,0 - which we then update in a subsequent callback.

I'm fixing this by making sure we render the Modal the first time with the right screen size - the status bar size

Changelog:
[Android] [Fixed] - Fix Modal first frame being rendered on top-left corner

Reviewed By: javache

Differential Revision: D73948178
cortinico added a commit to cortinico/react-native that referenced this pull request Jun 19, 2025
Summary:

Fixes facebook#50442
Closes facebook#50704

Users reported that Modals on Android are first renderer anchored in 0,0.
That results in them being on the top left corner of the screen for some seconds.

This is happening because the native state of the Modal on Android as width/height set at 0,0 - which we then update in a subsequent callback.

I'm fixing this by making sure we render the Modal the first time with the right screen size - the status bar size

Changelog:
[Android] [Fixed] - Fix Modal first frame being rendered on top-left corner

Reviewed By: javache

Differential Revision: D73948178
cortinico added a commit to cortinico/react-native that referenced this pull request Jun 19, 2025
Summary:
Pull Request resolved: facebook#51048

Fixes facebook#50442
Closes facebook#50704

Users reported that Modals on Android are first renderer anchored in 0,0.
That results in them being on the top left corner of the screen for some seconds.

This is happening because the native state of the Modal on Android as width/height set at 0,0 - which we then update in a subsequent callback.

I'm fixing this by making sure we render the Modal the first time with the right screen size - the status bar size

Changelog:
[Android] [Fixed] - Fix Modal first frame being rendered on top-left corner

Reviewed By: javache

Differential Revision: D73948178
facebook-github-bot pushed a commit that referenced this pull request Jun 19, 2025
Summary:
Pull Request resolved: #51048

Fixes #50442
Closes #50704

Users reported that Modals on Android are first renderer anchored in 0,0.
That results in them being on the top left corner of the screen for some seconds.

This is happening because the native state of the Modal on Android as width/height set at 0,0 - which we then update in a subsequent callback.

I'm fixing this by making sure we render the Modal the first time with the right screen size - the status bar size

Changelog:
[Android] [Fixed] - Fix Modal first frame being rendered on top-left corner

Reviewed By: javache

Differential Revision: D73948178

fbshipit-source-id: 055c12aa62d70acc1e4c5a2a5c4ea0c5608e22c7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Pick Request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants