deep-entertainment / issues

Issue tracker for deep Entertainment projects
1 stars 0 forks source link

[EGOVENTURE] Background sound is played after loading a scene w/o background sound #18

Closed ThmsKnz closed 2 years ago

ThmsKnz commented 2 years ago

Describe the bug Note: This bug is not reproducible on all systems. It seems to depend on timing and is might be caused by an issue of Godot's AudioStreamPlayer which under certain conditions continues playing although stop() has been issued.

To Reproduce

  1. Load a savegame that has a current_background = "" set and where the scene that gets loaded has a Boombox.play_background(preload()) in its ready() function.

--> This will cause that 2(!) background sound files get added to Boombox _background_queue Array when loading a game.

  1. Afterwards load a savegame that does not have a background sound.

--> On some systems the background of the scene before might be played.

Potential Reason Stopping the active AudioStreamPlayer after the tween doesn't work on some systems/scenarios. (Maybe this is related to https://github.com/godotengine/godot/issues/37148 ) Therefore both background audio players are playing at the same time after loading a game: one with volume_max the other with volume_min so it can't be noticed.)

However when then loading a savegame without background sound only the active background sound is stopped in function Boombox.reset() which leads to the issue that the background sound of the previous scene is still being played.

Workaround When replacing in boombox.gd in function reset() line active_background.stop() with

    $Background1.stop()
    $Background2.stop()

the issue does no longer occur.

Proposal The Godot bug seems to occur because there are 2 background sounds being added at the same time. Maybe it should get prevented that the _background_queue can have more than one member in the queue.

Note: The same could apply to Boombox music as well.

Versions