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] - Improve examples loading feedback #355

Closed

Conversation

doup
Copy link
Contributor

@doup doup commented Apr 18, 2022

This is a proposal for #338.

  • Builds on top of the code by @ickk using TransformStream.
  • Adds loading feedback on examples.
  • The solution is hacky, it monkey-patches fetch in the example template.
bevy-example-progress-bar-02.mp4

Co-Authored-By: ickk 17050131+ickk@users.noreply.github.com

doup and others added 2 commits April 18, 2022 12:09
- The idea to use `TransformStream` and original code to get the download progress is by @ickk

Co-Authored-By: ickk <17050131+ickk@users.noreply.github.com>
@doup
Copy link
Contributor Author

doup commented Apr 18, 2022

This is a proof of concept. Right now it doesn't work in Firefox as it needs a polyfill. Once the polyfill is added and if everything works fine I'll change the PR status for review.

@doup doup marked this pull request as ready for review April 19, 2022 15:58
@doup
Copy link
Contributor Author

doup commented Apr 19, 2022

I just noticed that it doesn't work on Android Firefox. Desktop works though with the polyfill. -_-

@doup
Copy link
Contributor Author

doup commented Apr 19, 2022

Looks like it's this issue: bevyengine/bevy#4431
So probably it will work fine on Android Firefox once it's on https.

I've tried on a locally built master (commit 9141a6a) on the same device with Android Firefox, with freshly compiled examples and I still get the same error. While bevyengine.org on the same commit works (also on 9141a6a, see deploy).

