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

Deserializing custom resource created through inspector results in parser error #102551

Closed
mihe opened this issue Feb 7, 2025 · 11 comments · Fixed by #102737
Closed

Deserializing custom resource created through inspector results in parser error #102551

mihe opened this issue Feb 7, 2025 · 11 comments · Fixed by #102737

Comments

@mihe
Copy link
Contributor

mihe commented Feb 7, 2025

Tested versions

  • Reproducible in: 4.4.beta3
  • Not reproducible in: 4.3.stable

System information

Godot v4.4.beta3 - Windows 11 (build 26100) - Multi-window, 3 monitors - Vulkan (Forward+) - dedicated NVIDIA GeForce RTX 4070 Laptop GPU (NVIDIA; 32.0.15.6636) - AMD Ryzen 9 7940HS w/ Radeon 780M Graphics (16 threads)

Issue description

When doing bytes_to_var_with_objects(var_to_bytes_with_objects(some_custom_resource)) where some_custom_resource was specifically created through the editor inspector, and not through something like MyResource.new(), you end up with a debugger break saying:

Parser Error: Class "MyResource" hides a global script class.

The exact same setup seemingly worked in 4.3-stable.

Steps to reproduce

  1. Open the MRP.
  2. Run the main scene.
  3. Note error.

Minimal reproduction project (MRP)

resource-serialization-error.zip

@mihe mihe added this to the 4.4 milestone Feb 7, 2025
@akien-mga akien-mga moved this from Unassessed to Release Blocker in 4.x Release Blockers Feb 7, 2025
@AThousandShips
Copy link
Member

Can confirm, but happens for me in 4.3.stable and even in 4.2.2.stable, at least in my testing using the MRP

@mihe
Copy link
Contributor Author

mihe commented Feb 7, 2025

If you recreate that same setup in 4.3 (i.e. don't use the MRP project) the error won't show.

It might be related to the metadata/_custom_type_script property added to the sub_resource as of 4.4.

I was planning on providing a 4.3-stable MRP instead, but there's some other strange issue happening in the upgrade process (that I need to report as well) which forced me to provide a 4.4 repro instead.

@AThousandShips
Copy link
Member

AThousandShips commented Feb 7, 2025

That makes sense when clarified!

With this added information I can pinpoint it as being introduced between dev3 and dev4

@mihe
Copy link
Contributor Author

mihe commented Feb 7, 2025

I just realized I could have just provided two MRPs in the first place, so here's one for 4.3, with no error: resource-serialization-error-4.3.zip

@AThousandShips
Copy link
Member

Will bisect now that I know the span

@KoBeWi
Copy link
Member

KoBeWi commented Feb 7, 2025

bytes_to_var_with_objects will for some reason embed resources instead of referencing them. Custom type resources have hidden _custom_type_script metadata, which gets duplicated. The same would happen if you export a variable of type Script.

To fix it there needs to be an exception, similar to #100177.
Though a more comprehensive fix would be changing _custom_type_script to String. It would fix all duplication problems.

@KoBeWi

This comment has been minimized.

@ShrigmaDev
Copy link

@KoBeWi Hi, still running into this issue in 4.4 rc1. Tried deleting .godot folder, and the custom resource file itself and then recreating it, and the issue still persists... The project was created in 4.3 stable, is there anything I need to "reset" in order to fix this?

@KoBeWi
Copy link
Member

KoBeWi commented Feb 24, 2025

It should be gone after you re-save the problematic scene. Check inside tscn if _custom_type_script meta is a String.

@ShrigmaDev
Copy link

ShrigmaDev commented Feb 25, 2025

It should be gone after you re-save the problematic scene. Check inside tscn if _custom_type_script meta is a String.

@KoBeWi My setup is slightly different but I've managed to create an MRP in #103271. The difference is the resource contains a PackedScene that defines a custom class, but also results in the same error as this one.

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

Successfully merging a pull request may close this issue.

4 participants