Set scrolls_viewport bits from viewport registration
The issue in this crash is that we compute the viewport registration and the scrolls_inner_viewport|scrolls_outer_viewport bits separately, even though they mean the same thing. However, in some cases they end up not matching which leads to violating invariants in the compositor. In some (I believe transient) cases, [1] will not have a GlobalRootScroller so we don't have an outer viewport. Because of that, we also avoid registering an inner viewport. This both-or-neither viewport registration was added in https://crrev.com/c/1955860 to simplify viewport existence. However, setting the |scrolls_inner_viewport| bit on the ScrollNode happens earlier, during pre-paint[2] at which point we don't yet know whether the outer viewport will be registered. This means we end up in a situation in the compositor where InnerViewportScrollNode() returns nullptr (because it comes from the ViewportPropertyIds) but there exists a node in the ScrollTree where |scrolls_inner_viewport| is true. The crash happens because we assume that if we're looking at a node that has this bit set to true, we must also have an outer viewport and so we crash dereferencing OuterViewportScrollNode. Ideally, we wouldn't need to duplicate this information but we don't want to do a ScrollTree walk each time we want to get one of the viewport nodes. So we need the ViewportPropertyIds registration. I've considered removing the |scrolls_x_viewport| bits altogether, compositor code can always do something like: scroll_node == InnerViewportScrollNode() But there's a handful of cases inside property_trees.cc that check these bits and they don't have access to the ViewportPropertyIds. We could pass those down but that seems awkward. This CL changes it so that we set these bits based on the nodes we register to the ViewportPropertyIds. The information is duplicated but at least it comes from the same source. This also means we don't need the bit on the blink-side paint property node so the bit is removed there. [1] https://source.chromium.org/chromium/chromium/src/+/master:third_party/blink/renderer/core/frame/local_frame_view.cc;l=2813;drc=e085cd7f91fd90b436565329510b738afb436b19 [2] https://source.chromium.org/chromium/chromium/src/+/master:third_party/blink/renderer/core/frame/visual_viewport.cc;l=218;drc=4045478f9a1db6872c1527a8e725bb79ae90f5ce Bug: 1037759 Change-Id: I1dc06d9c6541b4afcd351841e8e7544ec11e3eb7 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2006610 Commit-Queue: David Bokan <bokan@chromium.org> Reviewed-by:Xianzhu Wang <wangxianzhu@chromium.org> Reviewed-by:
Philip Rogers <pdr@chromium.org> Cr-Commit-Position: refs/heads/master@{#733404}
Showing
Please register or sign in to comment