nesbox / TIC-80

TIC-80 is a fantasy computer for making, playing and sharing tiny games.
https://tic80.com
MIT License
4.98k stars 479 forks source link

Games in Firefox slow down. (if you do not move the mouse intensively) #1347

Open Ratinod opened 3 years ago

Ratinod commented 3 years ago

OS: Windows 10 Firefox: 85.0.2 (x64)

example: https://tic80.com/play?cart=115

Don't move the mouse cursor: https://user-images.githubusercontent.com/12137233/107885422-523d3b00-6f0b-11eb-9389-1437cf513df6.mp4 Move the mouse cursor, then stop: https://user-images.githubusercontent.com/12137233/107885485-a9431000-6f0b-11eb-9bcf-c372b3595437.mp4

RobLoach commented 3 years ago

It's running okay for me. An older version of Firefox, and an older laptop. It sounds like a limitation on the CPU? What hardware are you on? Try Chrome instead, I've seen differences in the ways they run WASM.

Ratinod commented 3 years ago

If it was a CPU limitation, then there would be problems in other browsers, right? But in other browsers everything is fine (the problem appears specifically in firefox). And if you move the mouse, then there is no slowdown. CPU: I7-4770k

RobLoach commented 3 years ago

Firefox's implementation of web assembly is somewhat different than Chrome's implementation. There isn't much that we can do in TIC-80 to help that.

joshgoebel commented 3 years ago

CPU: I7-4770k

@RobLoach That's no slouch of a CPU. It's quite possible it's indeed a Firefox issue, but I'm not sure it's a CPU issue - since as stated it works normally if the mouse is moved... Sadly I have no idea what to suggest though.

Ratinod commented 3 years ago

after run cart firefox: total cpu usage ~7% total gpu usage ~ 20% opera: total cpu usage ~7% total gpu usage ~ 10%

firefox: when launched in multiple tabs, slows down in all tabs (no worse than it was) opera: when launched in multiple tabs, works well

Update: Achieved even more dramatic slowdown in the browser: 1) Open firefox 2) Open https://tic80.com/play?cart=115 3) Open https://tic80.com/play?cart=115 in the second tab. Result: (sound from the first tab is muted) https://user-images.githubusercontent.com/12137233/107926929-6161ce80-6f87-11eb-9fe8-c8308a743107.mp4 Mouse movements also give some positive effect, but overall even worse than in the first tab. 4) Then I closed the first tab. Nothing changed.

joshgoebel commented 2 years ago

This sounds like perhaps a Firefox problem more than a TIC-80 problem... can we reproduce this now in 2022 with the latest builds of TIC-80 and Firefox?

Ratinod commented 2 years ago

I confirm. The problem is reproduced with the latest builds of TIC-80 and Firefox.

ChillyCider commented 1 year ago

I'm also seeing slowdown issues in my own game (link) when viewing it in Firefox. I'm using Firefox 113.0.2 (Windows 11).

I am using pairs(...) and closures in a few places. But, I experimentally got rid of those and the game still crawls :(

I did find something interesting though. I intended to open Firefox's Inspector and do some profiling, but, weirdly enough, my game runs perfectly when Firefox is recording a profile. ???

Then when I stop recording a profile, the game slows to a crawl again. I really have no idea what's going on.

RobLoach commented 1 year ago

I won the game! Played on Firefox 113.0.2 (64-bit) Linux, didn't experience any slowdown. Fun game! Brought me back to playing Lemmings as a kid.

aliceisjustplaying commented 5 months ago

@Ratinod @ChillyCider is this still an issue?

ChillyCider commented 5 months ago

I'll download latest version and check when I get home tonight. I'll keep you posted.

Ratinod commented 5 months ago

Firefox 125.0.3 (64-bit). ~After testing, I can say that the issue in my case is no longer reproducible.~ ~I think the Issue can be closed.~ (After receiving confirmation from @ChillyCider)

ChillyCider commented 5 months ago

A few minutes ago, I exported an HTML cart using the latest nightly. The fps and sound quality still plummet on my laptop (Windows 11, Firefox version 125.0.3). Seems like very much a Firefox issue, whatever it is.

Honestly though -- usage of Firefox as a browser is down to 5% in Europe and even less in USA, so it may not even be a target to care about.

ChillyCider commented 5 months ago

I should mention (as a continuation of the above) other web games work fine in my browser. Even PICO-8 games, so idk.

Ratinod commented 5 months ago

After a more in-depth test and comparison with another browser, I can say that the problem is still there. However, this problem has changed. Now there is no sharp crackling sound or interruptions. But there is an unknown reason for the slowdown in sound. Moving the mouse no longer has any effect. In general, the problem is no longer so glaringly obvious, but it still exists.