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

Sub resource indices are shuffled when saving packed scenes in game, causing random missing resources on load #49622

Closed
pouleyKetchoupp opened this issue Jun 15, 2021 · 0 comments · Fixed by #49624
Milestone

Comments

@pouleyKetchoupp
Copy link
Contributor

pouleyKetchoupp commented Jun 15, 2021

Godot version

3.3.2.stable, 4.0.dev (0818a46)

System information

Windows 10

Issue description

Context:
We're using packed scenes in a game as a way to save the current state for different parts of the game world. But sometimes resources randomly disappear (meshes, collision shapes, materials).

Issue:
It appears that sometimes when saving packed scenes, sub-resources indices are saved in a different order and the resource cache doesn't reflect the change well. So when loading the same scene again (in the same session), some resources can be swapped, leading to missing resources (when a resource of the wrong type is assigned to a mesh, it just silently disappears).

I wasn't able to reproduce the missing resources in a minimal project, but I've reproduced a scenario that leads to shuffled sub resources in a saved packed scene. The missing resources can probably happen only in more complex nested scenes.

Steps to reproduce

Using the minimal repro project:

  1. Run the game. Scene 1 is loaded by default.
  2. Press 2 to save scene 1 and load scene 2.
  3. Press 1 to save scene 2 and load scene 1 again. Keep the game running.
  4. Open the saved Scene2 in [user_data]/Godot/app_userdata/Missing-sub-resource/saves/Scene2.tscn
  5. Observe the order of sub resource indices.
  6. With the game still running from the last session, press 2 to save scene 1 and load scene 2.
  7. Press 1 to save scene 2 and load scene 1 again.
  8. Checked the saved Scene2 in [user_data]/Godot/app_userdata/Missing-sub-resource/saves/Scene2.tscn
  9. Observe the order of sub resource indices has changed.

In order to reset the saves and start the repro again, you need to run the game and press R to delete all the saved scenes, otherwise the issue doesn't happen again.

Minimal reproduction project

3.x project:
missing-sub-resource.zip

4.0 project:
missing-sub-resource-4.0.zip

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants