Sounds playing or stopped just before quitting leak their AudioStreamPlayback at exit
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 48/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- cpp
- Ambito
- audio-video-rtc, game-dev
Direzione di ricerca
Read AudioServer::playback_list and AudioServer::finish(), then trace shutdown ordering in Main::cleanup() to understand when playback classes are still available. Reproduce with the provided MRP using the Dummy driver and a run that quits while audio is playing. Done means shutdown frees the remaining playbacks and the reported leak no longer occurs; the issue describes an available fix and unit test, so review that change for the expected test location.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Tested versions
- Reproducible in: v26.3.stable.official [85e520394]
- Also reproducible in an unmodified local build of the same commit.
- Upstream Godot master has the same code, so it is probably affected too. I have not tested it.
System information
Windows 10 Pro 22H2 (build 19045), x86-64. Reproduced headless with the Dummy audio driver, and with WASAPI with the Master bus muted. The GPU and renderer are not involved.
Issue description
If a sound is still playing when the game quits, the engine prints:
WARNING: ObjectDB instances leaked at exit (run with --verbose for details).
The leaked objects are the AudioStreamPlayback and its AudioStream. With a local patch to list them, they were an AudioStreamPlaybackWAV and an AudioStreamWAV. A plain --verbose run lists nothing on 26.3, because ObjectDB::cleanup() skips some blocks when it lists leaks; that is a separate problem.
When it happens. In ordinary situations:
- quitting with
get_tree().quit()while music is playing; - calling
stop()on a player in the same frame as quitting; - every bounded
--quit-afterrun that ends while a sound plays. A script cannot stop its sounds first in that case, because the engine ends the main loop directly.
Workaround. Games have to stop every player and wait a few frames (about 0.25 s) before quitting.
Cause. A playback leaves AudioServer::playback_list in two steps:
- the audio thread marks it for deletion after its fade-out;
AudioServer::update()frees it on the main thread.
At shutdown, neither step may run again, and nothing else empties the list. AudioServer::finish() only stops the drivers and deletes the buses. The SafeList destructor frees nodes that were already erased, but not nodes that are still in the list. With a real driver, the "stop then quit" case usually escapes, because the audio thread manages one more mix in time. With the Dummy driver it leaks every time.
Fix available. dominicbytes/redot-engine#9 (single commit b8fc04d, against 26.3-stable):
- adds
AudioServer::free_playbacks(), which frees every playback left in the list with the audio driver locked; - calls it from
Main::cleanup()right after the script languages finish, before the modules and GDExtensions that provide playback classes are uninitialized; - adds a unit test.
| Ending | Official 26.3-stable | With the fix |
|---|---|---|
Still playing, run ends by --quit-after 60 |
5 of 5 runs leak | 0 of 20 |
Still playing, get_tree().quit() |
5 of 5 | 0 of 20 |
stop() then get_tree().quit() in the same frame |
5 of 5 | 0 of 20 |
stop(), wait 0.25 s, then quit |
0 of 5 | 0 of 10 |
The full unit-test suite passes with the fix, 1347 of 1347.
Steps to reproduce
- Create the MRP below.
- Import it once:
redot --headless --path <mrp> --import. - Run any of these and look for the ObjectDB warning at exit:
redot --headless --audio-driver Dummy --path <mrp> --quit-after 60 -- --mode=playredot --headless --audio-driver Dummy --path <mrp> -- --mode=play-quitredot --headless --audio-driver Dummy --path <mrp> -- --mode=stop-quit
- As a control,
-- --mode=stop-waitexits cleanly.
To hear nothing with a real driver, use --audio-driver WASAPI and add --mute after --.
Minimal reproduction project (MRP)
Bugsquad edit:
audio-playback-shutdown-leak-mrp.zip
- Lingua principale
- C++
- Stelle
- 6.1k
- Fork
- 337
- Merge medio
- 5g 8h
- PR unite (30g)
- 13
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di Redot-Engine/redot-engine
-
C#] [Export] does not support struct types (GD0102), inconsistent with GDScript struct supportApertaenhancement topic:dotnet usability
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
Redot-Engine/redot-engine#1589 ·
I maintainer di solito rispondono entro 1 giorno
-
Trait is not being resolvedApertabug topic:gdscript
Difficoltà 3/5 1-2 giorni Idoneità per principianti 48/100
Redot-Engine/redot-engine#1588 ·
I maintainer di solito rispondono entro 1 giorno
-
Handle stateful audio effects when a bus channel becomes inactiveForse già presa @GeneralProtectionFault l’ha presa 27 giorni fa. Aperta
Redot-Engine/redot-engine#1584 · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
-
bug usability
Difficoltà 3/5 1-2 giorni Idoneità per principianti 53/100
Redot-Engine/redot-engine#1583 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
bug confirmed topic:3d topic:rendering
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
Redot-Engine/redot-engine#1568 ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di Redot-Engine/redot-engine
Issue simili
-
Make the HTTP server's keep-alive and headers timeouts configurableForse già presa @mattgodbolt l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
compiler-explorer/compiler-explorer#9902 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
Nixtla/statsforecast#1371 ·
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
[Bug]: pip install -U cudaq-qec fails with a conflict that names cudaq-qec itselfForse già presa @fedonman l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 1 giorno
-
task
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
SparseLinearAlgebra/spla#316 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno