Bug 210556 - performance.getEntries() API is missing performance entries
Summary: performance.getEntries() API is missing performance entries
Status: RESOLVED CONFIGURATION CHANGED
Alias: None
Product: WebKit
Classification: Unclassified
Component: DOM (show other bugs)
Version: Safari 13
Hardware: All All
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2020-04-15 10:52 PDT by Jonas Badalic
Modified: 2022-08-18 16:56 PDT (History)
7 users (show)

See Also:


Attachments
Side-by-side test results (553.66 KB, image/png)
2020-04-15 10:52 PDT, Jonas Badalic
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jonas Badalic 2020-04-15 10:52:38 PDT
Created attachment 396550 [details]
Side-by-side test results

performance.getEntries() API is missing performance entries in Safari 13 on both mobile and desktop.

Context: 
I am sending multiple requests to different server nodes and attempting to use the performance API to retrieve the timings of each individual request in order to perform some latency computations. I am using fetch to do the actual requests and after each fetch call, I check the performance.getEntries list to find the resource I requested in order to save it's timing. Each individual request has a unique and immutable query param that identifies the sequence in which it was ran.

The requests run synchronously in order to minimize network overhead and avoid overloading the device. All of the requests respond with 200 status, but based on how they are executed will or will not end up being listed by calling performance.getEntries().

Bug: 
When executing requests synchronously, listing entries via performance.getEntries() will end up with partial lists that are missing the network requests that were sent - the missing requests appear to be non deterministic and randomly missing. Same goes for the size of performance.getEntries() which ends up containing different number of resource timings in each different call. If we however send all the requests asynchronously, the error rate is 0 and all the request timings are successfully retrieved by calling getEntries()

I have created 2 codesandbox cases:
1. ✅Working async version https://codesandbox.io/s/relaxed-poincare-hllei?file=/src/index.ts
2. 🟥Broken sync version https://codesandbox.io/s/elated-glitter-rexby?file=/src/index.ts

What might be confusing here, is the execution flow of sync vs async execution, but I assume that this should not matter, as each individual promise still looks like fetch(url).then(() => collectPerformanceTiming(url) and how all of the requests are orchestrated should be irrelevant unless I'm missing something.

I've tried reproducing the issue on either Chrome (v80) or Firefox (v74), but didn't manage to reproduce the problem I'm seeing on Safari.

Thank you everyone for the help and the work you are doing 🙌 Let me know if there's something else I can help with or if the description doesn't suffice
Comment 1 Radar WebKit Bug Importer 2020-04-15 17:17:49 PDT
<rdar://problem/61858226>
Comment 2 Ahmad Saleem 2022-08-09 12:54:40 PDT
I am unable to reproduce this bug in Safari 15.6 on macOS 12.5 ad "Broken Sync Version" does not have any failure and have 60 success and it is similar to other browsers.

Since it seems to be fixed along the way, I am marking this as "RESOLVED CONFIGURATION CHANGED", if it is something still not fixed, appreciate if some can highlight difference in testing for my knowledge and learning. Thanks!
Comment 3 Alexey Proskuryakov 2022-08-18 16:56:50 PDT
Nice!