Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WPT fails to capture certain async JavaScript processing #3063

Open
pmdartus opened this issue May 6, 2024 · 0 comments
Open

WPT fails to capture certain async JavaScript processing #3063

pmdartus opened this issue May 6, 2024 · 0 comments
Labels
Type: Bug An issue or pull request relating to a bug in WebPageTest

Comments

@pmdartus
Copy link

pmdartus commented May 6, 2024

Description

WPT doesn’t capture all the JavaScript processing time during page load. More concretely, WPT reports idle main time on the browser main thread, for any JavaScript processing triggered from a fetch response.

Steps to reproduce

This issue can be reproduced by running WPT on a Chrome desktop with the default setting against the following page: https://wpt-async-repro.pages.dev/

The result can be found here: https://www.webpagetest.org/result/240506_AiDcKB_5G1/

Description

The HTML source code can be found in this gist. The HTML page contains a single <script> simulating JavaScript on the main thread.

The doWork function blocks the main thread for 500ms and adds performance markers at the beginning and the end of each chunk of work. This function is invoked in 4 different ways:

  • sync: synchronously during script evaluation
  • microtask: asynchronously in a microtask enqueued during script evaluation
  • timeout: asynchronously in a macro-task scheduled via a timeout
  • fetch: asynchronously in a microtask after the reception of a fetch request

Expected result

The WPT run should report ~2 seconds of JavaScript processing time. The JavaScript processing time should be reflected in:

  • Processing Breakdown table as “Scripting” time
  • Waterfall panel in the “CPU main thread” swimlane
  • Chrome Timeline view as JavaScript scripting
  • and, in Chrome Trace view

Recording a Performance timeline locally through the Chrome Devtools with JavaScript Sampling disabled correctly captures all the JavaSript processing time.

Actual result

The WPT run reports ~1.5 seconds of JavaScript processing time. The 500ms of JavaScript processing time associated with the fetch response is missing from the WPT run result.

Processing breakdown

Chrome Timeline

Further Investigation

When digging further it is apparent that the Chrome Dev Tools captures the JavaScript execution associated with the fetch response thanks to the v8.execute Chrome tracing category. The list of tracing categories used by the Chrome Dev Tools used by the performance panel can be found here.

@pmdartus pmdartus added the Type: Bug An issue or pull request relating to a bug in WebPageTest label May 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug An issue or pull request relating to a bug in WebPageTest
Projects
None yet
Development

No branches or pull requests

1 participant