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

[Merged by Bors] - [assets] set LoadState properly and more testing! #2226

Closed

Conversation

NathanSWard
Copy link
Contributor

@NathanSWard NathanSWard commented May 20, 2021

  1. Sets LoadState properly on all failing cases in AssetServer::load_async
  2. Adds more tests for sad and happy paths of asset loading

Note: this brings in the tempfile crate.

@NathanSWard NathanSWard requested a review from mockersf May 20, 2021 18:19
@NathanSWard NathanSWard added A-Assets Load files from disk to use for things like images, models, and sounds C-Bug An unexpected or incorrect behavior labels May 20, 2021
Copy link
Member

@alice-i-cecile alice-i-cecile left a comment

Choose a reason for hiding this comment

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

Just a nit. Looks good to me though.

@mockersf
Copy link
Member

From your tests, it seems LoadState::NotLoaded is used for:

  • handle to an asset not yet loaded (for example, building an handle from a path that was not loaded)
  • handle to an asset built outside of the asset server
  • handle to an asset created by loading it through the asset server but without an asset loader for its extension

Having those bundled together doesn't seems right to me.

@NathanSWard
Copy link
Contributor Author

Having those bundled together doesn't seems right to me.

This is fair, however, this isn't a change on my part. This was simply the original behavior of the LoadState.

@mockersf
Based on the list you gave I assume you'd expect the following:

handle to an asset not yet loaded (for example, building an handle from a path that was not loaded)

LoadState::NotLoaded

handle to an asset built outside of the asset server

LoadState::???

handle to an asset created by loading it through the asset server but without an asset loader for its extension

LoadState::Failed
The curious part about this last one is that this is the only unhappy path that doesnt change the LoadState to Failed. However this is because if a loader does not exist for the extension type async_load immediately returns before creating a SourceInfo struct for this.
Should we creat a SourceInfo struct for it?

@mockersf
Copy link
Member

mockersf commented May 26, 2021

This is fair, however, this isn't a change on my part. This was simply the original behavior of the LoadState.

Right, your tests made this issue visible 😄 . It can be a followup PR if you prefer.

handle to an asset not yet loaded (for example, building an handle from a path that was not loaded)

LoadState::NotLoaded

👍

handle to an asset built outside of the asset server

LoadState::???

LoadState::WhatAreYouDoing? LoadState::NotSomethingYouLoadedWhyYouDoingThis? LoadState::NotFromAssetServer? LoadState::ManuallyLoaded? LoadState::NotALoadedAssetAndNeverWillBe?

Maybe LoadState::Manual is the one I'd prefer.

handle to an asset created by loading it through the asset server but without an asset loader for its extension

LoadState::Failed

👍

The curious part about this last one is that this is the only unhappy path that doesnt change the LoadState to Failed. However this is because if a loader does not exist for the extension type async_load immediately returns before creating a SourceInfo struct for this.
Should we creat a SourceInfo struct for it?

I think a SourceInfo is used to track the life of an asset's source for things like reloading, ... This is not needed here so I would say no.

@mockersf
Copy link
Member

mockersf commented May 27, 2021

handle to an asset created by loading it through the asset server but without an asset loader for its extension

LoadState::Failed
The curious part about this last one is that this is the only unhappy path that doesnt change the LoadState to Failed. However this is because if a loader does not exist for the extension type async_load immediately returns before creating a SourceInfo struct for this.
Should we creat a SourceInfo struct for it?

It was mentioned today that it fails silently for that case. It was in a case of loading a gltf model with jpg textures, which doesn't work without --features jpeg. Could you also add a log in that case? (actually this would probably not help in this case at all as the gltf loader doesn't go back to the asset server to load its texture, still would probably be good to log that the user is doing something that can't work)

... sorry to add changes to your pr, this too can be a followup if you prefer...

@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 May 27, 2021
@NathanSWard
Copy link
Contributor Author

I think a SourceInfo is used to track the life of an asset's source for things like reloading, ... This is not needed here so I would say no.

Well, the SourceInfo struct is what conatins the LoadState.
So in order to set the load state, you would have to insert a SourceInfo.

@NathanSWard
Copy link
Contributor Author

NathanSWard commented May 29, 2021

When this gets merged in I'll submit a follow up PR to address #2261 and that calling get_load_state on a Handle manually constructed (not through .load()) should return a specific LoadState.

@NathanSWard NathanSWard requested a review from cart May 31, 2021 06:36
@NathanSWard
Copy link
Contributor Author

ping @cart 😉

@NathanSWard NathanSWard requested a review from cart June 3, 2021 20:13
@NathanSWard
Copy link
Contributor Author

pinging here again to hopefully get some traction.
Would like to get this merged in as it unblocks me from adding #2310 which then unblocks 2 other PRs.

@cart
Copy link
Member

cart commented Jun 8, 2021

Looks good to me!

@cart
Copy link
Member

cart commented Jun 8, 2021

bors r+

bors bot pushed a commit that referenced this pull request Jun 8, 2021
1) Sets `LoadState` properly on all failing cases in `AssetServer::load_async`
2) Adds more tests for sad and happy paths of asset loading

_Note_: this brings in the `tempfile` crate.
@bors bors bot changed the title [assets] set LoadState properly and more testing! [Merged by Bors] - [assets] set LoadState properly and more testing! Jun 8, 2021
@bors bors bot closed this Jun 8, 2021
ostwilkens pushed a commit to ostwilkens/bevy that referenced this pull request Jul 27, 2021
1) Sets `LoadState` properly on all failing cases in `AssetServer::load_async`
2) Adds more tests for sad and happy paths of asset loading

_Note_: this brings in the `tempfile` crate.
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.

None yet

4 participants