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

AssetServer.load_folder() fails in wasm while individual load() calls work #2916

Closed
djeedai opened this issue Oct 5, 2021 · 6 comments
Closed
Labels
C-Bug An unexpected or incorrect behavior O-Web Specific to web (WASM) builds

Comments

@djeedai
Copy link
Contributor

djeedai commented Oct 5, 2021

Bevy version

0.5.0

Operating system & version

Windows 10

What you did

Build https://github.com/djeedai/libracity/tree/wasm in wasm.

cargo make serve

What you expected to happen

Can load both individual assets and entire folders when targeting wasm.

What actually happened

asset_server.load("models/file.gltf") loads fine with both wasm and native.

asset_server.load_folder("models") returns an error AssetFolderNotADirectory("models")' in wasm, but works in native.

Additional information

>rustc -V
rustc 1.55.0-nightly (150fad30e 2021-06-19)
>cargo -V
cargo 1.54.0-nightly (44456677b 2021-06-12)
>wasm-bindgen -V
wasm-bindgen 0.2.69
@djeedai djeedai added C-Bug An unexpected or incorrect behavior S-Needs-Triage This issue needs to be labelled labels Oct 5, 2021
@mockersf mockersf added O-Web Specific to web (WASM) builds and removed S-Needs-Triage This issue needs to be labelled labels Oct 5, 2021
@mockersf
Copy link
Member

mockersf commented Oct 5, 2021

Loading an asset in wasm in Bevy is opinionated and is done as an http request for that file, which most servers should support out of the box.

Loading a folder would mean being able to list its content, which is even more opinionated and often blocked on servers. This doesn't work currently... as it's not even implemented in Bevy

fn read_directory(
&self,
_path: &Path,
) -> Result<Box<dyn Iterator<Item = PathBuf>>, AssetIoError> {
Ok(Box::new(std::iter::empty::<PathBuf>()))
}

@djee-ms
Copy link

djee-ms commented Oct 6, 2021

Loading an asset in wasm in Bevy is opinionated and is done as an http request for that file

Do you mind developing what's opinionated here?

Loading a folder would mean being able to list its content, which is even more opinionated and often blocked on servers

I agree, I didn't think about this, obviously most server disallow listing content. I've replaced load_folder() with individual load() calls. However maybe the error returned should be more clear? Because currently AssetFolderNotADirectory which hints at a wrong path while configuring the build or deploying, whereas the actual error is it not being supported in the first place. I actually spent over a hour trying various things, changing paths, server configs, etc. until I filled that bug and replaced the call.

@rparrett
Copy link
Contributor

A warning was added in #5827, and it seems like there's not really a path forward to support load_folder on the web.

Should we close this?

@djeedai
Copy link
Contributor Author

djeedai commented Jan 18, 2023

@rparrett sounds good to me.

@djeedai djeedai closed this as not planned Won't fix, can't repro, duplicate, stale Jan 18, 2023
@mockersf
Copy link
Member

mockersf commented Jan 19, 2023

Loading an asset in wasm in Bevy is opinionated and is done as an http request for that file

Do you mind developing what's opinionated here?

Sorry, forgot to reply...

When loading an asset in wasm, Bevy does a http get request to the relative URL ./assets/path/to/asset.file. For me, this is opinionated has it uses http, and tries to load files from the same server. It could be hard to serve from a javascript blob if you want to get creative, or from a CDN or just another server for your static files, or using webdav, ...

@djeedai
Copy link
Contributor Author

djeedai commented Jan 19, 2023

Ah yes agreed. Well it's more than opinionated, it's very limited and should be improved, but I believe that's already planned as part of the asset work maybe? Or at least there's a Bevy architecture and third-party crates to work around that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-Bug An unexpected or incorrect behavior O-Web Specific to web (WASM) builds
Projects
None yet
Development

No branches or pull requests

4 participants