Error Message
panicked at 'error getting gamepads: JsValue(TypeError: getObject(...).getGamepads is not a function
init/imports.wbg.__wbg_getGamepads_15547708d4a2c197/<@http://192.168.1.134:1111/examples/2d/rect/rect.js:1071:35
handleError@http://192.168.1.134:1111/examples/2d/rect/rect.js:260:18
init/imports.wbg.__wbg_getGamepads_15547708d4a2c197@http://192.168.1.134:1111/examples/2d/rect/rect.js:1070:74
web_sys::features::gen_Navigator::Navigator::get_gamepads::h6b8900abff18c49a@http://192.168.1.134:1111/examples/2d/rect/rect_bg.wasm:wasm-function[17706]:0x9f491f
gilrs_core::platform::platform::gamepad::Gilrs::next_event::hd918af2e739a2de7@http://192.168.1.134:1111/examples/2d/rect/rect_bg.wasm:wasm-function[663]:0x252929
gilrs_core::Gilrs::next_event::h56dc831d39f8c27b@http://192.168.1.134:1111/examples/2d/rect/rect_bg.wasm:wasm-function[25026]:0xa2bcb9
gilrs::gamepad::Gilrs::next_event_priv::hcc60519fce21e3ee@http://192.168.1.134:1111/examples/2d/rect/rect_bg.wasm:wasm-function[724]:0x280ff2
gilrs::gamepad::Gilrs::next_event::h86c28d494acf29da@http://192.168.1.134:1111/examples/2d/rect/rect_bg.wasm:wasm-function[6128]:0x78fcc9
core::ops::function::impls::<impl core::ops::function::FnMut<A> for &mut F>::call_mut::hab046af8d7131941@http://192.168.1.134:1111/examples/2d/rect/rect_bg.wasm:wasm-function[2197]:0x4f5bcf
<bevy_ecs::system::function_system::FunctionSystem<In,Out,Param,Marker,F> as bevy_ecs::system::system::System>::run_unsafe::hd105aaf5a53cabdf@http://192.168.1.134:1111/examples/2d/rect/rect_bg.wasm:wasm-function[5001]:0x70761d
<core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll::h5c3de87af2106aaf@http://192.168.1.134:1111/examples/2d/rect/rect_bg.wasm:wasm-function[2041]:0x4c3ab0
async_task::raw::RawTask<F,T,S>::run::ha63aa38003ced71c@http://192.168.1.134:1111/examples/2d/rect/rect_bg.wasm:wasm-function[1714]:0x452725
async_task::runnable::Runnable::run::hdeda50481f30420b@http://192.168.1.134:1111/examples/2d/rect/rect_bg.wasm:wasm-function[23803]:0xa27fc4
async_executor::LocalExecutor::try_tick::h99167c683d5f429d@http://192.168.1.134:1111/examples/2d/rect/rect_bg.wasm:wasm-function[8633]:0x87b5fc
bevy_tasks::single_threaded_task_pool::TaskPool::scope::hc7c9aa9b037070c9@http://192.168.1.134:1111/examples/2d/rect/rect_bg.wasm:wasm-function[3359]:0x5fdee1
<bevy_ecs::schedule::executor_parallel::ParallelExecutor as bevy_ecs::schedule::executor::ParallelSystemExecutor>::run_systems::hf503128559bddca7@http://192.168.1.134:1111/examples/2d/rect/rect_bg.wasm:wasm-function[1450]:0x3eca64
<bevy_ecs::schedule::stage::SystemStage as bevy_ecs::schedule::stage::Stage>::run::h5a96131c734fe577@http://192.168.1.134:1111/examples/2d/rect/rect_bg.wasm:wasm-function[374]:0x93286
bevy_ecs::schedule::Schedule::run_once::hefa615e64f67aea7@http://192.168.1.134:1111/examples/2d/rect/rect_bg.wasm:wasm-function[5443]:0x73fd00
<bevy_ecs::schedule::Schedule as bevy_ecs::schedule::stage::Stage>::run::h65596e8b3249a482@http://192.168.1.134:1111/examples/2d/rect/rect_bg.wasm:wasm-function[11405]:0x929ebd
bevy_app::app::App::update::h345cb597e1a575f9@http://192.168.1.134:1111/examples/2d/rect/rect_bg.wasm:wasm-function[11319]:0x9255ae
winit::platform_impl::platform::event_loop::EventLoop<T>::run::{{closure}}::had911c780df8e582@http://192.168.1.134:1111/examples/2d/rect/rect_bg.wasm:wasm-function[418]:0x127b3e
winit::platform_impl::platform::event_loop::runner::Shared<T>::handle_event::h6a88aca07620e92c@http://192.168.1.134:1111/examples/2d/rect/rect_bg.wasm:wasm-function[3054]:0x5c344d
winit::platform_impl::platform::event_loop::runner::Shared<T>::run_until_cleared::h6c8835bfd8849433@http://192.168.1.134:1111/examples/2d/rect/rect_bg.wasm:wasm-function[2822]:0x593015
winit::platform_impl::platform::event_loop::runner::Shared<T>::set_listener::h8df6903dcffc961e@http://192.168.1.134:1111/examples/2d/rect/rect_bg.wasm:wasm-function[7493]:0x81aa9a
winit::platform_impl::platform::event_loop::window_target::WindowTarget<T>::run::h2dc2a57dbe9fcb0f@http://192.168.1.134:1111/examples/2d/rect/rect_bg.wasm:wasm-function[12501]:0x95b8b8
winit::platform_impl::platform::event_loop::EventLoop<T>::run::h7f30eb1e572beec4@http://192.168.1.134:1111/examples/2d/rect/rect_bg.wasm:wasm-function[15111]:0x9b7698
winit::event_loop::EventLoop<T>::run::h3f64cc2a187bbf97@http://192.168.1.134:1111/examples/2d/rect/rect_bg.wasm:wasm-function[19350]:0xa0c601
bevy_winit::run::h9e40bc3f0fa153af@http://192.168.1.134:1111/examples/2d/rect/rect_bg.wasm:wasm-function[19349]:0xa0c5d8
bevy_winit::winit_runner_with::h9b2727838be62eeb@http://192.168.1.134:1111/examples/2d/rect/rect_bg.wasm:wasm-function[1090]:0x34f15c
core::ops::function::Fn::call::h4a3ec35c39cd1aa4@http://192.168.1.134:1111/examples/2d/rect/rect_bg.wasm:wasm-function[19009]:0xa08771
bevy_app::app::App::run::h3408f923c8969b91@http://192.168.1.134:1111/examples/2d/rect/rect_bg.wasm:wasm-function[12431]:0x958a2b
rect::main::h9644f967535ed69d@http://192.168.1.134:1111/examples/2d/rect/rect_bg.wasm:wasm-function[914]:0x2f4acd
std::sys_common::backtrace::__rust_begin_short_backtrace::h995cce5a2ac8cde0@http://192.168.1.134:1111/examples/2d/rect/rect_bg.wasm:wasm-function[25393]:0xa2cac4
std::rt::lang_start::{{closure}}::ha9b694a413a21a32@http://192.168.1.134:1111/examples/2d/rect/rect_bg.wasm:wasm-function[18818]:0xa05f76
std::rt::lang_start_internal::hf82fb96883107d82@http://192.168.1.134:1111/examples/2d/rect/rect_bg.wasm:wasm-function[11267]:0x922a05
main@http://192.168.1.134:1111/examples/2d/rect/rect_bg.wasm:wasm-function[18816]:0xa05f23
@http://192.168.1.134:1111/examples/2d/rect/rect_bg.wasm:wasm-function[23882]:0xa2846e
init@http://192.168.1.134:1111/examples/2d/rect/rect.js:1668:10
async*@http://192.168.1.134:1111/examples/2d/rect/:138:5
)', /Users/doup/.cargo/registry/src/github.com-1ecc6299db9ec823/gilrs-core-0.3.2/src/platform/wasm/gamepad.rs:52:14

