Bug 236155

Summary: PerformanceObserver should work with {type: 'paint', buffered: true }
Product: WebKit Reporter: Andrew Scheuermann <andrewscheuermann>
Component: DOMAssignee: Nobody <webkit-unassigned>
Status: RESOLVED DUPLICATE    
Severity: Normal CC: bfulgham, noam, simon.fraser, webkit-bug-importer, wilander
Priority: P2 Keywords: BrowserCompat, InRadar
Version: Safari 15   
Hardware: Unspecified   
OS: Unspecified   

Description Andrew Scheuermann 2022-02-04 13:32:41 PST
** Steps to reproduce: **

1. Navigate to example.com (or any web page) in Safari and run the following code in the console:

```
new PerformanceObserver((list) => {
  console.log('callback invoked');
  list.getEntries().forEach(console.log);
}).observe({ type: 'paint', buffered: true });
```

** Actual Results: **

Nothing is logged and the callback is not invoked.

** Expected Results: **

A PerformancePaintTiming entry should be logged. The paint entry is logged with this other approach...

```
performance.getEntriesByType('paint').forEach(console.log);
```

** Additional Information: **
Related Stack Overflow question -> https://stackoverflow.com/questions/70989089/new-performanceobservercb-observe-type-paint-buffered-true-doesnt-w
Comment 1 Radar WebKit Bug Importer 2022-02-04 16:14:19 PST
<rdar://problem/88513217>
Comment 2 Simon Fraser (smfr) 2022-02-07 11:58:01 PST

*** This bug has been marked as a duplicate of bug 78011 ***
Comment 3 Simon Fraser (smfr) 2022-02-08 16:57:46 PST
Not a dup.
Comment 4 Noam Rosenthal 2022-02-08 22:34:41 PST
This is already covered in a web platform test: https://wpt.live/paint-timing/fcp-only/fcp-iframe.html

From what I checked it works as expected in safari. I also tested it manually in a fresh page.

Note that the observer needs to be added before the paint happens - in your example steps that's not the case.

Can you post a test page where you add an observer before the paint and the observer is not called?
Comment 5 Andrew Scheuermann 2022-02-09 09:48:36 PST
To clarify, the "Steps to reproduce" show a PerformanceObserver that is created with {type: 'paint', buffered: true}. The presence of the buffered parameter means that the PerformanceObserver callback should invoke with paint entries that occurred ~before~ the observer is added.

You can reproduce this buffered behavior on Chrome, Firefox, Opera, and Edge by copying in the code at any time after the initial paint occurs.


I've updated the bug description to "PerformanceObserver should work with {type: 'paint', buffered: true }"

https://developer.mozilla.org/en-US/docs/Web/API/PerformanceObserver/observe#parameters
Comment 6 Noam Rosenthal 2022-02-09 09:58:57 PST
(In reply to Andrew Scheuermann from comment #5)
> To clarify, the "Steps to reproduce" show a PerformanceObserver that is
> created with {type: 'paint', buffered: true}. The presence of the buffered
> parameter means that the PerformanceObserver callback should invoke with
> paint entries that occurred ~before~ the observer is added.
> 
> You can reproduce this buffered behavior on Chrome, Firefox, Opera, and Edge
> by copying in the code at any time after the initial paint occurs.
> 
> 
> I've updated the bug description to "PerformanceObserver should work with
> {type: 'paint', buffered: true }"
> 
> https://developer.mozilla.org/en-US/docs/Web/API/PerformanceObserver/
> observe#parameters

Ah. I think this is a dup of https://bugs.webkit.org/show_bug.cgi?id=225305
Comment 7 Noam Rosenthal 2022-02-09 10:05:46 PST

*** This bug has been marked as a duplicate of bug 225305 ***
Comment 8 Noam Rosenthal 2022-02-09 10:08:33 PST
I marked it as dup, and found an existing failing WPT for this https://wpt.fyi/results/paint-timing/fcp-only/buffered-flag.window.html?label=experimental&label=master&aligned which would make it easier to reproduce and fix.