Bug 264989

Summary: [content-visibility] REGRESSION(267547@main): Blank panels on bing.com (content-visibility: auto)
Product: WebKit Reporter: Tim Nguyen (:ntim) <ntim>
Component: Layout and RenderingAssignee: Rob Buis <rbuis>
Status: RESOLVED FIXED    
Severity: Normal CC: bfulgham, rbuis, simon.fraser, webkit-bug-importer, zalan
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Test reduction (from Alan Baradlay) none

Description Tim Nguyen (:ntim) 2023-11-16 15:55:33 PST
Created attachment 468635 [details]
Test reduction (from Alan Baradlay)

rdar://116822168

Some notes from Alan:

Layer content is not getting painted due to stale m_visibleDescendantStatusDirty on the “un-skipped” (scrolled back to viewport) self-painting layer’s parent layer.

RenderElement::styleWillChange’s willBeVisible branch needs some more involved dirty-ing

<div id=A style="content-visibility: auto">
  <div id=B style="position: relative;"></div>
</div>

1. When renderer (A) gets scrolled out, we call dirtyVisibleContentStatus() on its render layer (see RenderElement::styleWillChange) 
2. It triggers computeHasVisibleContent() call: we compute its visibility status ‘visible’ (note that renderer().isSkippedContent() is false as this is the root of the skipped content and not the actual skipped content)
3. we also compute renderer (B)’s layer’s visibility status. It’s hidden as it is a “skipped content”.
4. Now when renderer (A) gets scrolled back in, RenderElement::styleWillChange calls setHasVisibleContent on RenderLayer(A) but its m_hasVisibleContent is already true (see #2) so we early return (which makes RenderLayer (B) stay hidden).

The bug here is that when the content gets scrolled back in, and we get the RenderElement::styleWillChange() call on the content-visibility block (A), we treat it as if this layer was hidden (i.e. when it initially got scrolled out), but the layer (renderer) is not hidden at all, its subtree is. The current invalidation is not sufficient (and incorrect) and instead we should call dirtyVisibleContentStatus().
Comment 1 Tim Nguyen (:ntim) 2023-11-16 15:55:48 PST
rdar://116822168
Comment 2 Rob Buis 2023-12-11 11:06:10 PST
Pull request: https://github.com/WebKit/WebKit/pull/21642
Comment 3 EWS 2024-01-24 01:39:15 PST
Committed 273399@main (4241ce289630): <https://commits.webkit.org/273399@main>

Reviewed commits have been landed. Closing PR #21642 and removing active labels.