godot icon indicating copy to clipboard operation
godot copied to clipboard

Circular dependency causes resources to be missing on export

Open RobertSzaszak opened this issue 1 year ago • 35 comments

Godot version

4.0 Stable

System information

Windows 10

Issue description

When exporting the project as a Windows executable, the application throws the following error.

Make sure resources have been imported by opening the project in the editor at least once.

Steps to reproduce

Export project as Windows Desktop (Runnable) Run the application.

Minimal reproduction project

N/A

RobertSzaszak avatar May 12 '23 16:05 RobertSzaszak

Same error when running the project from the editor in version 4.02.

Make sure resources have been imported by opening the project in the editor at least once.
  <C++ Error>    Condition "found" is true. Returning: Ref<Resource>()
  <C++ Source>   core/io/resource_loader.cpp:222 @ _load()`

RobertSzaszak avatar May 12 '23 16:05 RobertSzaszak

My experience with this bug was exporting from Mac/Linux. Exports from Windows always worked for some reason.

Issue resolved randomly after a couple days. I tried reimporting objects that were error’d, but no luck. I also tried restarting Godot, re cloning my repo, restarting my pc, building from a Github Actions pipeline, and a couple other things. Builds just only worked on Windows.

I tried Godot 4.01, 4.02, and 4.1.dev1 — none of them fixed the issue. No idea how it resolved.

hunterkepley avatar May 12 '23 17:05 hunterkepley

To add on, my game could export from all 4 ways described in my first comment originally, then it stopped working one day out of nowhere..

hunterkepley avatar May 12 '23 17:05 hunterkepley

@RobertSzaszak @hunterkepley Please upload a minimal reproduction project to make this easier to troubleshoot.

Calinou avatar May 12 '23 17:05 Calinou

I will look through my commits to find one, but it'll take some time

hunterkepley avatar May 13 '23 01:05 hunterkepley

@Calinou Hi, How do I upload a minimal reproduction project? My game is quite big already. Shall I try to make it smaller and create a new repo for it? The issue seems to be with the load_threaded request function in my case.

RobertSzaszak avatar May 16 '23 18:05 RobertSzaszak

Minimal project is literally what it says. Create the smallest project you can that has the problem.

Zireael07 avatar May 16 '23 18:05 Zireael07

I am unable to recreate this issue with a project, it seems to happen at random. Currently my project is unable to build on OSX, but builds work from my automated pipeline on GitHub (linux) and my windows desktop. This was not the case last week.

I could provide my game with a lot of the code removed, if that would suffice, it just wouldn't be "minimal".

hunterkepley avatar May 21 '23 03:05 hunterkepley

~~reu broken for github.zip~~ Moderator edit: Link removed for security, as the MRP contains secret credentials.

I removed all of the important code from my game such as rollback, server reconciliation, etc. As well as skipped the lobby and removed proprietary models I own

I have, however, included the export presets

All you need to do is export from OSX, (try a .dmg on a Mac first) start the game, press "Host" on the bottom left, and it should have a grey screen and spit out a ton of errors if ran from a terminal

Hope this helps

hunterkepley avatar May 21 '23 03:05 hunterkepley

Seems like it works in version 4.0.3. You can close the issue.

RobertSzaszak avatar May 21 '23 18:05 RobertSzaszak

   at: load (core/io/resource_format_binary.cpp:696)
ERROR: Failed loading resource: res://.godot/exported/133200997/export-ac4b7ec5c7c6a50838ddcd1f4e057820-candy_placer.scn. Make sure resources have been imported by opening the project in the editor at least once.
   at: _load (core/io/resource_loader.cpp:223)
ERROR: Can't load dependency: res://game/objects/candy_placer.tscn.
   at: load (core/io/resource_format_binary.cpp:696)
ERROR: Failed loading resource: res://.godot/exported/133200997/export-ccb27609e01d6460664dd431ed388159-bedroom.scn. Make sure resources have been imported by opening the project in the editor at least once.
   at: _load (core/io/resource_loader.cpp:223)
ERROR: Can't load dependency: res://game/levels/bedroom/bedroom.tscn.
   at: load (core/io/resource_format_binary.cpp:696)
ERROR: Failed loading resource: res://.godot/exported/133200997/export-be6198c9d492642daf2a2b8a18326593-bedroom_level.scn. Make sure resources have been imported by opening the project in the editor at least once.
   at: _load (core/io/resource_loader.cpp:223)

Still exists for me, please do not close

hunterkepley avatar May 22 '23 02:05 hunterkepley

reu broken for github.zip

MRP without credentials in it

hunterkepley avatar May 22 '23 23:05 hunterkepley

Hopefully this can be fixed soon, I am currently having to work on the game on my MacBook, then export from my windows desktop to linux and Mac, then upload that to AWS/my MacBook :(

hunterkepley avatar May 22 '23 23:05 hunterkepley

This could be due to a similar cause as https://github.com/godotengine/godot/issues/55711, or due to texture compression project settings if this is a 3D project that uses VRAM compression for any textures (as is done by default).

Calinou avatar May 23 '23 10:05 Calinou

Happening in my scene as well. Several materials referenced by .GLTFs are not able to be parsed because the textures can't be loaded. This results in entire meshes not loading because they can't find the textures to load on the materials I've linked in the .gltf importer.

E 0:00:11:0282 _parse_ext_resource: res://Resources/Characters/Guard/guard upper.tres:6 - Parse Error: [ext_resource] referenced nonexistent resource at: res://Resources/Characters/Guard/guard_packed1_diffuse_r1.png <C++ Source> scene/resources/resource_format_text.cpp:162 @ _parse_ext_resource()

E 0:00:11:0282 load: res://Resources/Characters/Guard/guard upper.tres:6 - Parse Error: [ext_resource] referenced nonexistent resource at: res://Resources/Characters/Guard/guard_packed1_diffuse_r1.png <C++ Source> scene/resources/resource_format_text.cpp:735 @ load()

The this happens specifically if I use the ResourceLoader.load_threaded_request command. I do this so I can have a loading bar. Also, it's not 100% consistent - sometimes textures do load, and for almost all my models, this isn't an issue, but for some big ones it is. No amount of re-importing, renaming, or changing whether it's loaded into VRAM seems to make a difference

cosmoddd avatar May 31 '23 02:05 cosmoddd

yes, i should add, this all started after i moved all my files one by one using Godot's "Move To" functionality

ever since, no number of changes, reimports, etc has fixed the issue.

also my game is 3D

hunterkepley avatar Jun 01 '23 15:06 hunterkepley

v 4.0.3 I have this problem too. My case is some of the code gen xxx.tscn file can not load while this line of code in Android: load("res://.godot/exported/xxx/export-yyy-zzz.scn").instantiate()

error info: _load: Failed loading resource: Make sure resources have been imported by opening the project in the editor at least once.

ZhuangXiongfei avatar Jun 06 '23 07:06 ZhuangXiongfei

My case is some of the code gen xxx.tscn file can not load while this line of code in Android: load("res://.godot/exported/xxx/export-yyy-zzz.scn").instantiate()

You should not load() files directly in the res://.godot/ folder, as the structure will change when the project is exported.

Calinou avatar Jun 06 '23 09:06 Calinou

I was able to trace my issue and potentially solve it:

After troubleshooting, I found my version of the error occurred only with specific image files that were shared by multiple materials. For example, Guard_BLUE and Guard_RED both use the same texture in their materials: guard_packed1_diffuse_r1.png. When objects using or sharing those materials are loaded using ResourceLoader.load_threaded_request, the error is thrown. It even causes the mesh in question to disappear from the scene.

Reading in the docs, a particular piece of information became apparent - if a resource is already loaded, Godot will not load it again. So what I ended up doing was this:

  1. Use the Debug panel to trace where the offending texture is. In my case, it was guard_packed1_diffuse_r1.png.
  2. Right click on the texture and click "View Owners." This will show which materials and which scenes were using it.
  3. Find the texture in the Scene and right click -> "Make Unique." This makes a unique version of the texture that shouldn't conflict with the texture already loaded. Alternatively, you can reimport the object with NO embedded images and manually assign materials in Godot.
  4. If you can't find the texture or have a huge scene, I was able to find it by opening up the scene in text format in VsCode and searching via a string match.

This seems to have resolved my issues with this error. It may not apply to many of you, but it's useful information to know that resources, particularly textures, CANNOT be loaded more than once in a scene, unless explicitly marked to do so by making them "Unique". My suggestion would be to make this information part of the warning / error message, so users can know where and how to troubleshoot this.

cosmoddd avatar Jun 06 '23 14:06 cosmoddd

My case is some of the code gen xxx.tscn file can not load while this line of code in Android: load("res://.godot/exported/xxx/export-yyy-zzz.scn").instantiate()

You should not load() files directly in the res://.godot/ folder, as the structure will change when the project is exported.

I read this path in the apk/assets/xxx.tscn.remap file

ZhuangXiongfei avatar Jun 16 '23 03:06 ZhuangXiongfei

For what it's worth I worked through this issue with my project.

The errors were pointing to the script property attached to the root node:

In game.tscn

[node name="Game" type="Node2D"]
script = ExtResource("1_3emra")

I removed the script = ... line, and then further above I removed the line with the matching id: Also in game.tscn

[ext_resource type="Script" path="res://scripts/game.gd" id="1_3emra"]

After that I was able to load the scene, and the script was not attached. I was able to add it back, generating a new id and everything seems to work again. Hope this is helpful!

mddizon avatar Jul 09 '23 04:07 mddizon

I am currently finding these errors in a project coming over from 4.0.x versions of it. I did a fully new project import yet somehow these errors appeared in 4.1.x versions of Godot. If I have helpful information on probable causes of this problem I will report here.

infohub-gather avatar Sep 01 '23 13:09 infohub-gather

Good morning everyone. I'm having the same issue of @RobertSzaszak I have made a very basic 2d Top-Down game where there are 7 scenes.

  • One for the player
  • One for the end screen scene
  • Five for the levels.

Yesterday I was working on game without any issue but this morning I'm having this issue.

The version of Godot I'm using is Stable 4.1.1.

@Calinou

Please upload a minimal reproduction project to make this easier to troubleshoot.

It is ok to link to my repository since I have published it?

SimoneStarace avatar Sep 17 '23 08:09 SimoneStarace

After digging for an hour on understanding why I was receiving this error on my project, the reason was in one of the scenes there was a weirdly missing reference to another scene.

In short my game is structured as follow:

  • On each level, once the player reaches the goal, the next scene is loaded.
  • In the last scene I have added a button that, when clicked, it brings the player to restart playing from the first level. This is where I was getting the error Make sure resources have been imported by opening the project in the editor at least once because, for some reason, Godot wasn't able to find the first scene.

To solve the problem I had to modify the scene file, manually by removing the missing reference of the scene. Now all the scenes are loaded normally without issues.

Probably, this might not be the answer for Robert but it seems that this issue depends on how files are handled.

SimoneStarace avatar Sep 17 '23 09:09 SimoneStarace

Similar issue happened to my project. (Using Godot 4.1.1.stable.mono)

I have "sceneA", which has a script with an [Export] reference to "sceneB". Similarly, "sceneB" also has a script with a reference to "sceneA". This relationship caused the issue for me, but I don't know if it's the only thing that does.

On reloading of the project, such relationship breaks every scenes it was involved in, causing the error as in the original post. Furthermore, if other scenes have any reference (either by script, or nested in the tree) to scenes broken this way, those will break too. This has caused all but one of my scenes to break.

I managed to resolve it by editing the .tscn files and removing all PackedScene references, but I'm afraid to move forward with the project since the same thing could happen again anytime, in a bigger scale, and I wouldn't be able to notice it until the project is reloaded and everything breaks.

Av0c avatar Sep 29 '23 01:09 Av0c

Similar issue happened to my project. (Using Godot 4.1.1.stable.mono)

I have "sceneA", which has a script with an [Export] reference to "sceneB". Similarly, "sceneB" also has a script with a reference to "sceneA". This relationship caused the issue for me, but I don't know if it's the only thing that does.

On reloading of the project, such relationship breaks every scenes it was involved in, causing the error as in the original post. Furthermore, if other scenes have any reference (either by script, or nested in the tree) to scenes broken this way, those will break too. This has caused all but one of my scenes to break.

I managed to resolve it by editing the .tscn files and removing all PackedScene references, but I'm afraid to move forward with the project since the same thing could happen again anytime, in a bigger scale, and I wouldn't be able to notice it until the project is reloaded and everything breaks.

I've got exactly the same issue with a similar case where I use TP point to load a new map. For my test the A map tp to B and the B to A. My A scene was causing the trouble. I'm using @export too with PackedScene as type. Edit: with godot 4.1.1 as well.

aurumboros avatar Oct 03 '23 23:10 aurumboros

I've got exactly the same issue with a similar case where I use TP point to load a new map. For my test the A map tp to B and the B to A. My A scene was causing the trouble. I'm using @export too with PackedScene as type. Edit: with godot 4.1.1 as well.

@aurumboros TP stands for? Anyway which node are you using for loading the levels because to me it was a problem with the node I used for loading the next level.

SimoneStarace avatar Oct 08 '23 21:10 SimoneStarace

I've got exactly the same issue with a similar case where I use TP point to load a new map. For my test the A map tp to B and the B to A. My A scene was causing the trouble. I'm using @export too with PackedScene as type. Edit: with godot 4.1.1 as well.

@aurumboros TP stands for? Anyway which node are you using for loading the levels because to me it was a problem with the node I used for loading the next level.

Sry, TP stands for "Teleport". To solve the issue -> I used a global dictionnary with some enums and the path to the scenes I want. I load the scene only when needed and it solves the issue.

In my previous setup, a "TP node" from a "scene A" referenced "scene B" thanks to @export Packed Scene with some coordinates to load the scene and teleport the player. Then in the "scene B" a node has a reference of the "scene A" with coordinates too. And the reference from A -> B and B -> A break the scenes until you remove the reference in the .tscn

aurumboros avatar Oct 09 '23 08:10 aurumboros

I'm also experiencing this issue, Godot 4.1.2. When:

godot4 --headless --export-release "Linux/X11" $out/bin/tank

Error:

ERROR: res://scenes/components/health_component.tscn:6 - Parse Error: at: _parse_node_tag (scene/resources/resource_format_text.cpp:283) ERROR: Failed loading resource: res://scenes/components/health_component.tscn. Make sure resources have been imported by opening the project in the editor at least once. at: _load (core/io/resource_loader.cpp:273)

Reference also points to script. By removing script, error is gone. But I need the script...

Contents of health_component.tscn (which references script):

[gd_scene load_steps=2 format=3 uid="uid://dax2x4s2u7l4v"] [ext_resource type="Script" path="res://scenes/components/health_component.gd" id="1_yvfi3"] [node name="HealthComponent" type="Node"] script = ExtResource("1_yvfi3")

I understand that this problem has to be replicated in a discrete project and isolated. [Will attempt to do so.]

superherointj avatar Oct 09 '23 11:10 superherointj

I've experienced this issue and have been able to semi-reliably recreate the error and recover from it. Replication project here

Chemiseblanc avatar Oct 10 '23 17:10 Chemiseblanc