Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Firefox Sound Observations 🔥 🦊 🔉 🔍 #9

Closed
zicklag opened this issue Apr 15, 2021 · 9 comments
Closed

Firefox Sound Observations 🔥 🦊 🔉 🔍 #9

zicklag opened this issue Apr 15, 2021 · 9 comments

Comments

@zicklag
Copy link

zicklag commented Apr 15, 2021

I saw the note in the readme about sound playback issues in Firefox and I just wanted to share my experiencewith my own Bevy Kira plugin on web ( I'm not using this plugin, but I am using Kira ).

I also had audio issues on Firefox, but I noticed that Firefox is also using almost 100% of one of my CPU cores. If I resize the browser window so that it is much smaller, though, the CPU usage goes down and the sound playback works nicely. That seems to indicate that the issue isn't actually with the sound playback itself, but how much CPU usage the Bevy game is using on Firefox. It seems that Bevy takes much more CPU on firefox than it does on Chrome.

I'm not sure exactly what causes the CPU usage difference, but at least I think that gives us somewhere to look. If resizing the screen changes the CPU usage, then it is probably rendering. Maybe firefox's rendering is just slower than chrome's.

I'm using a custom renderer, too, so my experience may not be the best benchmark, but that's what I know for what it's worth.

@zicklag zicklag changed the title Firefox Sound Observations 🔉 🔍 Firefox Sound Observations Apr 15, 2021
@zicklag zicklag changed the title 🔉 🔍 Firefox Sound Observations 🦊 🔉 🔍 Firefox Sound Observations Apr 15, 2021
@zicklag zicklag changed the title 🦊 🔉 🔍 Firefox Sound Observations Firefox Sound Observations 🔥 🦊 🔉 🔍 Apr 15, 2021
@zicklag
Copy link
Author

zicklag commented Apr 15, 2021

Looking at the firefox performance recording it shows "WebRender display list" as the function taking up the vast majority of the frame time:

image

Expanding that more gives us:

image

So it looks like it might not be the game code at all, but actually the painting as done by firefox that is taking forever.

Ah, here's another view that shows that the firefox "WebRender display list" is taking as long to run as the whole of the game code put together for that frame!

image

So maybe this is just a firefox rendering problem. 🤷‍♂️

@NiklasEi
Copy link
Owner

NiklasEi commented Apr 30, 2021

Do you think Bevy getting better at rendering would also help for web builds? Would most improvements be in bevy_render or in bevy_wgpu? In the case of bevy_wgpu, we would need to take a look at bevy_webgl2, right?

@zicklag
Copy link
Author

zicklag commented Apr 30, 2021

I don't know if it's actually Bevy's fault, it might be Firefox's fault. In the screenshot above, The stack of functions on the left shows how long Bevy took to render the frame, but the stack of functions on the right shows that Firefox is taking just as long just to display the frame that is already rendered!

image

So making Bevy render faster might not help because Firefox is still spending way too much time getting the rendered frame to the screen.


That is just my interpretation and I could be wrong. I couldn't figure out where to report this to Firefox so that we might figure out if it's their problem or our problem.

Also, I am using my own custom renderer, not bevy_webgl2. The fact that this is happening with my own very simple renderer ( that runs great on Chrome and desktop BTW ) also makes me feel like this is maybe Firefox's issue and not Bevy's. I'm also using WebGL 1 not WebGL 2 now, but I can't remember if I tested and had the same rendering/audio issues when I was using WebGL 2.


Would most improvements be in bevy_render or in bevy_wgpu?

If you were to do any improvements it would probably be in bevy_webgl2 not bevy_wgpu or bevy_render, I think. If I remember correctly bevy_render has the rendering abstractions, so it doesn't do any actual rendering, it just defines how you control the rendering, and bevy_wgpu and bevy_webgl2 handle doing the actual rending on desktop and web respectively. So if you are trying to fix web rendering performance all of the relevant stuff would be in bevy_webgl2 I think.

@billyb2
Copy link
Contributor

billyb2 commented Aug 6, 2021

Have you tried disabling privacy.resistFingerprinting in about:config ? I heard somewhere that it massively improves canvas performance.

@zicklag
Copy link
Author

zicklag commented Aug 6, 2021

Looks like it's already disabled for me, but it's still got the issue:

image

@djee-ms
Copy link

djee-ms commented Oct 6, 2021

Isn't this simply Firefox reducing framerate on non-focused canvas, like it does for other "background" elements (other non-active tabs, notably)? Sound is choppy for me until I give focus by clicking on the canvas, and then immediately becomes normal. If so there's nothing we can do about that, it's by design. So work around by not trying to play audio until getting keyboard focus.

@zicklag
Copy link
Author

zicklag commented Oct 6, 2021

In my game, I still have audio problems, even when I click on the canvas, so I'm not sure. 🤷‍♂️

@djee-ms
Copy link

djee-ms commented Oct 6, 2021

It may be both at the same time, reduced framerate before first focus, and later game is more demanding so general perf issue?

@zicklag
Copy link
Author

zicklag commented Oct 6, 2021

I am pretty sure it is just general performance issue, actually, so we might as well close this I think.

I'm not sure why the Firefox canvas performance is so bad, but it's not actually the sound causing the problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants