#Godot Debug is sometimes crashing when trying to swap to an intro scene (control scene / text based)

15 messages · Page 1 of 1 (latest)

floral sparrow
#

Godot 4.3. GD script. Godot Debug is sometimes crashing when trying to swap to an intro scene (control scene). Just on the off chance that someone else has experienced this and might know how to resolve it;

I'm running a main menu scene (control node); that is trying to launch an intro scene (another control node scene); when the player presses "new game".

about 25% of the time; the debug freezes when the intro scene is trying to start; it will freeze; try to bring up the first line of text (the intro to the game text); then it will just stop; and crash; and the debug will just close.

It doesn't give any errors in the debugger at all. So im finding it difficult to debug why this is happening. I should mention there are a few auto load global scripts firing at this point upon pressing "start new game".

If i run the main menu into something else such as level 1, level select scene, or world select scene; then it does not crash; and it works perfectly 100% of the time.

So the crash seems to only occur in text based scenes such as the intro scene; and it also happens on the game over scene; when player dies; and text tries to come up on the screen; it also does the same thing.

I have been trying all sorts for 2 days. With no luck. Tried preloading the intro via the main menu. doesn't work. tried creating a fake player node within the intro to trick the global auto loads into thinking a player is there. does not work.

tried putting a few await process frames to try and give the engine some breathing room. does not work.

So; im in a situation; where i cant really run any text scenes like intro, game over, credits, ending scenes without a 25% chance that the whole game will just freeze and crash.

I've even had a look through the godot logs in the AppData folder on the C drive. still cant seem to find anything that might help me.

So I'm praying that someone might have seen this before; and can possibly shed some light on it. Thank you. Now I pray. 🙏

south igloo
#

Can you try loading an empty control node and see it crashes too

floral sparrow
#

Even just a node. Getting it to go to a node. Just a blank node scene. It still crashes on that too. only 25% of the time. 🙃

south igloo
floral sparrow
#
# this is a var up the top of the script
var intro_scene = preload("res://scenes/cutscenes/defense_for_intro.tscn") # This is a preloaded intro scene


# === START NEW GAME ===
func _on_new_game_pressed():
    if is_transitioning:
        return

    print("[MainMenu] ✅ Starting new game")
    is_transitioning = true
    confirm_pressed.play()

    # ✅ Reset state and load into WorldSelect
    SaverLoader.reset_game_state()
    HealthManager.start_new_game() # Resets Player health and lives and apples to defaults
    
    await get_tree().create_timer(1.0).timeout # This is for the confirm SFX to play out
    
    await get_tree().process_frame # Give a frame to settle #1
    await get_tree().process_frame # Give a frame to settle #2
    await get_tree().process_frame # Give a frame to settle #3
    await get_tree().process_frame # Give a frame to settle #4
    await get_tree().process_frame # Give a frame to settle #5
    await get_tree().process_frame # Give a frame to settle #6
    
    # === Instantiate the preloaded scene
    var instance := intro_scene.instantiate()
    
    # === Safely replace current scene with intro
    var tree := get_tree()
    var root := tree.root
    var current_scene := tree.current_scene
    
    root.add_child(instance)
    tree.current_scene = instance

    call_deferred("queue_free")```
#

I have tested a debug message inside of the blank node scene and it is indeed printing the debug in the ready of the blank node scene; and then still even crashing after the debug is printed;


func _ready():
    print("[READY] BlankScene initialized")

func _enter_tree():
    print("[ENTER_TREE] BlankScene entered")
south igloo
#

Maybe you should try using get_tree().change_scene_to_packed(instance) to change the scene instead

#

Unless this was tried already

#

@floral sparrow

floral sparrow
#

i will need to give it about 30 tests. as usually it has been crashing at least 1 in 30. so i am trying that now. 🙂

#

also; not sure if this is significant or not; but; what i am noticing is;

Say for example i am on the menu menu screen for a split second; and really quickly press "new game", it then takes about 1 to 2 seconds; for the debug text to kind of get its bearings and pop up in the debugger, on the next scene load; the blank test scene / the blank node scene.

But; in contrast to that; if i stay on the main menu for 2 seconds, on purpose; and THEN press "new game"; the debug text pops up almost instantly upon going to the next scene / the blank node scene.

So there is a subtle difference there in the time it takes for the debug text messages to catch up.

no clue if this will have any impact at all; but; worth mentioning.

floral sparrow
# south igloo Maybe you should try using get_tree().change_scene_to_packed(instance) to change...

it has crashed again on the 10th attempt. 😦 Using change scene to packed. Hmmm. Thank you for the suggestion though.

I will continue to try and debug this.

func _on_new_game_pressed():
    if is_transitioning:
        return

    print("[MainMenu] ✅ Starting new game")
    is_transitioning = true
    confirm_pressed.play()

    # ✅ Reset state and load into WorldSelect
    SaverLoader.reset_game_state()
    HealthManager.start_new_game() # Resets Player health and lives and apples to defaults
    
    await get_tree().create_timer(1.0).timeout # This is for the confirm SFX to play out
    
    await get_tree().process_frame # Give a frame to settle #1
    await get_tree().process_frame # Give a frame to settle #2
    await get_tree().process_frame # Give a frame to settle #3
    await get_tree().process_frame # Give a frame to settle #4
    await get_tree().process_frame # Give a frame to settle #5
    await get_tree().process_frame # Give a frame to settle #6
    
    # === Safely replace current scene with intro
    get_tree().change_scene_to_packed(intro_scene)```