GoogleChrome / lighthouse

Automated auditing, performance metrics, and best practices for the web.
https://developer.chrome.com/docs/lighthouse/overview/
Apache License 2.0
28.02k stars 9.32k forks source link

TBT is incorrect for script type="module" #14739

Open agido-freudenreich opened 1 year ago

agido-freudenreich commented 1 year ago

FAQ

URL

https://bwin.de

What happened?

The Total Blocking Time (TBT) is incorrect if the page uses <script type="module" .../>.

The value is almost 0: Lighthouse

Because the time of "Evaluate module" is not considered: Performance

What did you expect?

"Evaluate module" should be treated the same way like "Evaluate script".

What have you tried?

Comparison between Lighthouse Audit and Performance analysis in Chrome Dev Tools. The page insight test has the same results.

How were you running Lighthouse?

Chrome DevTools

Lighthouse Version

9.6.8

Chrome Version

109.0.5414.119

Node Version

No response

OS

Mac

Relevant log output

No response

adamraine commented 1 year ago

I can't reproduce this because https://bwin.de/ returns a 403 page initially which forces Lighthouse to fail. Are you testing the page from a logged in state? I attempted to create a minimum repro with just a module script that blocks for 1s and Lighthouse does pick up that blocking time.

Also, did you get that performance panel result independently of running Lighthouse, or did you get to it by clicking the "View Trace"/"View Original Trace" button?

agido-freudenreich commented 1 year ago

Hi Adam, Thank you for looking at this. The 403 is maybe because of geo location restrictions based on your ip. The low TBT score is also visible at https://pagespeed.web.dev/report?url=https%3A%2F%2Fbwin.de%2F.

I did the performance analysis independently. I attached the profile where it is clearly visible that "Evaluate module" needs a lot of time which can't lead to a TBT of 80ms. PerformanceCheck

Profile-20230202T075752.json.zip

adamraine commented 1 year ago

I was able to reproduce this sometimes but I think it's working as intended. I would advise you to read our docs on variability and throttling to learn more about these topics.

I did the performance analysis independently.

The Lighthouse results are not guaranteed to match up with a performance trace you took independently. If you want to see the trace that Lighthouse used to compute TBT, you can click the "View Original Trace" button in a report collect from Lighthouse in DevTools. Keep in mind that the trace will show the unthrottled page load by default.

I attached the profile where it is clearly visible that "Evaluate module" needs a lot of time which can't lead to a TBT of 80ms.

Only tasks that run after FCP will count towards TBT. On PSI runs that had a low-ish TBT most of the long tasks were run before FCP:

Screenshot 2023-02-02 at 9 06 05 AM

The trace you provided doesn't have an FCP timing so it's hard to verify this 100%.

paulirish commented 1 year ago

I'm going to look at our allowlists like https://github.com/GoogleChrome/lighthouse/blob/main/core/lib/tracehouse/task-groups.js#L60-L73 and if they're comprehensive. We just faced similar problems in RPP.