A 'Commit' Task In The Performance Inspector Is Slowing Down My JavaScript Game

1.7k Views Asked by At

This is probably relatively simple, but unfortunatly it's not an easy thing to google.

A client has tasked me with making a little 404 page runner game, similar to the google dino game. It runs fairly well despite using a ton of css animation.

My big problem right now: every once in a while there is a 'Commit' task called that lags the game for a second. It's sometimes enough to make the player lose.

Commit event

All I can tell is that it might be something to do with rendering the CSS. But google has turned up empty.

I would apreciate any tips on how to minimize the effects of whatever this is. Thank you!

2

There are 2 best solutions below

0
Jesper Ingels On

Maybe you could inspect your code keeping 'The pixel pipeline' in mind -> https://web.dev/rendering-performance/

When animating on the web you want to keep the pipeline as short as possible.

For example: if you want to animate an element moving from left to right you could animate the left value but this will cause a layout recalculation followed by paint and composite. You could do the same thing by using transform: translateX(), this will only cause a composite recalculation which is much shorter.

Maybe these articles also help:

0
diachedelic On

I had Commit tasks taking up to 5 seconds. The problem went away when I disabled "Enable advanced paint instrumentation (slow)".

enter image description here