Stack:

init/imports.wbg.__wbg_new_693216e109162396@http://192.168.1.134:1111/examples/2d/rect/rect.js:408:19
console_error_panic_hook::hook::heedd4879d3ad26ce@http://192.168.1.134:1111/examples/2d/rect/rect_bg.wasm:wasm-function[6230]:0x79b190
core::ops::function::Fn::call::h02e64390c0dc1397@http://192.168.1.134:1111/examples/2d/rect/rect_bg.wasm:wasm-function[25463]:0xa2ccf5
std::panicking::rust_panic_with_hook::h12b2f0179ff84c92@http://192.168.1.134:1111/examples/2d/rect/rect_bg.wasm:wasm-function[10798]:0x9081b1
std::panicking::begin_panic_handler::{{closure}}::h5a69bb4aef967681@http://192.168.1.134:1111/examples/2d/rect/rect_bg.wasm:wasm-function[13827]:0x98d6ce
std::sys_common::backtrace::__rust_end_short_backtrace::h1cfd7c1c16d2a171@http://192.168.1.134:1111/examples/2d/rect/rect_bg.wasm:wasm-function[21120]:0xa1aebb
rust_begin_unwind@http://192.168.1.134:1111/examples/2d/rect/rect_bg.wasm:wasm-function[18140]:0x9fc030
core::panicking::panic_fmt::hf0d93ec1ac504cf9@http://192.168.1.134:1111/examples/2d/rect/rect_bg.wasm:wasm-function[19192]:0xa0a9dd
core::result::unwrap_failed::hd5a60243cf946632@http://192.168.1.134:1111/examples/2d/rect/rect_bg.wasm:wasm-function[14876]:0x9b025b
gilrs_core::platform::platform::gamepad::Gilrs::next_event::hd918af2e739a2de7@http://192.168.1.134:1111/examples/2d/rect/rect_bg.wasm:wasm-function[663]:0x253543
gilrs_core::Gilrs::next_event::h56dc831d39f8c27b@http://192.168.1.134:1111/examples/2d/rect/rect_bg.wasm:wasm-function[25026]:0xa2bcb9
gilrs::gamepad::Gilrs::next_event_priv::hcc60519fce21e3ee@http://192.168.1.134:1111/examples/2d/rect/rect_bg.wasm:wasm-function[724]:0x280ff2
gilrs::gamepad::Gilrs::next_event::h86c28d494acf29da@http://192.168.1.134:1111/examples/2d/rect/rect_bg.wasm:wasm-function[6128]:0x78fcc9
core::ops::function::impls::<impl core::ops::function::FnMut<A> for &mut F>::call_mut::hab046af8d7131941@http://192.168.1.134:1111/examples/2d/rect/rect_bg.wasm:wasm-function[2197]:0x4f5bcf
<bevy_ecs::system::function_system::FunctionSystem<In,Out,Param,Marker,F> as bevy_ecs::system::system::System>::run_unsafe::hd105aaf5a53cabdf@http://192.168.1.134:1111/examples/2d/rect/rect_bg.wasm:wasm-function[5001]:0x70761d
<core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll::h5c3de87af2106aaf@http://192.168.1.134:1111/examples/2d/rect/rect_bg.wasm:wasm-function[2041]:0x4c3ab0
async_task::raw::RawTask<F,T,S>::run::ha63aa38003ced71c@http://192.168.1.134:1111/examples/2d/rect/rect_bg.wasm:wasm-function[1714]:0x452725
async_task::runnable::Runnable::run::hdeda50481f30420b@http://192.168.1.134:1111/examples/2d/rect/rect_bg.wasm:wasm-function[23803]:0xa27fc4
async_executor::LocalExecutor::try_tick::h99167c683d5f429d@http://192.168.1.134:1111/examples/2d/rect/rect_bg.wasm:wasm-function[8633]:0x87b5fc
bevy_tasks::single_threaded_task_pool::TaskPool::scope::hc7c9aa9b037070c9@http://192.168.1.134:1111/examples/2d/rect/rect_bg.wasm:wasm-function[3359]:0x5fdee1
<bevy_ecs::schedule::executor_parallel::ParallelExecutor as bevy_ecs::schedule::executor::ParallelSystemExecutor>::run_systems::hf503128559bddca7@http://192.168.1.134:1111/examples/2d/rect/rect_bg.wasm:wasm-function[1450]:0x3eca64
<bevy_ecs::schedule::stage::SystemStage as bevy_ecs::schedule::stage::Stage>::run::h5a96131c734fe577@http://192.168.1.134:1111/examples/2d/rect/rect_bg.wasm:wasm-function[374]:0x93286
bevy_ecs::schedule::Schedule::run_once::hefa615e64f67aea7@http://192.168.1.134:1111/examples/2d/rect/rect_bg.wasm:wasm-function[5443]:0x73fd00
<bevy_ecs::schedule::Schedule as bevy_ecs::schedule::stage::Stage>::run::h65596e8b3249a482@http://192.168.1.134:1111/examples/2d/rect/rect_bg.wasm:wasm-function[11405]:0x929ebd
bevy_app::app::App::update::h345cb597e1a575f9@http://192.168.1.134:1111/examples/2d/rect/rect_bg.wasm:wasm-function[11319]:0x9255ae
winit::platform_impl::platform::event_loop::EventLoop<T>::run::{{closure}}::had911c780df8e582@http://192.168.1.134:1111/examples/2d/rect/rect_bg.wasm:wasm-function[418]:0x127b3e
winit::platform_impl::platform::event_loop::runner::Shared<T>::handle_event::h6a88aca07620e92c@http://192.168.1.134:1111/examples/2d/rect/rect_bg.wasm:wasm-function[3054]:0x5c344d
winit::platform_impl::platform::event_loop::runner::Shared<T>::run_until_cleared::h6c8835bfd8849433@http://192.168.1.134:1111/examples/2d/rect/rect_bg.wasm:wasm-function[2822]:0x593015
winit::platform_impl::platform::event_loop::runner::Shared<T>::set_listener::h8df6903dcffc961e@http://192.168.1.134:1111/examples/2d/rect/rect_bg.wasm:wasm-function[7493]:0x81aa9a
winit::platform_impl::platform::event_loop::window_target::WindowTarget<T>::run::h2dc2a57dbe9fcb0f@http://192.168.1.134:1111/examples/2d/rect/rect_bg.wasm:wasm-function[12501]:0x95b8b8
winit::platform_impl::platform::event_loop::EventLoop<T>::run::h7f30eb1e572beec4@http://192.168.1.134:1111/examples/2d/rect/rect_bg.wasm:wasm-function[15111]:0x9b7698
winit::event_loop::EventLoop<T>::run::h3f64cc2a187bbf97@http://192.168.1.134:1111/examples/2d/rect/rect_bg.wasm:wasm-function[19350]:0xa0c601
bevy_winit::run::h9e40bc3f0fa153af@http://192.168.1.134:1111/examples/2d/rect/rect_bg.wasm:wasm-function[19349]:0xa0c5d8
bevy_winit::winit_runner_with::h9b2727838be62eeb@http://192.168.1.134:1111/examples/2d/rect/rect_bg.wasm:wasm-function[1090]:0x34f15c
core::ops::function::Fn::call::h4a3ec35c39cd1aa4@http://192.168.1.134:1111/examples/2d/rect/rect_bg.wasm:wasm-function[19009]:0xa08771
bevy_app::app::App::run::h3408f923c8969b91@http://192.168.1.134:1111/examples/2d/rect/rect_bg.wasm:wasm-function[12431]:0x958a2b
rect::main::h9644f967535ed69d@http://192.168.1.134:1111/examples/2d/rect/rect_bg.wasm:wasm-function[914]:0x2f4acd
std::sys_common::backtrace::__rust_begin_short_backtrace::h995cce5a2ac8cde0@http://192.168.1.134:1111/examples/2d/rect/rect_bg.wasm:wasm-function[25393]:0xa2cac4
std::rt::lang_start::{{closure}}::ha9b694a413a21a32@http://192.168.1.134:1111/examples/2d/rect/rect_bg.wasm:wasm-function[18818]:0xa05f76
std::rt::lang_start_internal::hf82fb96883107d82@http://192.168.1.134:1111/examples/2d/rect/rect_bg.wasm:wasm-function[11267]:0x922a05
main@http://192.168.1.134:1111/examples/2d/rect/rect_bg.wasm:wasm-function[18816]:0xa05f23
@http://192.168.1.134:1111/examples/2d/rect/rect_bg.wasm:wasm-function[23882]:0xa2846e
init@http://192.168.1.134:1111/examples/2d/rect/rect.js:1668:10
async*@http://192.168.1.134:1111/examples/2d/rect/:138:5


