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

Autoloaded scene loses their built-in script when upgrading from 4.3 to 4.4 #103417

Closed
matheusmdx opened this issue Feb 28, 2025 · 3 comments · Fixed by #103439
Closed

Autoloaded scene loses their built-in script when upgrading from 4.3 to 4.4 #103417

matheusmdx opened this issue Feb 28, 2025 · 3 comments · Fixed by #103439

Comments

@matheusmdx
Copy link
Contributor

Tested versions

  • Reproducible: 4.4 beta 4, 4.4 rc 2 and 4.4 rc 3
  • Not Reproducible: 4.4 beta 3

System information

Godot v4.4.rc3 - Windows 10 (build 19045) - Multi-window, 2 monitors - Vulkan (Forward+) - dedicated AMD Radeon RX 580 2048SP (Advanced Micro Devices, Inc.; 31.0.21921.1000) - AMD Ryzen 5 3600 6-Core Processor (12 threads)

Issue description

When i did the upgrade of a project made in 4.3 stable to 4.4 rc 2 after the uid update and restart i noticed a scene that also was an autoload loses the built-in script and was replaced for an empty built-in script.

This is the mrp in 4.3 stable, everything ok:

4.3.ok.mp4

After open in 4,4 rc 2 for the first time and do the restart and upgrade process, the script attached to my autoload scene was empty, the ctrl + left click in BulletManager inside the script doesn't work and ctrl + left click on the function name leads to another script, the function docs tooltip still working.

4.4.after.update.mp4

But if i restart again, the built-in script attached still empty, ctrl + left click in BulletManager inside the script works but now hover or press ctrl while hovering the functon name trigger this error: modules/gdscript/gdscript_editor.cpp:3838 - Condition "!ClassDB::class_exists(class_name)" is true. Returning: ERR_BUG and the doc tooltips doesn't work anymore.

4.4.after.restart.mp4

Bisecting points to pr #102636 as the culprit, CC @amarsero

Image

Steps to reproduce

  1. Download the MRP.
  2. Open in Godot 4.4 beta 4 or higher.
  3. Do the Restart and Upgrade.
  4. After restart, open the BulletManager.tscn and look the script, will be empty.
  5. Ctrl + left click the function name in the Scenes/Player/player.tscn script in line 28, will open a different script from the attached one in the BulletManager.tscn, but this one contain all the data.
  6. Restart again and try do the same as above.

Minimal reproduction project (MRP)

test_project.zip

@amarsero
Copy link
Contributor

amarsero commented Mar 1, 2025

I'll look into it!

@akien-mga akien-mga moved this from Unassessed to Very Bad in 4.x Release Blockers Mar 1, 2025
@Hilderin
Copy link
Contributor

Hilderin commented Mar 1, 2025

Did you find the issue @amarsero ? Just for my curiosity, I was investigating this issue. I'm not 100% certain why the modifications from #102636 afftected this issue but I think the issue is caused because with the modifications, the Player script in the MVP is now valid at the moment of the upgrade, causing the autoload script (BulletManager) to load while loading the Player script during the upgrade process.

In the GDScriptCache::get_shallow_script, the BulletManager script resource (which is an embedded script into the scene) is created but without it's scene unique id.

Image

That causes the save of the bullet_manager.tscn to create a new embedded script with a new id when resaving it in the upgrade process.

I fixed the issue on my side by using the ResourceFormatLoader::CACHE_MODE_REPLACE cache mode to the ResourceLoader::load in UIDUpgradeTool::finish_upgrade:

Ref<Resource> res = ResourceLoader::load(file_path, "", ResourceFormatLoader::CACHE_MODE_REPLACE);

That forces the scene and the script to be reloaded completely from the disk during the upgrade progress.

@amarsero
Copy link
Contributor

amarsero commented Mar 1, 2025

@Hilderin I didn't investigate that far but looks like you've got it.

If you want to open a PR please do so!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Very Bad
Development

Successfully merging a pull request may close this issue.

3 participants