Bug 197891

Summary: [IntersectionObserver] Regression: No initial observation when nothing else triggers rendering
Product: WebKit Reporter: Ali Juma <ajuma>
Component: Layout and RenderingAssignee: Ali Juma <ajuma>
Status: RESOLVED FIXED    
Severity: Normal CC: bfulgham, commit-queue, pvollan, rohitrao, sabouhallawa, simon.fraser, webkit-bug-importer, zalan
Priority: P2 Keywords: InRadar
Version: WebKit Local Build   
Hardware: Unspecified   
OS: Unspecified   
See Also: https://bugs.webkit.org/show_bug.cgi?id=198382
Attachments:
Description Flags
Test case
none
Patch none

Description Ali Juma 2019-05-14 12:57:06 PDT
Created attachment 369885 [details]
Test case

After the rAF timing changes in bug 177484 (which are great news overall, bringing IntersectionObserver timing in-line with the spec and other browsers), an initial observation isn't fired after a call to IntersectionObserver::observe, until something else triggers rendering.

It should be enough to add a call to Document::scheduleRenderingUpdate at the end of IntersectionObserver::observe (this would correspond to "Schedule an iteration of the event loop" in https://w3c.github.io/IntersectionObserver/#dom-intersectionobserver-observe).
Comment 1 Simon Fraser (smfr) 2019-05-14 13:05:49 PDT
Did we not have tests that detected this, or did we skip them?
Comment 2 Ali Juma 2019-05-14 13:25:31 PDT
(In reply to Simon Fraser (smfr) from comment #1)
> Did we not have tests that detected this, or did we skip them?

Most of our tests (or at least, most of the WPTs) use rAF to wait for observations (which triggers a rendering update), or seem to call |observe| early enough that a rendering update will be scheduled for the initial layout of the page.

Speaking of skipped tests, the rAF changes seem to have fixed all of the flakiness we were seeing on the Mac Debug bots, so I'll go ahead and update those expectations.
Comment 3 Ali Juma 2019-05-15 13:03:14 PDT
It turns out that at least one of the reasons that no existing test caught this is that the speculative tiling timer and the tile size change timer trigger flushes (and rendering updates) even after the page is loaded and nothing is changing. So calls to IntersectionObserver::observe that happen within ~1 second of page load will work properly even though IntersectionObserver isn’t itself scheduling a rendering update.
Comment 4 Ali Juma 2019-05-15 13:03:25 PDT
Created attachment 369985 [details]
Patch
Comment 5 WebKit Commit Bot 2019-05-16 06:55:02 PDT
Comment on attachment 369985 [details]
Patch

Clearing flags on attachment: 369985

Committed r245396: <https://trac.webkit.org/changeset/245396>
Comment 6 WebKit Commit Bot 2019-05-16 06:55:03 PDT
All reviewed patches have been landed.  Closing bug.
Comment 7 Radar WebKit Bug Importer 2019-05-16 06:56:28 PDT
<rdar://problem/50851236>