-
-
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
Fix get_handle_path()
#1290
Fix get_handle_path()
#1290
Conversation
This does add another atomic operation (handle_to_path.write()) to a function that will get called a lot. Probably not terrible but worth calling out. We could move it into load_async() which would ensure the op happens on a separate thread, but that has the downside of making things like this not work reliably: let handle = server.load("path");
server.get_handle_path(handle); |
Hmm, my first instinct is to get dashmap as a dependency - it would probably solve the performance without such a concurrency issue. It only depends on |
Hmm I'm not familiar enough with dashmap's impl to have an immediate response. Pulling in a new dependency will always require a bit more scrutiny than normal, so it would be good to evaluate a couple of things before rolling with that approach:
|
…/bevy into get-asset-path-fix
8244b42
to
29b83a2
Compare
I actually don't mind this solution of moving it into It's definitely a bummer that the |
I was pointed to this PR via #2306 and this is a pretty glaringly missing feature. |
let owned_path = asset_path.to_owned(); | ||
let id: HandleId = asset_path.into(); | ||
self.server.handle_to_path.write().insert(id, owned_path); | ||
id |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just as an addition to this, could we add a test to validate this behavior?
#2268 and #2306 are both blocked by this PR. |
Help is always appreciated :) If you want to push this PR to completion, you can open a new PR using this as a base if you want and I can close this one. I've been fairly short on time recently, so it'd probably be better. |
No worries! I'll probably end up making a new PR with this as a base :) |
Closed in favor of #2310 |
# 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)
# 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)
Motivated on discord: https://discord.com/channels/691052431525675048/742884593551802431/802272336774299648