Bug 236155 - PerformanceObserver should work with {type: 'paint', buffered: true }
Summary: PerformanceObserver should work with {type: 'paint', buffered: true }
Status: RESOLVED DUPLICATE of bug 225305
Alias: None
Product: WebKit
Classification: Unclassified
Component: DOM (show other bugs)
Version: Safari 15
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords: BrowserCompat, InRadar
Depends on:
Blocks:
 
Reported: 2022-02-04 13:32 PST by Andrew Scheuermann
Modified: 2022-02-09 10:08 PST (History)
5 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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.