-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
[Merged by Bors] - [assets] Fix AssetServer::get_handle_path
#2310
Conversation
So doing this in load_async creates timing issues that could affect the PRs mentioned above (as discussed in #1290). If we're going to rely on this for things like serialization / deserialization, I don't think we can have nondeterministic behavior based on whether or not a load_async task has been run yet. In some cases, "behavior that cannot be relied upon" is worse than "consistently not working correctly". |
This is all fair. asset_server.load("mypath"); multiple times, the value keeps getting overwritten. I guess we could do something like: if self.handle_to_path.read().contains(&handle_id) {
self.handle_to_path.write().insert(handle_id, asset_path.clone());
} Actually now thinking about it, this isn't the worst solution. |
Just updated the PR to add the path in the |
Honestly its probably not great. For the "happy path" where Just doing unconditional |
I'm not the biggest fan on banking on the called exactly once argument, however, since it does make sense that this is the happy and common path, I'm ok with removing the |
I'd argue that your impl is banking on the "called more than once argument" 😄 |
That's fair 😛
Yep! I complete agree with the argument that we should we should encourage handle reuse! And the PR is currently updated with the |
Cool I think this is good to go, but I just merged #2226 and I'm happy to wait for tests 😄 |
5730fad
to
7e86244
Compare
thanks! just added the tests! |
This PR should be ready to go now with the additional testing :) |
bors r+ |
# Objective - Currently `AssetServer::get_handle_path` always returns `None` since the inner hash map is never written to. ## Solution - Inside the `load_untracked` function, insert the asset path into the map. This is similar to #1290 (thanks @TheRawMeatball)
Pull request successfully merged into main. Build succeeded: |
AssetServer::get_handle_path
AssetServer::get_handle_path
# Objective - Currently `AssetServer::get_handle_path` always returns `None` since the inner hash map is never written to. ## Solution - Inside the `load_untracked` function, insert the asset path into the map. This is similar to bevyengine#1290 (thanks @TheRawMeatball)
Objective
AssetServer::get_handle_path
always returnsNone
since the inner hash map is never written to.Solution
load_untracked
function, insert the asset path into the map.This is similar to #1290 (thanks @TheRawMeatball)