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

Game crashes when AudioStreamPlayer2D plays sound after reloading scene #96506

Closed
JUSTCAMH opened this issue Sep 3, 2024 · 3 comments
Closed

Comments

@JUSTCAMH
Copy link

JUSTCAMH commented Sep 3, 2024

Tested versions

  • Reproducible in 4.3.stable
  • Reproducible in 4.2.1.stable

System information

Godot v4.3.stable - Windows 10.0.19045 - GLES3 (Compatibility) - NVIDIA GeForce RTX 3070 (NVIDIA; 32.0.15.6094) - 11th Gen Intel(R) Core(TM) i7-11700K @ 3.60GHz (16 Threads)

Issue description

A godot game crashes with this fairly specific combination of features:

  • The scene has been reloaded via get_tree().reload_current_scene()
  • A subviewport has its world set to share with the main viewport
  • A sound is played by an AudioStreamPlayer2D
  • Happens occasionally, often after a handful of scene reloads / sounds played

This does not occur if:

  • The scene hasn't first been reloaded.
  • You use an AudioStreamPlayer instead of an AudioStreamPlayer2D
  • If play is never called on the AudioStreamPlayer2D

When the game crashes, there are usually no errors printed to the log, however sometimes before crashing, you get the following error printed multiple times:

E 0:00:03:0399   affine_invert: Condition "det == 0" is true.
  <C++ Source>   core/math/transform_2d.cpp:51 @ affine_invert()

There's some discussion of this bug in the forums here: https://forum.godotengine.org/t/game-crashing-on-audiostreamplayer2d-play/50531

Steps to reproduce

  • Load the MRP below.
  • Enter play mode, press R to reload the scene (the particles are there to show reload working)
  • Press space to play a sound.
  • After pressing R and space for some random number of times, the game will silently crash without printing any error. This sometimes takes a while to crash and sometimes happens quickly, usually within a handful of restarts and many sounds played

Minimal reproduction project (MRP)

audio-crash-bug.zip

@akien-mga
Copy link
Member

akien-mga commented Sep 3, 2024

I didn't reproduce a crash on Linux with 4.4.dev (8120e03) in the MRP, but I did manage to get an error to show up:

Played sound!
Restarted scene!
Played sound!
Restarted scene!
ERROR: Parameter "data.tree" is null.
   at: get_tree (./scene/main/node.h:471)
Restarted scene!
Played sound!
Restarted scene!
Played sound!
Restarted scene!
Played sound!
Restarted scene!
Played sound!
Restarted scene!
ERROR: Parameter "data.tree" is null.
   at: get_tree (./scene/main/node.h:471)

I'm using a dev editor build, this may be a crash in a release export.

Edit: Tried with 4.3.stable release export template on Linux, couldn't reproduce either an error or a crash with maybe a hundred restarts.

@aaronp64
Copy link
Contributor

aaronp64 commented Sep 3, 2024

Reproduced on Windows with stack trace below. Looks like the same issue as #89212, should be fixed by #91123

Engine version: Godot Engine v4.4.dev.custom_build (61598c5c88d95b96811d386cb20d714c35f4c6d7)
Dumping the backtrace. Please include this when reporting the bug to the project developer.
[0] Node2D::get_global_position (C:\dev\godot\scene\2d\node_2d.cpp:291)
[1] AudioStreamPlayer2D::_update_panning (C:\dev\godot\scene\2d\audio_stream_player_2d.cpp:147)
[2] AudioStreamPlayer2D::_notification (C:\dev\godot\scene\2d\audio_stream_player_2d.cpp:62)
[3] AudioStreamPlayer2D::_notificationv (C:\dev\godot\scene\2d\audio_stream_player_2d.h:43)
[4] Object::notification (C:\dev\godot\core\object\object.cpp:876)
[5] SceneTree::_process_group (C:\dev\godot\scene\main\scene_tree.cpp:1012)
[6] SceneTree::_process (C:\dev\godot\scene\main\scene_tree.cpp:1092)
[7] SceneTree::physics_process (C:\dev\godot\scene\main\scene_tree.cpp:537)
[8] Main::iteration (C:\dev\godot\main\main.cpp:4285)
[9] OS_Windows::run (C:\dev\godot\platform\windows\os_windows.cpp:1781)
[10] widechar_main (C:\dev\godot\platform\windows\godot_windows.cpp:181)
[11] _main (C:\dev\godot\platform\windows\godot_windows.cpp:208)
[12] main (C:\dev\godot\platform\windows\godot_windows.cpp:220)
[13] __scrt_common_main_seh (D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288)
[14] <couldn't map PC to fn name>

@akien-mga
Copy link
Member

Thanks! Consolidating in #89212.

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

No branches or pull requests

4 participants