Toolbar layout sometimes broken on iOS 10 with UI Refresh Location Bar |
|||||
Issue descriptionSteps to repro: 1. Enable UI Refresh and Refresh Location Bar flags 2. Use iOS 10 iPad, simulator is ok 3. close all tabs 4. open NTP 5. By using long-press on the tab switcher button, open an incognito NTP 6. By using long-press on the tab switcher button, open a NTP Expected results: Toolbar visible Actual results: Toolbar invisible. The layout of the toolbar is broken, but there is no error output in the console. On iOS 11, there layout is fine and the toolbar is visible. The breakage seems to come from the toolbar's use of two stack views that cannot determine their width and end up stretching the leading stack view to a gigantic width. The toolbar is laid out like this: H:|[Leading UIStackView]-[Location Bar Container]-[Trailing UIStackView]| Workaround: Adding a constant width constraint for either stack view resolves the problem. The bug also doesn't reproduce with the old flag, which makes me think that some attribute of the OmniboxTextFieldIOS allows auto layout on 10 to satisfy constraints. Possibly, text fields have an intrinsicContentSize? The bug DOES reproduce if the location bar view is swapped by a pure empty UIView, so I don't think the issue is a result of poor constraints inside the location bar.
,
Jun 13 2018
Thanks for digging. Sounds like this is what's going wrong: 1) The popup menu presenter invokes layout when the size class is Unspecified. 2) AdaptiveToolbarVC hides all of its buttons when the size class is Unspecified. 3) iOS 10 somehow breaks UIStackView's constraints when all of its subviews are hidden. #3 is out of our control and fixed in iOS 11. #1 and #2 both seem like bugs, but I'm not sure whether the current behavior is important to maintain in some cases. https://chromium-review.googlesource.com/c/chromium/src/+/1097207 attempts to avoid triggering #3 by preventing the stack view from shrinking to zero width. I think this is pretty safe as a temporary change.
,
Jun 13 2018
Yes, I've also seen updateHiddenInCurrentSizeClass is indeed called multiple times. I suspect that UIStackView's automagic relayout when the views are hidden doesn't happen correctly as the buttons are hidden and unhidden multiple times during one runloop. It is really hard to make them update their visibility only once, though, since there are so many code paths leading to updateHiddenInCurrentSizeClass, including some snapshotting calls and animation callbacks and stuff. I agree with Rohit that the proposed fix is good enough, since we understand the problem for the most part and the solution is a workaround for an iOS 10 bug. Going forward, I think the toolbar should be audited for the redundant calls to updateHiddenInCurrentSizeClass, and possibly some special-case handling should be introduced for the unspecified size classes, or fake trait collections need to be injected where appropriate. If this enables us to remove the workaround, that's great.
,
Jun 13 2018
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/8b0446e6d03446934b11236a768082bad8968814 commit 8b0446e6d03446934b11236a768082bad8968814 Author: Rohit Rao <rohitrao@chromium.org> Date: Wed Jun 13 08:30:08 2018 [ios] Fixes toolbar buttons disappearing when switching BVC modes. When switching between incognito and non-incognito BVCs, it is possible for all of the toolbar's buttons to be temporarily hidden. We believe that this results in the stack view having zero width, which seems to permanently break autolayout on iOS 10. Adding an optional width constraint seems to work around this issue. BUG= 851954 Cq-Include-Trybots: luci.chromium.try:ios-simulator-full-configs;master.tryserver.chromium.mac:ios-simulator-cronet Change-Id: I6995f2b3f5fa3b0f2eafb09e3970001fd16720f6 Reviewed-on: https://chromium-review.googlesource.com/1097207 Reviewed-by: Stepan Khapugin <stkhapugin@chromium.org> Commit-Queue: Stepan Khapugin <stkhapugin@chromium.org> Cr-Commit-Position: refs/heads/master@{#566759} [modify] https://crrev.com/8b0446e6d03446934b11236a768082bad8968814/ios/chrome/browser/ui/tab_switcher/tab_switcher_transition_egtest.mm [modify] https://crrev.com/8b0446e6d03446934b11236a768082bad8968814/ios/chrome/browser/ui/toolbar/adaptive/primary_toolbar_view.mm
,
Jun 13 2018
To Gauthier since this is in the toolbar. Let's discuss when you're back in the office. It'd be nice to get rid of this workaround and come up with a better solution.
,
Jun 18 2018
,
Jun 19 2018
Looking at the CL, as long as it is behind an iOS 10 only guard, I am fine with it.
,
Jun 19 2018
Verified based on the steps from original report. Toolbar looks good. Verified in iPad 5th Gen iOS 10.3.3 M69.0.3465.0 dev |
|||||
►
Sign in to add a comment |
|||||
Comment 1 by justincohen@chromium.org
, Jun 12 2018