Skip to content

project loading failing with failed loading resource / failed to instantiate scene with cyclic preload #86154

@tlobig

Description

@tlobig

Tested versions

  • Reproducible with 4.2.1 stable

System information

Godot v4.2.1.stable - Windows 10.0.19045 - Vulkan (Forward+) - dedicated NVIDIA GeForce RTX 3080 Laptop GPU (NVIDIA; 31.0.15.4617) - AMD Ryzen 9 5900HX with Radeon Graphics (16 Threads)

Issue description

When opening an affected project it fails to load, for example:

 scene/resources/resource_format_text.cpp:284 - res://a.tscn:6 - Parse Error: 
 Failed loading resource: res://a.tscn. Make sure resources have been imported by opening the project in the editor at least once.

when trying to load the scene from the FileSystem view:

 Failed to instantiate scene state of "res://a.tscn", node count is 0. Make sure the PackedScene resource is valid.
 editor/editor_data.cpp:626 - Index p_idx = 1 is out of bounds (edited_scene.size() = 1).

Only workaround I know: break the cycle in the script. In a larger project where I first found the issue it also helped to close all open scenes and just reload.

Steps to reproduce

minimal steps:

  1. Create a 2D scene A and a 2D scene B
  2. Attach a script a.gd to A's root and a script b.gd to B'
  3. in a add a variable b like this: var b = preload("res://b.tscn")
  4. in b add a variable a like this: var a = preload("res://a.tscn"), which creates a cycle.
  5. safe all scenes (ctrl + s)
  6. from the menu execute Project -> Reload Current Project

Minimal reproduction project (MRP)

project_loading_bug_test.zip

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions