4

My website uses the following optimizations to free up main thread as well as optimize content load process:

- Web workers for loading async data as well as images.
- Defer images until all the content on page is loaded first
- typekit webfontloader for optimized font load

Now since the time I completely switched over to webworkers for all network [async] related tasks, I have noticed the increased occurence in following errors[by ~50%]: Error: Invalid task timing data

But my score seems to be unaffected.

PageSpeed score

My question is, how accurate is this score?

P.S: My initial data is huge, so styling and rendering takes ~1300ms & ~1100ms resp. [required constraint]

Zeeshan Hyder
  • 520
  • 5
  • 14
  • Could you share your website URL, I have a few guesses as to the cause but need to see it in action. The score is not affected as there is no weighting for JavaScript execution time in the scoring (it looks at `time-to-interactive` and `first-CPU-idle` which would normally take JS execution time into effect, but as you are using web workers and it only monitors the main thread for 'quiet time' it won't show up (simplified but you get the idea)) – GrahamTheDev Oct 12 '19 at 21:54
  • Sure! It's https://indianswhodesign.in – Zeeshan Hyder Oct 12 '19 at 21:56

1 Answers1

0

After doing a few experiments and glancing through the LightHouse (the engine that powers PSI) source code I think the problem comes in the fact that once everything has loaded (page load event) Lighthouse only runs for a few seconds before terminating.

However your JS runs for quite some time afterwards with the service workers performing some tasks nearly 11 seconds after page load on one run of mine (probably storing some images which take a long time to download).

I am guessing you are getting intermittent errors as sometimes the CPU goes quiet long enough to calculate JS execution time and sometimes it does not (depending on how long it is between tasks it is performing).

To see what I mean open developer tools on Chrome -> Performance Tab -> Set CPU slowdown to 4 x slowdown (which is what Lighthouse emulates) and press 'record' (top left). Now reload the page and once it has loaded fully stop recording.

You will get a preformance profile and there is a section 'Main' that you can expand to see the main thread load (which is still used despite using a worker as it needs to decode the base64 encoded images, not sure if that can be shifted onto a different thread)

You will see that tasks continue to use CPU for 3-4 seconds after page load.

It is a bug with Lighthouse but at the same time something to address at your side as it is symptomatic of a problem (why base64 encoded images? that is where you are taking the performance hit on what would otherwise be a well-optimised site).

GrahamTheDev
  • 22,724
  • 2
  • 32
  • 64