Hacker News new | ask | show | jobs
by Retr0id 857 days ago
In Firefox, I'm getting ~500ms GC pauses every few seconds which make it pretty difficult to play. It works fine in Chromium, though.

Edit: Firefox 122.0 on aarch64 (fedora asahi)

3 comments

From the source the only thing I can see that would make garbage is b.innerText=o which is set 50 times each frame.

But even then it's just one giant text node, not html elements so it's surprising this is causing so much GC in Firefox.

Looks like a job for the new profiler.firefox.com
Here's a profile of the freeze being caused the GC if anyone wants to try and debug: https://share.firefox.dev/487vDxG
The profile actually shows the freeze is not caused by normal JS garbage collection, but by cycle collection. So probably something related to DOM nodes.
By the way, here's my simplified/annotated version of the code https://gist.github.com/DavidBuchanan314/13f4c4e8d9573108ff9...
Looks like the lag can be fixed by only updating b.innerText once per frame. This seems like a ff bug to be honest, but it appears that rapidly updating the size of innerText is the culprit.
Actually I'm using Chrome and I also got some random lag spikes