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

Fix GLTF scene dependencies and make full scene renders predictable #10745

Merged
merged 4 commits into from
Nov 27, 2023

Conversation

cart
Copy link
Member

@cart cart commented Nov 26, 2023

Objective

Fixes #10688

There were a number of issues at play:

  1. The GLTF loader was not registering Scene dependencies properly. They were being registered at the root instead of on the scene assets. This made LoadedWithDependencies fire immediately on load.
  2. Recursive labeled assets inside of labeled assets were not being loaded. This only became relevant for scenes after fixing (1) because we now add labeled assets to the nested scene LoadContext instead of the root load context. I'm surprised nobody has hit this yet. I'm glad I caught it before somebody hit it.
  3. Accessing "loaded with dependencies" state on the Asset Server is boilerplatey + error prone (because you need to manually query two states).

Solution

  1. In GltfLoader, use a nested LoadContext for scenes and load dependencies through that context.
  2. In the AssetServer, load labeled assets recursively.
  3. Added a simple asset_server.is_loaded_with_dependencies(id)

I also added some docs to LoadContext to help prevent this problem in the future.


Changelog

  • Added AssetServer::is_loaded_with_dependencies
  • Fixed GLTF Scene dependencies
  • Fixed nested labeled assets not being loaded

@cart cart added the A-Assets Load files from disk to use for things like images, models, and sounds label Nov 26, 2023
@cart cart added this to the 0.12.1 milestone Nov 26, 2023
@alice-i-cecile alice-i-cecile added the C-Bug An unexpected or incorrect behavior label Nov 26, 2023
Copy link
Contributor

@djeedai djeedai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, but any chance we add tests for some of these things so they don't regress in the future?

@@ -711,6 +711,13 @@ impl AssetServer {
.unwrap_or(RecursiveDependencyLoadState::NotLoaded)
}

/// Returns true if the asset and all of its dependencies (recursive) have been loaded.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be worth linking to this from the standard is_loaded method.

@alice-i-cecile alice-i-cecile added the S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it label Nov 26, 2023
@cart
Copy link
Member Author

cart commented Nov 27, 2023

Looks good, but any chance we add tests for some of these things so they don't regress in the future?

I'm on board for more tests, but that will require engineering effort that would otherwise delay 0.12.1 so I'm not going to block on that.

@cart cart enabled auto-merge November 27, 2023 22:31
@cart cart added this pull request to the merge queue Nov 27, 2023
Merged via the queue into bevyengine:main with commit cc6c4d6 Nov 27, 2023
22 checks passed
cart added a commit that referenced this pull request Nov 30, 2023
…10745)

# Objective

Fixes #10688

There were a number of issues at play:

1. The GLTF loader was not registering Scene dependencies properly. They
were being registered at the root instead of on the scene assets. This
made `LoadedWithDependencies` fire immediately on load.
2. Recursive labeled assets _inside_ of labeled assets were not being
loaded. This only became relevant for scenes after fixing (1) because we
now add labeled assets to the nested scene `LoadContext` instead of the
root load context. I'm surprised nobody has hit this yet. I'm glad I
caught it before somebody hit it.
3. Accessing "loaded with dependencies" state on the Asset Server is
boilerplatey + error prone (because you need to manually query two
states).

## Solution

1. In GltfLoader, use a nested LoadContext for scenes and load
dependencies through that context.
2. In the `AssetServer`, load labeled assets recursively.
3. Added a simple `asset_server.is_loaded_with_dependencies(id)`

I also added some docs to `LoadContext` to help prevent this problem in
the future.

---

## Changelog

- Added `AssetServer::is_loaded_with_dependencies`
- Fixed GLTF Scene dependencies
- Fixed nested labeled assets not being loaded

---------

Co-authored-by: Alice Cecile <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Assets Load files from disk to use for things like images, models, and sounds C-Bug An unexpected or incorrect behavior S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Race condition in assets loading
4 participants