-
-
Notifications
You must be signed in to change notification settings - Fork 545
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,Fabric): prevent another infinite state update loop for header subviews with zero size #2696
fix(Android,Fabric): prevent another infinite state update loop for header subviews with zero size #2696
Conversation
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.
Currently blocked by regression detected in testing
@@ -32,12 +33,11 @@ class RNSScreenStackHeaderSubviewComponentDescriptor final | |||
|
|||
auto state = std::static_pointer_cast< | |||
const RNSScreenStackHeaderSubviewShadowNode::ConcreteState>( | |||
shadowNode.getState()); |
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.
The bug I've reported in earlier comment was caused by accessing mounted state and not the most recent one.
@kkafar Thanks for the quick fix, unfortunately I can't install v4.7.0 on IOS now.
Android works now, but it looks like it is adding some safe area insets again (as a black bar) to the bottom of my screen, when I'm navigating (default presentation) to some other root screen.
Just to let you quickly know... |
@marcel-happyfloat thanks for the report, however I do need more details to investigate any of the issues you mentioned. Could you provide a recording of the bug and preferably a snippet / detailed description of navigation hierarchy where I can reproduce the issue? |
Description
Closes #2675
Error mechanism
This one was tricky to figure out.
Few concurrent facts first:
statusBarTranslucent
istrue
we applypaddingTop
to nativeToolbar
to heighten the header.Header subview that represents the search bar has no content. Therefore native layout sets it frame to exactly (0, 0), but with origin
(x, toolbar.paddingTop)
.This frame -
((x, toolbar.paddingTop), (0, 0))
is send to shadow node, where it is ignored, but the layout is triggered by subsequent header config update.Therefore Yoga resolves height of the subview to full height of the parent (usually
154 px = 40 dip
). New layout metrics are sent to HostTree, where next native toolbar layoutdetermines toolbar size to be its content height + padding == subview height + paddingTop. This gets send to ShadowTree, then back to HostTree, native layout is triggered and another
paddingTop
value is added to the overall header height, and so on.This is a regression introduced in 4.6.0 and limited to Fabric.
The fix is simple - accept the (0, 0) size for the subview in ShadowTree. We just need to use more reasonable value to denote the uninitialized frame -
{-1, -1}
seems like a better choice asit is an invalid frame.
Changes
Test code and steps to reproduce
Test2675
Tested on all combinations:
statusBarTranslucent: true
andfalse
,Also tested iOS on the same example, because the code changes affect shared C++ code.
Checklist