rect.js:420:21

@mockersf
Copy link
Member

works as in the video on my Safari and Firefox 👍

@doup
Copy link
Contributor Author

doup commented Apr 19, 2022

I've tried it with ngrok, and over https it works fine on my phone Firefox. 🎉

@ickk
Copy link
Member

ickk commented Apr 20, 2022

This is great, thanks for working on this!

To reiterate my comments left on #338 I don't think monkey-patching is an ideal solution.

  • We already patch files using sed in our deployment script, so replacing calls to window.fetch with progressive_fetch using sed seems okay in my opinion.
  • We don't necessarily want to use this for the loading of assets long-term (although it's a good stop-gap until the engine has this functionality).
  • It makes using this code difficult if we ever want to include multiple bevy-canvases on the same page (since the callback is hardcoded to a single element-id). This seems like something we might do in release notes going forward; interactive feature demonstrations!

@doup
Copy link
Contributor Author

doup commented Apr 20, 2022

Hi! I think there is a misunderstanding with my goal here. I thought #338 was for the examples on the Bevy Website, as it supersedes #236. This PR just pretends to improve the website examples loading feedback, it's not a proposal for the general Bevy engine "assets loading feedback" story itself. There is an UX issue on the website right now (#236) and this just tries to solve that UX issue with the tools at hand. It's super hacky but it (kind-of) does the job.

That being said… it's true that the monkey-patch approach is fragile. For example, if someone who is not aware of the hack adds some search functionality on the header using fetch… suddenly they might see that a loading bar shows on the example while doing searches on the header… not great. 😅

I think I have an idea, I'll use sed, and patch the following pieces:

  • function init(input) { => function init(customFetch, input) { customFetch = customFetch || fetch; (add a parameter to pass a custom fetch implementation, which defaults to fetch)
  • input = fetch( => input = customFetch( (for the main wasm)
  • getObject(arg0).fetch( => customFetch( (for the assets)

Then, in example.html I'll pass the custom fetch with the TransformStream logic. This still tradeoffs your callbacks mechanism in favor of an easier to iterate approach. Otherwise to make changes on the loading feedback code we would need to run the script each time…

This is still a hack, even if it doesn't pollute the original fetch. It could break in the future if wasm-bindgen changes the generated code. But, hopefully an in-engine approach lands before this. :-)

doup and others added 4 commits April 20, 2022 09:49
factor progressiveFetch into tools.js for reuse by other pages
@doup
Copy link
Contributor Author

doup commented Apr 21, 2022

@ickk much better!

What do you think on using unpkg links to import the polyfill?

import { ReadableStream as PolyfillReadableStream, TransformStream as PolyfillTransformStream } from 'https://unpkg.com/web-streams-polyfill@3.2.1/dist/ponyfill.es6.mjs';
import { createReadableStreamWrapper } from 'https://unpkg.com/@mattiasbuelens/web-streams-adapter@0.1.0/dist/web-streams-adapter.mjs';

@ickk
Copy link
Member

ickk commented Apr 21, 2022

I don't personally mind using unpkg, but @cart might have a strong opinion one way or the other.


Another idea I had: we could actually factor the whole loading bar thing into a function that takes a canvas-id and returns a custom-fetch anonymous fn. Then the API would be

import init from './{{ page.title }}.js';
import { loadingBarFetch } from '/tools.js';

init(loadingBarFetch('bevy'));

and would let us have as many wasm inits with as many different canvases as we like on a page. In that case it would be better to separate out the relevant css as well, so that it can be selectively included on other pages (like blog posts, et c.).

thoughts?

@doup
Copy link
Contributor Author

doup commented Apr 21, 2022

It could be nice, but I don't know if it's practical right now.

The examples have the canvas ID hardcoded & then we have the JS fetch injection patch that this PR adds… Although, I suppose that the canvas ID could be set per example, just generate an unique id based on the path, patch each example rust file and then compile. But if you want to add an example outside the examples build process, then you'll need to replicate the JS patch and ensure it uses a proper canvas id? It's not a big issue… but I find it fragile.

Where would you use this though? News? I think that my computer would explode if more than one example load/run at the same time… 😅

@ickk
Copy link
Member

ickk commented Apr 21, 2022

You are right that it is a fragile system :/

I think longer term, something like bevy_framepace can probably help prevent blowing up too many computers, as well as not automatically downloading and running bevy instances; this is already pretty egregious with e.g. breakout, where it plays sound.

That said, even if something like a news post would only include a single canvas, being a self contained module would still be tidy (and there's no reason not to allow specifying the canvas-id).

But maybe you were right. Perhaps some kind of holistic web-container stuff should belong in a different PR, and this PR should be just a quick and dirty UX improvement for the examples. 💁‍♀️

@IceSentry
Copy link
Contributor

Would it be possible to get the name of the resource that is being fetched to add somme text like "Loading flight_helmet.gltf" and then only show one loading bar at a time. It just looks like a bug when there's multiple loading bar showing up and showing only one loading bar at a time without text would probably not be great either.

@ickk
Copy link
Member

ickk commented Apr 22, 2022

Would it be possible to get the name of the resource that is being fetched

It would be possible, but work would need to be done on the engine's side (would need to pass the name as an arg to fetch).

It's probably not worth it if we can just add native loading-progress to the engine/AssetServer, and then a game-author can display asset-loading however they like in their game. Then we'll only need the junk in this PR for the wasm-file.

We could pretty easily print just the URL of the resource, if that suffices?

@doup
Copy link
Contributor Author

doup commented Apr 22, 2022

Yup, much better. You'll notice that in the end the progress bar is at half, there is nothing I can do about that. The main thread blocks at that point and the browser doesn't even repaint… Or not, I suppose I could delay the controller.enqueue if I detect that it's the last chunk… 🤔

bevy-example-progress-bar-03.mp4

@doup
Copy link
Contributor Author

doup commented Apr 22, 2022

Actually there was a bug, it didn't call the update callback when 100% of the file was loaded, it just moved into the finish callback. This is it for me.

@cart what do you think about loading the poly-fills from an external service? 👉 #355 (comment)

I might be introducing malicious code via those huge polyfill files… 😈 🙄

@ickk
Copy link
Member

ickk commented Apr 22, 2022

Oh! good catch regarding the bug.

Looks good enough to me!

Copy link
Contributor

@IceSentry IceSentry left a comment

Choose a reason for hiding this comment

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

The filename addition is really nice. I'm not a massive fan of the background effect before loading the wasm, but it's not a deal breaker for me.

Also, using third parties to load polyfill is pretty standard practice on the web so I'm personally fine with it, especially since at worst it will mean there won't be any loading bar, but nothing else would break if for some reason unpkg somehow went down.

@doup
Copy link
Contributor Author

doup commented Apr 23, 2022

Thanks for the reviews!

As all three of us agree, I've removed the poly-fill files and used unpkg instead.
@cart this should be easy to revert if you prefer to have the files instead.

@doup
Copy link
Contributor Author

doup commented Apr 23, 2022

Ah, btw, I added the bg animation as intermediate feedback until the wasm file starts loading… but it's easy to remove if more people don't like it.

@cart
Copy link
Member

cart commented May 4, 2022

I'd prefer to self host the polyfills (for the same reasons we don't use google fonts directly):

  1. User privacy: We don't force our users to send requests to unpkg
  2. Fewer points of failure: if unpkg goes down, we stay up
  3. Security: one less entity in the "trust chain"

@cart
Copy link
Member

cart commented May 4, 2022

I also think I'm in favor of removing the bg animation. Its a bit "loud" atm. I suspect theres an ideal animation out there (maybe a subtle pulse of the background color), but I think I'd prefer to just use a solid color in this PR so we can merge it asap and then follow up later to iterate (if we are so inclined).

@cart
Copy link
Member

cart commented May 4, 2022

With those changes, I'm ready to merge this!

@doup
Copy link
Contributor Author

doup commented May 7, 2022

@cart both issues now are fixed.

Now that I see it, that background loading animation it's probably not necessary. The idea was to show something before the wasm file starts loading… but in reality I think this will happen quickly enough so that the user won't even notice.

@IceSentry IceSentry added the S-Ready-For-Final-Review Ready for a maintainer to consider for merging label May 7, 2022
@cart
Copy link
Member

cart commented May 10, 2022

bors r+

bors bot pushed a commit that referenced this pull request May 10, 2022
This is a proposal for #338.

- Builds on top of the code by @ickk using `TransformStream`.
- Adds loading feedback on examples.
- The solution is hacky, it monkey-patches `fetch` in the example template.

https://user-images.githubusercontent.com/188612/163875627-b11bf330-0fb8-4991-a710-e12e8657fe07.mp4

Co-Authored-By: ickk <17050131+ickk@users.noreply.github.com>


Co-authored-by: ickk <git@ickk.io>
@bors
Copy link

bors bot commented May 10, 2022

Pull request successfully merged into master.

Build succeeded:

@bors bors bot changed the title Improve examples loading feedback [Merged by Bors] - Improve examples loading feedback May 10, 2022
@bors bors bot closed this May 10, 2022
bors bot pushed a commit that referenced this pull request Jul 8, 2022
I think we've ironed out enough of the kinks to justify making the examples page more prominent. We've been sitting on a lot of value here for awhile 😄 

For posterity: big thanks to @mockersf for putting together this feature in #225 and @doup for adding loading feedback in #355 and a bunch of other visual improvements.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Examples C-Webdev S-Ready-For-Final-Review Ready for a maintainer to consider for merging
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

6 participants