-
Notifications
You must be signed in to change notification settings - Fork 24.3k
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
Set size of Modal
only once on Android
#35803
base: main
Are you sure you want to change the base?
Conversation
Base commit: be38fbb |
From blame looks like this is added for fixing some app freezes, here the comment from original commit,
cc @cortinico ref: D3892795 |
I'm not sure that's the right diff number @jacdebug |
Ah sorry missing the context, its the change where original fix was added. |
I'm impacted by this and would like to see it merged. Anything holding this up (other than conflicts)? |
@cortinico @jacdebug is there anything specific blocking this? or @j-piasecki could rebase/address conflict and then it'd be ready to go? |
Nope this should be good to go. Let's rebase and merge it |
542b8c0
to
ff19cd0
Compare
|
@cortinico has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
@@ -168,8 +158,6 @@ protected void onAfterUpdateTransaction(ReactModalHostView view) { | |||
public Object updateState( | |||
ReactModalHostView view, ReactStylesDiffMap props, StateWrapper stateWrapper) { | |||
view.getFabricViewStateManager().setStateWrapper(stateWrapper); | |||
Point modalSize = ModalHostHelper.getModalHostSize(view.getContext()); | |||
view.updateState(modalSize.x, modalSize.y); |
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.
I think the renderer needs this information. What if React Native's viewport is not full screen but only partially covers the screen? In that case, we need to feed the information about available size to React Native so it knows that whatever is within the modal, is not constrained by RN's viewport size.
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.
Is there another direction that we could go to resolve the issue then @sammy-SC ?
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.
I would try to investigate why is the height wrong in the new architecture. The height seems to be off exactly by the height of the status bar. Could it be that ModalHostHelper.getModalHostSize(view.getContext())
returns height of React Native's view port instead of the desired size of the modal? Where is the height calculated for the old architecture and why is it correct? Maybe we missed something in the implementation for the new architecture.
Any news? I enabled the new architecture and set the StatusBartransLucent as true, and then got the wrong modal height |
This PR is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 7 days. |
I still have it at the back of my head, I'll try to get back to it shortly when I have some time. |
ff19cd0
to
5db452f
Compare
Modal
state updates on AndroidModal
only once on Android
On the old arch, the modal size is set in two places:
The size set in the first point is the same as on the new arch (without status bar height), and the next one is correct. This causes a visible blink, where the wrong layout is visible for one frame: 334412883-8fa9f086-c46e-4a23-84fc-1aa3dc7928bb.movOn the new arch, the modal size is also set in two places:
The difference here is that the first step on the new architecture is executed multiple times, which causes the values from The state being updated constantly with the values returned by the helper seems a bit weird to me, given that the second path also exists and it's effectively useless because of that. I've updated the PR, so now it updates the state with values from the helper only initially. cc. @sammy-SC @cortinico |
Any update on this? |
Summary
On the old architecture, when using a
Modal
with no animation and translucent status bar, a layout flash is noticeable when the modal is opened. Here's the video of this happening (it's visible for one frame):old_arch.mov
On the new architecture, the issue is more problematic as the modal keeps the wrong height:
new_arch.mov
This PR updates the logic related to setting modal size, to set only the initial state based on the helper method, and the following updates will be based on the dimensions received in
onSizeChanged
method.Issue relevant to this PR (with more details): #35804
Changelog
[Android] [Fixed] - Fixed wrong modal height when
statusBarTranslucent
is set totrue
Test Plan
I've tested the changes on the following snippet: