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

Speedometer doesn't capture all React work #441

Open
flashdesignory opened this issue Oct 31, 2024 · 0 comments
Open

Speedometer doesn't capture all React work #441

flashdesignory opened this issue Oct 31, 2024 · 0 comments

Comments

@flashdesignory
Copy link
Contributor

flashdesignory commented Oct 31, 2024

The react scheduler does work until a deadline is reached, then uses postMessage to schedule additional work. The speedometer runner does not wait for this additional work to complete before finishing the async period of the test. This is a general problem, but differences in timing between Safari and Chrome mean that Chrome ends up doing more real work during the scoring phase of the test.

To showcase the challenge, let's look at the NewsSite-Next workload, where we added a debug message in a component:

useEffect(() => {
        console.log(`useEffect with message: ${title}`);
        performance.mark(`useEffect with message: ${title}`);
    });

    useLayoutEffect(() => {
        console.log(`useLayoutEffect with message: ${title}`);
        performance.mark(`useLayoutEffect with message: ${title}`);
    });

Screenshot from Chrome:
_chrome

Screenshot from Safari:
_safari

A potential solution could be to use an AsyncSuiteRunner class that waits for each test.run() step.
I tested the approach locally and do see a more fair comparison between Chrome and Safari, with the message being captured in the test steps during the measured async time.

Safari before:
_before

Safari after:

new
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant