Skip to content

Add http & https asset sources (clean commit history) #17889

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

Open
wants to merge 14 commits into
base: main
Choose a base branch
from

Conversation

mrchantey
Copy link
Contributor

@mrchantey mrchantey commented Feb 17, 2025

Objective

This is a duplicate of #16366 because I made a mess of the commit history. See that pr for more context and discussion.

Solution

  • Add http & https asset sources
  • Allows CDLA-Permissive-2.0 in deny.toml

Testing

  • Verify visually by running cargo run --example http_source --features="http_source"

Showcase

Bevy now supports assets loaded via url!

Add the http_source feature to load assets served over the web, with support for both native and wasm targets. On native targets the http_source_cache feature will use a basic caching mechanism to avoid repeated network requests.

  // Simply use a url where you would normally use an `assets` path
  let handle = asset_server.load("https://raw.githubusercontent.com/bevyengine/bevy/refs/heads/main/assets/branding/bevy_bird_dark.png");
  commands.spawn(Sprite::from_image(handle));

Further Work

  • Better AssetReaderError: The asset path is not always collected in the error. This is likely a common error that actual non-developer users will see so its important to get it right.
  • Possibly expose the native request mechanic as a general fetch, in the future we'll have many reasons to be making requests.

@mrchantey mrchantey added C-Feature A new feature, making something new possible A-Assets Load files from disk to use for things like images, models, and sounds C-Dependencies A change to the crates that Bevy depends on S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it X-Controversial There is active debate or serious implications around merging this PR M-Needs-Release-Note Work that should be called out in the blog due to impact D-Modest A "normal" level of difficulty; suitable for simple features or challenging fixes labels Feb 17, 2025
@alice-i-cecile alice-i-cecile added S-Needs-SME Decision or review from an SME is required and removed S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it labels Feb 17, 2025
@Elabajaba
Copy link
Contributor

Just a quick note, ring is now unmaintained for the foreseeable future.

@TimJentzsch TimJentzsch added the S-Needs-Review Needs reviewer attention (from anyone!) to move forward label Feb 25, 2025
@recatek
Copy link
Contributor

recatek commented Mar 5, 2025

Adding MPL as an allowed license seems like it would have complications for distributing game binaries, no?

That said, I'm not clear what new dependency here actually requires it. Both ureq and webpki-roots support MIT and Apache 2.0 from looking at their repos.

@mockersf
Copy link
Member

mockersf commented Mar 5, 2025

Just a quick note, ring is now unmaintained for the foreseeable future.

ring is maintained again, now by the rustls team

@mockersf
Copy link
Member

mockersf commented Mar 5, 2025

blocked on finding where the MPL license comes from and removing it

@mockersf mockersf added the S-Blocked This cannot move forward until something else changes label Mar 5, 2025
@mockersf
Copy link
Member

mockersf commented Mar 5, 2025

waiting on a new release of webpki-root with this commit: rustls/webpki-roots@90c48f3#diff-8aec0a2c31031e00524df726f854726660ec8289dcddfa70005000fc21b00511

@jf908
Copy link
Contributor

jf908 commented Mar 5, 2025

As of right now, ring is not actually included in this PR, it was replaced by aws-lc-rs. Now that ring has removed the OpenSSL parts of the license, I think we can remove aws-lc-rs, remove OpenSSL from deny.toml and use the ureq's default ring dependency again. This would be especially nice because aws-lc-rs requires installing CMake on Windows.

@alice-i-cecile alice-i-cecile added S-Waiting-on-Author The author needs to make changes or address concerns before this can be merged and removed S-Blocked This cannot move forward until something else changes S-Needs-Review Needs reviewer attention (from anyone!) to move forward S-Needs-SME Decision or review from an SME is required labels Mar 6, 2025
@mrchantey
Copy link
Contributor Author

Okeydokey back to ring with OpenSSL and MPL licences removed from the allow list, the next release of webpki-roots should get check-licenses passing in ci 🤞

@mrchantey mrchantey added S-Blocked This cannot move forward until something else changes and removed S-Waiting-on-Author The author needs to make changes or address concerns before this can be merged labels Apr 22, 2025
@jf908
Copy link
Contributor

jf908 commented Apr 27, 2025

I poked the rustls discord and they pushed a new webpki-roots release! Just have to wait for ureq to update too now.

Although the rustls discord also suggested that we make use of rustls-platform-verifier rather than webpki-roots. rustls-platform-verifier uses the OS's certificates which is the default behaviour of most applications since it won't be on the onus of bevy and bevy games to keep certificates regularly up to date. See here. ureq uses webpki-roots as the default to reduce the default number of dependencies but I feel like that might be the wrong default for a bevy application. With that said, maybe we just worry about that in a follow up PR, this one has already been through quite the cycle of development :)

@alice-i-cecile
Copy link
Member

I'm fine to call this unblocked once ureq releases :) I agree with your analysis: that's a better default, but can be done in follow-up.

Very eager to get this into the engine to help unblock the usage of better assets in our examples (in addition to the direct value to users).

Copy link
Contributor

@rlidwka rlidwka left a comment

Choose a reason for hiding this comment

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

Would it be too much to ask for current download progress statistics?

edit: and a user-defined validation function to check digital signature or checksum

Copy link
Contributor

@jf908 jf908 left a comment

Choose a reason for hiding this comment

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

I just realized this PR is no longer blocked - I was wrong about needing to wait on a ureq release since patch dependencies can be upgraded automatically.

Approved from me other than .gitignore change and adding CDLA-Permissive-2.0 to allowed licenses in deny.toml. I guess a maintainer will have to give their ok to the license in final review.

@jf908
Copy link
Contributor

jf908 commented May 16, 2025

@rlidwka has raised some very good review points but personally I feel this PR is in a good enough state to merge and then we can start making incremental follow ups - feel free to disagree with me if you think there is anything worth blocking

mrchantey and others added 3 commits May 18, 2025 11:44
Co-authored-by: François Mockers <francois.mockers@vleue.com>
@mrchantey
Copy link
Contributor Author

I agree, more iteration is requried but this pr is already substantial. How about we create a follow-up issue for discussion on whats needed to complete http asset sources and open smaller prs from there.

@mrchantey mrchantey removed the S-Blocked This cannot move forward until something else changes label May 19, 2025
@mrchantey mrchantey requested a review from mockersf May 19, 2025 00:27
@alice-i-cecile alice-i-cecile added the S-Waiting-on-Author The author needs to make changes or address concerns before this can be merged label May 19, 2025
@mrchantey mrchantey removed the S-Waiting-on-Author The author needs to make changes or address concerns before this can be merged label May 20, 2025
@alice-i-cecile alice-i-cecile added S-Needs-Review Needs reviewer attention (from anyone!) to move forward X-Blessed Has a large architectural impact or tradeoffs, but the design has been endorsed by decision makers and removed X-Controversial There is active debate or serious implications around merging this PR labels May 21, 2025
@alice-i-cecile
Copy link
Member

I've spoken with @cart about this, and we'd like to move forward with this as a solution for example assets (in addition to thinking it's broadly useful). We just need a second approval now to get this merged.

@alice-i-cecile alice-i-cecile added this to the 0.17 milestone May 21, 2025
Co-authored-by: jf908 <jf908@users.noreply.github.com>
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-Dependencies A change to the crates that Bevy depends on C-Feature A new feature, making something new possible D-Modest A "normal" level of difficulty; suitable for simple features or challenging fixes M-Needs-Release-Note Work that should be called out in the blog due to impact S-Needs-Review Needs reviewer attention (from anyone!) to move forward X-Blessed Has a large architectural impact or tradeoffs, but the design has been endorsed by decision makers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature: Upstream bevy_web_asset, allowing assets loaded via http
8 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy