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

Playing many audio samples causes ever increasing cpu usage in web export #102505

Closed
mooflu opened this issue Feb 7, 2025 · 3 comments · Fixed by #102715
Closed

Playing many audio samples causes ever increasing cpu usage in web export #102505

mooflu opened this issue Feb 7, 2025 · 3 comments · Fixed by #102715

Comments

@mooflu
Copy link

mooflu commented Feb 7, 2025

Tested versions

v4.4.beta2.official [a013481]

System information

Godot v4.4.beta2 - Windows 11 (build 26100) - Multi-window, 2 monitors - OpenGL 3 (Compatibility) - NVIDIA GeForce RTX 2070 SUPER (NVIDIA; 32.0.15.6636) - 13th Gen Intel(R) Core(TM) i7-13700KF (24 threads)

Issue description

In web export of my game after playing for a while, the audio starts to crackle. I think I narrowed it down to playing lots of audio samples over time. Even thought the audio samples are short and finish quickly, the cpu usage goes up over time and does not come back down.

Steps to reproduce

I've attached a simple project that plays 100 audio samples each time the 'play' button is pressed.

Export MRP as a no-thread web app. Open in Chrome or Firefox and open the browser's task manager.
Find WebAudioTest task and note CPU usage (starts low - a few % on my computer)
Click the play button a bunch of times. CPU starts increasing and doesn't drop again.
Eventually CPU usage becomes so high that audio starts to crackle as well.

MRP also includes a short python script to start a local server:
D:...\webaudiotest>python server.py

Minimal reproduction project (MRP)

webaudiotest.zip

@mooflu
Copy link
Author

mooflu commented Feb 7, 2025

Poked around a bit and I think the root cause it that GodotPositionReportingProcessor.process always returns true and is forced to remain active and keeps processing (no data) even after the sample has finished playing.

See comment here: https://github.com/godotengine/godot/pull/102163/files#r1945897924

@adamscott
Copy link
Member

@mooflu Could you test my PR? I think it solves the issue.

@mooflu
Copy link
Author

mooflu commented Feb 12, 2025

Yes, works great. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment