Bug 234315 - REGRESSION (r286982): ASSERTION FAILED: clipRectsContext.rootLayer == m_clipRectsCache->m_clipRectsRoot[clipRectsType]
Summary: REGRESSION (r286982): ASSERTION FAILED: clipRectsContext.rootLayer == m_clipR...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Layout and Rendering (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: cathiechen
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2021-12-14 14:09 PST by Ryan Haddad
Modified: 2022-01-10 23:40 PST (History)
15 users (show)

See Also:


Attachments
WIP-patch (1.58 KB, patch)
2021-12-24 03:14 PST, cathiechen
no flags Details | Formatted Diff | Diff
Patch (3.24 KB, patch)
2022-01-06 06:28 PST, cathiechen
no flags Details | Formatted Diff | Diff
Patch (3.25 KB, patch)
2022-01-06 06:45 PST, cathiechen
no flags Details | Formatted Diff | Diff
Patch (3.21 KB, patch)
2022-01-06 22:52 PST, cathiechen
no flags Details | Formatted Diff | Diff
[fast-cq] Patch (4.16 KB, patch)
2022-01-10 00:09 PST, cathiechen
simon.fraser: review+
ntim: commit-queue-
Details | Formatted Diff | Diff
[fast-cq] Patch for landing (4.23 KB, patch)
2022-01-10 10:57 PST, Tim Nguyen (:ntim)
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Ryan Haddad 2021-12-14 14:09:40 PST
fast/layers/top-layer-ancestor-opacity-and-transform-crash.html is asserting on iOS and macOS debug bots since https://trac.webkit.org/changeset/286982/webkit, which was a revert of https://trac.webkit.org/changeset/283354/webkit 

ASSERTION FAILED: clipRectsContext.rootLayer == m_clipRectsCache->m_clipRectsRoot[clipRectsType]
./rendering/RenderLayer.cpp(4410) : Ref<WebCore::ClipRects> WebCore::RenderLayer::updateClipRects(const WebCore::RenderLayer::ClipRectsContext &)
1   0x14fa1c950 WTFCrash
2   0x105812230 WebCore::Converter<WebCore::IDLDOMString>::ReturnType WebCore::convert<WebCore::IDLDOMString>(JSC::JSGlobalObject&, JSC::JSValue)
3   0x109b7f31c WebCore::RenderLayer::updateClipRects(WebCore::RenderLayer::ClipRectsContext const&)
4   0x109b7f840 WebCore::RenderLayer::parentClipRects(WebCore::RenderLayer::ClipRectsContext const&) const
5   0x109b75ef4 WebCore::RenderLayer::backgroundClipRect(WebCore::RenderLayer::ClipRectsContext const&) const
6   0x109b75604 WebCore::RenderLayer::paintLayerWithEffects(WebCore::GraphicsContext&, WebCore::RenderLayer::LayerPaintingInfo const&, WTF::OptionSet<WebCore::RenderLayer::PaintLayerFlag>)
7   0x109b74be8 WebCore::RenderLayer::paintLayer(WebCore::GraphicsContext&, WebCore::RenderLayer::LayerPaintingInfo const&, WTF::OptionSet<WebCore::RenderLayer::PaintLayerFlag>)
8   0x109b7a64c WebCore::RenderLayer::paintList(WebCore::RenderLayer::LayerList, WebCore::GraphicsContext&, WebCore::RenderLayer::LayerPaintingInfo const&, WTF::OptionSet<WebCore::RenderLayer::PaintLayerFlag>)
9   0x109b770b4 WebCore::RenderLayer::paintLayerContents(WebCore::GraphicsContext&, WebCore::RenderLayer::LayerPaintingInfo const&, WTF::OptionSet<WebCore::RenderLayer::PaintLayerFlag>)
10  0x109b76620 WebCore::RenderLayer::paintLayerContentsAndReflection(WebCore::GraphicsContext&, WebCore::RenderLayer::LayerPaintingInfo const&, WTF::OptionSet<WebCore::RenderLayer::PaintLayerFlag>)
11  0x109b76400 WebCore::RenderLayer::paintLayerByApplyingTransform(WebCore::GraphicsContext&, WebCore::RenderLayer::LayerPaintingInfo const&, WTF::OptionSet<WebCore::RenderLayer::PaintLayerFlag>, WebCore::LayoutSize const&)
12  0x109b756dc WebCore::RenderLayer::paintLayerWithEffects(WebCore::GraphicsContext&, WebCore::RenderLayer::LayerPaintingInfo const&, WTF::OptionSet<WebCore::RenderLayer::PaintLayerFlag>)
13  0x109b74be8 WebCore::RenderLayer::paintLayer(WebCore::GraphicsContext&, WebCore::RenderLayer::LayerPaintingInfo const&, WTF::OptionSet<WebCore::RenderLayer::PaintLayerFlag>)
14  0x109b7a64c WebCore::RenderLayer::paintList(WebCore::RenderLayer::LayerList, WebCore::GraphicsContext&, WebCore::RenderLayer::LayerPaintingInfo const&, WTF::OptionSet<WebCore::RenderLayer::PaintLayerFlag>)
15  0x109b770b4 WebCore::RenderLayer::paintLayerContents(WebCore::GraphicsContext&, WebCore::RenderLayer::LayerPaintingInfo const&, WTF::OptionSet<WebCore::RenderLayer::PaintLayerFlag>)
16  0x109b95d84 WebCore::RenderLayerBacking::paintIntoLayer(WebCore::GraphicsLayer const*, WebCore::GraphicsContext&, WebCore::IntRect const&, WTF::OptionSet<WebCore::PaintBehavior>, WebCore::EventRegionContext*)::$_25::operator()(WebCore::RenderLayer&, WTF::OptionSet<WebCore::RenderLayer::PaintLayerFlag>) const
17  0x109b95804 WebCore::RenderLayerBacking::paintIntoLayer(WebCore::GraphicsLayer const*, WebCore::GraphicsContext&, WebCore::IntRect const&, WTF::OptionSet<WebCore::PaintBehavior>, WebCore::EventRegionContext*)
18  0x109b969cc WebCore::RenderLayerBacking::paintContents(WebCore::GraphicsLayer const*, WebCore::GraphicsContext&, WebCore::FloatRect const&, unsigned int)
19  0x1094abe38 WebCore::GraphicsLayer::paintGraphicsLayerContents(WebCore::GraphicsContext&, WebCore::FloatRect const&, unsigned int)
20  0x10958bbdc WebCore::GraphicsLayerCA::platformCALayerPaintContents(WebCore::PlatformCALayer*, WebCore::GraphicsContext&, WebCore::FloatRect const&, unsigned int)
21  0x106e8a3d4 WebCore::PlatformCALayer::drawLayerContents(WebCore::GraphicsContext&, WebCore::PlatformCALayer*, WTF::Vector<WebCore::FloatRect, 5ul, WTF::CrashOnOverflow, 16ul, WTF::FastMalloc>&, unsigned int)
22  0x1095cb29c WebCore::TileGrid::platformCALayerPaintContents(WebCore::PlatformCALayer*, WebCore::GraphicsContext&, WebCore::FloatRect const&, unsigned int)
23  0x106f483ec -[WebSimpleLayer drawInContext:]
24  0x1b8ab6660 CABackingStoreUpdate_
25  0x1b8b15464 invocation function for block in CA::Layer::display_()
26  0x1b8ab58d0 -[CALayer _display]
27  0x106f481d8 -[WebSimpleLayer display]
28  0x1b8ab49d8 CA::Layer::display_if_needed(CA::Transaction*)
29  0x1b8bf6aac CA::Context::commit_transaction(CA::Transaction*, double, double*)
30  0x1b8a96d78 CA::Transaction::commit()
31  0x12c3b8fcc WebKit::TiledCoreAnimationDrawingArea::forceRepaint()


https://results.webkit.org/?suite=layout-tests&test=fast%2Flayers%2Ftop-layer-ancestor-opacity-and-transform-crash.html&limit=31116
Comment 1 Radar WebKit Bug Importer 2021-12-14 14:09:54 PST
<rdar://problem/86488039>
Comment 2 Ryan Haddad 2021-12-14 15:32:05 PST
Skipped the test for debug in r287055.
Comment 3 cathiechen 2021-12-24 03:14:58 PST
Created attachment 447933 [details]
WIP-patch

Looks like it hits this assert.
ASSERT(clipRectsContext.rootLayer == m_clipRectsCache->m_clipRectsRoot[clipRectsType]);

IIUC, `m_clipRectsRoot` of ClipRectsCache is set while `updateLayerPositions()` which happens after layout.
And  `clipRectsContext.rootLayer` comes from `paintInfo.rootLayer`.
Looks like the rootLayer is changed in RenderLayer::paintLayerByApplyingTransform(see [1]).
Also happens in RenderLayer::hitTestLayerByApplyingTransform(see [2]).

Then the assert doesn't pass.

Regarding the approach, I tried to update `m_clipRectsRoot` of ClipRectsCache, it seems not work, for there are other layers don't has transform.
So maybe we shouldn't let the transform layers use the clipRects in `m_clipRectsRoot`, i.e, use TemporaryClipRects instead. The WIP patch is attached, not sure if this makes sense or not?

[1] https://webkit-search.igalia.com/webkit/source/Source/WebCore/rendering/RenderLayer.cpp#3495
[2] https://webkit-search.igalia.com/webkit/source/Source/WebCore/rendering/RenderLayer.cpp#4333
Comment 4 cathiechen 2022-01-06 06:28:36 PST
Created attachment 448494 [details]
Patch
Comment 5 cathiechen 2022-01-06 06:45:49 PST
Created attachment 448497 [details]
Patch
Comment 6 Simon Fraser (smfr) 2022-01-06 11:08:49 PST
Comment on attachment 448497 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=448497&action=review

> Source/WebCore/rendering/RenderLayer.cpp:4457
> +    if (establishesTopLayer() && !parent()->establishesTopLayer())

Even if both this and parent establish a top layer, they are in separate top layers so I think you should just check establishesTopLayer().
Comment 7 cathiechen 2022-01-06 22:50:46 PST
Comment on attachment 448497 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=448497&action=review

>> Source/WebCore/rendering/RenderLayer.cpp:4457
>> +    if (establishesTopLayer() && !parent()->establishesTopLayer())
> 
> Even if both this and parent establish a top layer, they are in separate top layers so I think you should just check establishesTopLayer().

Done! Thanks!
Comment 8 cathiechen 2022-01-06 22:52:38 PST
Created attachment 448563 [details]
Patch
Comment 9 cathiechen 2022-01-07 01:54:08 PST
Still crash in "mac-AS-debug-wk2" of EWS, it seems the crash exists before the patch. See, https://bugs.webkit.org/show_bug.cgi?id=230079
Comment 10 Rob Buis 2022-01-07 10:55:52 PST
(In reply to cathiechen from comment #9)
> Still crash in "mac-AS-debug-wk2" of EWS, it seems the crash exists before
> the patch. See, https://bugs.webkit.org/show_bug.cgi?id=230079

It may make sense to change the patch to skip top-layer-ancestor-opacity-and-transform-crash.html on Mac Debug with bug 230079 as reference.
Comment 11 cathiechen 2022-01-10 00:09:15 PST
(In reply to Rob Buis from comment #10)
> (In reply to cathiechen from comment #9)
> > Still crash in "mac-AS-debug-wk2" of EWS, it seems the crash exists before
> > the patch. See, https://bugs.webkit.org/show_bug.cgi?id=230079
> 
> It may make sense to change the patch to skip
> top-layer-ancestor-opacity-and-transform-crash.html on Mac Debug with bug
> 230079 as reference.

Done! Thanks, Rob!
Comment 12 cathiechen 2022-01-10 00:09:52 PST
Created attachment 448725 [details]
[fast-cq] Patch
Comment 13 Simon Fraser (smfr) 2022-01-10 10:26:30 PST
Comment on attachment 448725 [details]
[fast-cq] Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=448725&action=review

> Source/WebCore/ChangeLog:11
> +        treated as a root layer. When the tranformed layer updates its clip rects, the root layer won't

tranformed
Comment 14 Tim Nguyen (:ntim) 2022-01-10 10:47:11 PST
Comment on attachment 448725 [details]
[fast-cq] Patch

Win failure is false alarm.
Comment 15 Tim Nguyen (:ntim) 2022-01-10 10:47:42 PST
Comment on attachment 448725 [details]
[fast-cq] Patch

let me address simon's comment first
Comment 16 Tim Nguyen (:ntim) 2022-01-10 10:57:54 PST
Created attachment 448776 [details]
[fast-cq] Patch for landing
Comment 17 EWS 2022-01-10 11:08:04 PST
Committed r287847 (245896@main): <https://commits.webkit.org/245896@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 448776 [details].
Comment 18 cathiechen 2022-01-10 23:40:01 PST
Thanks, Tim and Simon!