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

Engine Randomly Crashing - Logs indicate issue with get_global_position #101921

Closed
Jestus opened this issue Jan 22, 2025 · 8 comments
Closed

Engine Randomly Crashing - Logs indicate issue with get_global_position #101921

Jestus opened this issue Jan 22, 2025 · 8 comments

Comments

@Jestus
Copy link

Jestus commented Jan 22, 2025

Tested versions

Reproducible in 4.3 stable

System information

Godot Engine v4.3.stable.custom_build - https://godotengine.org Vulkan 1.3.289 - Forward+ - Using Device #0: NVIDIA - NVIDIA GeForce RTX 4080 SUPER

Issue description

My game randomly started hard crashing (game window crashes without any error logs within Godot) and I looked up the log file with debug_symbols enabled:

Godot Engine v4.3.stable.custom_build - https://godotengine.org
Vulkan 1.3.289 - Forward+ - Using Device #0: NVIDIA - NVIDIA GeForce RTX 4080 SUPER


================================================================
CrashHandlerException: Program crashed
Engine version: Godot Engine v4.3.stable.custom_build
Dumping the backtrace. Please include this when reporting the bug to the project developer.
[0] Node2D::get_global_position (D:\Dropbox\Coding Projects\godot source\godot-4.3-stable\scene\2d\node_2d.cpp:291)
[1] Node2D::get_global_position (D:\Dropbox\Coding Projects\godot source\godot-4.3-stable\scene\2d\node_2d.cpp:291)
[2] AudioStreamPlayer2D::_update_panning (D:\Dropbox\Coding Projects\godot source\godot-4.3-stable\scene\2d\audio_stream_player_2d.cpp:147)
[3] AudioStreamPlayer2D::_notification (D:\Dropbox\Coding Projects\godot source\godot-4.3-stable\scene\2d\audio_stream_player_2d.cpp:62)
[4] AudioStreamPlayer2D::_notificationv (D:\Dropbox\Coding Projects\godot source\godot-4.3-stable\scene\2d\audio_stream_player_2d.h:43)
[5] Object::notification (D:\Dropbox\Coding Projects\godot source\godot-4.3-stable\core\object\object.cpp:873)
[6] SceneTree::_process_group (D:\Dropbox\Coding Projects\godot source\godot-4.3-stable\scene\main\scene_tree.cpp:954)
[7] SceneTree::_process (D:\Dropbox\Coding Projects\godot source\godot-4.3-stable\scene\main\scene_tree.cpp:1034)
[8] SceneTree::physics_process (D:\Dropbox\Coding Projects\godot source\godot-4.3-stable\scene\main\scene_tree.cpp:491)
[9] Main::iteration (D:\Dropbox\Coding Projects\godot source\godot-4.3-stable\main\main.cpp:4070)
[10] OS_Windows::run (D:\Dropbox\Coding Projects\godot source\godot-4.3-stable\platform\windows\os_windows.cpp:1666)
[11] widechar_main (D:\Dropbox\Coding Projects\godot source\godot-4.3-stable\platform\windows\godot_windows.cpp:181)
[12] _main (D:\Dropbox\Coding Projects\godot source\godot-4.3-stable\platform\windows\godot_windows.cpp:208)
[13] main (D:\Dropbox\Coding Projects\godot source\godot-4.3-stable\platform\windows\godot_windows.cpp:220)
[14] __scrt_common_main_seh (D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288)
[15] <couldn't map PC to fn name>
-- END OF BACKTRACE --
================================================================

It looks like for some reason (from my read) it is crashing when calling get_global_position within audio_stream_player_2d

Any insights on this or previous history of this issue?

Steps to reproduce

Kind of complicated - I've got AI running that hasn't caused any issues until now.

Minimal reproduction project (MRP)

Let me know if I should upload this - I'll have to put together a concise scene.

@AThousandShips
Copy link
Member

Let me know if I should upload this

This absolutely needs a minimal project to make any sense of it, some ability to reproduce this is needed

@Jestus
Copy link
Author

Jestus commented Jan 22, 2025

Gotcha, will put together a MRP now.

@Jestus
Copy link
Author

Jestus commented Jan 22, 2025

Having difficulty isolating this.

Basically, when I create a pure MRP scene to show this off, the bug disappears.

However when I start in another scene and load into the scene in question, the bug re-appears.

I can upload a video if that's allowed, but my best guess right now is that it's an issue with a scene that has been loaded into.

@Jestus
Copy link
Author

Jestus commented Jan 22, 2025

I've narrowed it down further - it appears to be happening as an AudioStreamPlayer2D is being instantiated

@AThousandShips
Copy link
Member

You can upload a video but it won't help much without knowing what goes wrong, a video can only say so much, and the important part is not to show it happens but what might cause it, so a video indicating some idea of that would possibly help, but in the end being able to know how to make this happen is absolutely required (otherwise we can't really solve it, we need to know that it's solved and not just not happening right now)

@Jestus
Copy link
Author

Jestus commented Jan 22, 2025

I have narrowed it down further -

I have this class which in-scene is just a Node2D with child AudioStreamPlayer2D

extends Node2D
class_name ConfigurableSound

@export var destroy_on_finish: bool = true
@export var vary_pitch: bool = true
@export var volume_db: float = 0

@onready var audio_stream_player: AudioStreamPlayer2D = $AudioStreamPlayer2D

# Called when the node enters the scene tree for the first time.
func _ready():
	if destroy_on_finish:
		audio_stream_player.finished.connect(_on_audio_stream_player_2d_finished)

func set_distance(distance: float):
	audio_stream_player.max_distance = distance

func play(stream: AudioStream):
	audio_stream_player.stream = stream
	audio_stream_player.volume_db = volume_db
	if vary_pitch:
		audio_stream_player.pitch_scale = randf_range(0.75, 1.0) # to slightly vary the effect
	
	audio_stream_player.play()

func _on_audio_stream_player_2d_finished():
	get_parent().remove_child(self)
	queue_free()

I instantiate this like this:

func _on_pistol_shoot_ready():
	var proficiency_modified_target = Helpers.get_ranged_weapon_proficiency_modified_shot_location(
		attack_target,
		actor_equipment.equipped_weapon,
		actor_stats,
		global_position)
	fire_shot(proficiency_modified_target)
	
	#var new_configurable_sound: ConfigurableSound = configurable_sound_scene.instantiate()
	#sound_holder.add_child(new_configurable_sound)
	#new_configurable_sound.play(actor_equipment.equipped_weapon.weapon_sound)
	
	actor_sprite.animate(Enums.AnimType.PISTOL_SHOOT_UNREADY, facing_direction)
	broadcast_equipment_anim(Enums.AnimType.PISTOL_SHOOT_UNREADY)

commenting the above shown lines got rid of the issue

is there anything in these lines that stands out as problematic?

@Jestus
Copy link
Author

Jestus commented Jan 23, 2025

I'm thinking it's this - going to run on 4.4 to see if it resolves:
#91123

@Jestus
Copy link
Author

Jestus commented Jan 23, 2025

Unable to reproduce it in 4.4 - looks like that was it. Closing this then, thanks!

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

2 participants