Bug 197891 - [IntersectionObserver] Regression: No initial observation when nothing else triggers rendering
Summary: [IntersectionObserver] Regression: No initial observation when nothing else t...
Alias: None
Product: WebKit
Classification: Unclassified
Component: Layout and Rendering (show other bugs)
Version: WebKit Local Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Ali Juma
Keywords: InRadar
Depends on:
Reported: 2019-05-14 12:57 PDT by Ali Juma
Modified: 2019-05-30 13:39 PDT (History)
8 users (show)

See Also:

Test case (489 bytes, text/html)
2019-05-14 12:57 PDT, Ali Juma
no flags Details
Patch (4.14 KB, patch)
2019-05-15 13:03 PDT, Ali Juma
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
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]
Comment 5 WebKit Commit Bot 2019-05-16 06:55:02 PDT
Comment on attachment 369985 [details]

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