Giter Club home page Giter Club logo

bevy_web_asset's Issues

Handle http error codes

Currently, if the response is a http error, we just blindly pass the payload on to the asset loader, which will most likely fail.

On certain http error codes it probably makes sense to retry, on others it probably makes sense to log a warning/error and return and AssetIoError.

Split from: #4
Related to: #6

Going forward with Bevy 0.12

Bevy 0.12 adds native support for remote asset sources, making most code here redundant.
Will bevy_web_asset become a legacy crate, or will it provide boilerplate implementations for http/https?

app.register_asset_source("http", ..);
app.register_asset_source("https", ..);

Doesn't build on stable rust

bevy_web_asset main↑1 cargo run --example web_image
    Blocking waiting for file lock on build directory
   Compiling proc-macro2 v1.0.78
   Compiling thiserror v1.0.57
   Compiling num-traits v0.2.18
   Compiling aho-corasick v1.1.2
   Compiling windows v0.52.0
   Compiling crc32fast v1.4.0
   Compiling khronos-egl v6.0.0
   Compiling miniz_oxide v0.7.2
   Compiling profiling v1.0.15
   Compiling ring v0.16.20
   Compiling fdeflate v0.3.4
   Compiling blake3 v1.5.0
   Compiling polling v2.8.0
   Compiling rustix v0.37.27
   Compiling anyhow v1.0.80
   Compiling accesskit_consumer v0.16.1
error[E0554]: `#![feature]` may not be used on the stable release channel
   --> C:\Users\Johan\.cargo\registry\src\index.crates.io-6f17d22bba15001f\rustix-0.37.27\src\lib.rs:101:26
    |
101 | #![cfg_attr(rustc_attrs, feature(rustc_attrs))]
    |                          ^^^^^^^^^^^^^^^^^^^^

For more information about this error, try `rustc --explain E0554`.
error: could not compile `rustix` (lib) due to 1 previous error
warning: build failed, waiting for other jobs to finish...

MIT License

Hi, do you mind adding a permissive license like MIT / Apache?

Error when fetching images on V0.7

I've got a weird double image fetching error going on locally. Building for wasm and testing in firefox on M1.

Hey, here's the screenshot of what I'm seeing.
image
Essentially it looks like there's a second request getting kicked off that will always take any url and append .meta on the end.
someurl.jpg -> someurl.jpg.meta

AssetReaderError::Io when loading more than one web asset

Bug

I am getting this error when trying to load more than one web asset.

ERROR bevy_asset::server: Encountered an I/O error while loading asset: unexpected status code 500 while loading https://example.png: Head byte length should be less than 8kb

This error is misleading and the head byte length is less than 8kb. There is an issue on the surf repo http-rs/surf#289 which points to it being a bug in http-rs/async-h1's DDOS protection but from a cursory glance, I can't see the cause. I could create an issue downstream but its looking unmaintained.

Reproduction

It was reproducing 100% of the time in my project and I think I boiled it down to it happening when:

  1. First, a request has to be made to a web server that 404s but has a body to it.
  2. Next, a request to an asset over 8kb will result in this error.

Since asset meta checks 404s on every asset, this bug happens every time I load more than one asset. I noticed that this bug does not happen on all web servers and I am assuming this is something to do with the size of the 404 response. For testing purposes, I noticed images from Apple's website also return 404s with html bodies when .meta is appended to the end of an image URL and can be used to reproduce this bug.

Workarounds

  1. Use .insert_resource(AssetMetaCheck::Never) to avoid 404s. I cannot use this one because I am using processed mode for local assets.
  2. Compile bevy_web_asset with surf = { features = [ "curl-client" ] }

Warn and retry when the server can't be reached

When the user has a poor connection and the server can't be reached, we just warn and report the asset as AssetIoError::NotFound.

However, it probably makes sense to retry if we couldn't reach the server.

We should probably add a loop inside WebAssetIo::load_path to retry in those cases.

Split from: #4

ocasional panic

The unwrap here is causing a panic occasionally:

let resp_value = JsFuture::from(window.fetch_with_str(uri)).await.unwrap();

panicked at 'called `Result::unwrap()` on an `Err` value: JsValue(TypeError: NetworkError when attempting to fetch resource.
)', /home/gilescope/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_web_asset-0.4.0/src/web_asset_io.rs:26:83

IoTaskPool resource not found in browser

Got: panicked at 'IoTaskPool resource not found'.

Anyone seen this error before? I'm on bevy 0.7 at the moment (waiting a bit longer to upgrade to 0.8).

Is there some additional setup to do for wasm given things are a tad different on the browser?

android support

isahc is not easily usable on android, because it always uses openssl and doesn't have a published version that can opt-out of that (sagebind/isahc#199).

I read #18 (comment), but it's not clear to me why isahc was preferred over surf, when both appear to not have the issue with loading some urls.

I can do the work and switch back to surf (and set it up so it works with rustls) if that is ok with y'all

WASM Issues for Images

When trying to load an Image in a WASM game following error is output to the console

WARN C:\Users\Jay\.cargo\registry\src\github.com-1ecc6299db9ec823\bevy_asset-0.9.1\src\asset_server.rs:454 encountered an error while loading an asset: Error reading image file https://i.pinimg.com/originals/b5/41/b3/b541b339d5fee0af74e95d3fe7bbf038.png: failed to load an image: Format error decoding Png: Unexpected end of data before image end., this is an error in `bevy_render`.

Trouble loading assets from localhost while doing development

I've been working with this library using an image pulled from S3 as a testing URL.

This image parses in just fine, but I'm running into an asset path parsing error when sending in a url that contains a port.

Ideally, I'd like to use pre-signed urls from S3 and that would look something like this.

The error I'm seeing so far looks like this.

/bevy_asset-0.12.1/src/path.rs:104:37: called `Result::unwrap()` on an `Err` value: InvalidSourceSyntax

I tracked down where I think this is being thrown to the while loop that parses paths looking for :. Since there is a second : in the url containing a path, it seems to throw that InvalidSourceSyntax error.

    while let Some((index, char)) = chars.next() {
          match char {
              ':' => {
                  let (_, char) = chars
                      .next()
                      .ok_or(ParseAssetPathError::InvalidSourceSyntax)?;
                  if char != '/' {
                      return Err(ParseAssetPathError::InvalidSourceSyntax);
                  }
                  let (index, char) = chars
                      .next()
                      .ok_or(ParseAssetPathError::InvalidSourceSyntax)?;
                  if char != '/' {
                      return Err(ParseAssetPathError::InvalidSourceSyntax);
                  }
                  source_range = Some(0..index - 2);
                  path_range.start = index + 1;
              }
              '#' => {
                  path_range.end = index;
                  label_range = Some(index + 1..asset_path.len());
                  break;
              }
              _ => {}
          }
      }

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.