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

File corruption when two scenes call preload on each other #85986

Open
rsutton1 opened this issue Dec 10, 2023 · 1 comment
Open

File corruption when two scenes call preload on each other #85986

rsutton1 opened this issue Dec 10, 2023 · 1 comment

Comments

@rsutton1
Copy link

rsutton1 commented Dec 10, 2023

Tested versions

Reproducible in

In these versions, there is no file corruption but the program behaves unexpectedly

  • 4.1.dev2.official [668cf3c]
  • 4.0.4.stable.official
  • 4.0.stable.official

In this version, there is no file corruption and when attempting to Run the project I receive the following error:

  • 3.6.beta3.official
E 0:00:00.426   load: Resource: 'res://scene_a.tscn' is already being loaded. Cyclic reference?
  <C++ Error>   Condition "!success" is true. Returned: RES()
  <C++ Source>  core/io/resource_loader.cpp:353 @ load()

System information

Godot v4.2.stable - Windows 10.0.19045 - GLES3 (Compatibility) - NVIDIA GeForce RTX 3060 (NVIDIA; 31.0.15.3742) - Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz (8 Threads)

Issue description

Expected Behavior

When two scenes call "preload" on each other, I should be able to exit and reopen the project successfully.

Actual Behavior

When I exit and reload the project, I see the following error message:

godot_bug_scene

It appears I cannot open scene_a anymore.

Steps to reproduce

How to reproduce with MRP

  1. Import and open the project
  2. You should see a pop-up window that says scene_a.tscn is invalid/corrupt:

godot_bug

How I created the MRP

Here are the steps I followed to create the MRP.

  1. Open Godot
  2. Create a scene scene_a.tscn
  3. Create a Node in scene_a
  4. Attach the "scene_a.gd" script to the Node
  5. Create a scene scene_b.tscn
  6. Create a Node in scene_b
  7. Attach the "scene_b.gd" script to the Node

scene_a.gd:

extends Node

func _ready():
	preload("res://scene_b.tscn")

scene_b.gd:

extends Node

func _ready():
	preload("res://scene_a.tscn")

Minimal reproduction project (MRP)

SceneBugMRP.zip

@rsutton1
Copy link
Author

rsutton1 commented Dec 10, 2023

It seems like Godot does not support two scenes loading each other with PackedScene.

If this is the case, I would advise the following:

  1. In Godot 4, don't let the user run the project when trying to do this. (Godot 3 provides an error message and refuses to Run the project).
  2. Update the docs on changing scenes to warn about this (I created a godot-docs issue here: The page on changing scenes should warn about cyclic dependencies godot-docs#8596 )

Because of this issue I lost about ~3 hours scratching my head at the unexpected behavior. When I tried to reload the project, my scene file was corrupted. I would prefer that Godot provide an error message to prevent me from running the unsupported behavior in the first place (and if the docs were up-to-date, I wouldn't have tried to do this at all -- but that's a discussion for the the Issue in godot-docs).

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