Coder Social home page Coder Social logo

bevy_webgl2's People

Contributors

aevyrie avatar billyb2 avatar gcoakes avatar jrobsonchase avatar memoryruins avatar mockersf avatar mrk-its avatar mvlabat avatar ostwilkens avatar richodemus avatar rparrett avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

bevy_webgl2's Issues

Example doesn't build

$ cargo build --release --example sprite --target wasm32-unknown-unknown
...
   Compiling bevy_internal v0.3.0 (https://github.com/bevyengine/bevy#db2d20ec)
   Compiling bevy v0.3.0 (https://github.com/bevyengine/bevy#db2d20ec)
   Compiling bevy_webgl2 v0.3.0 (/tmp/bevy_webgl2)
error[E0432]: unresolved import `bevy::ecs::IntoThreadLocalSystem`
  --> src/lib.rs:16:29
   |
16 | use bevy::ecs::{IntoSystem, IntoThreadLocalSystem, Resources, World};
   |                             ^^^^^^^^^^^^^^^^^^^^^
   |                             |
   |                             no `IntoThreadLocalSystem` in `ecs`
   |                             help: a similar name exists in the module: `ThreadLocalSystemFn`

error[E0599]: no method named `thread_local_system` found for opaque type `impl for<'r, 's> FnMut<(&'r mut World, &'s mut Resources)>` in the current scope
  --> src/lib.rs:90:38
   |
90 |                 handle_events_system.thread_local_system(),
   |                                      ^^^^^^^^^^^^^^^^^^^ method not found in `impl for<'r, 's> FnMut<(&'r mut World, &'s mut Resources)>`
   |
   = note: `handle_events_system` is a function, perhaps you wish to call it

error[E0599]: no method named `thread_local_system` found for opaque type `impl for<'r, 's> FnMut<(&'r mut World, &'s mut Resources)>` in the current scope
  --> src/lib.rs:92:56
   |
92 |             .add_system_to_stage(RENDER, render_system.thread_local_system())
   |                                                        ^^^^^^^^^^^^^^^^^^^ method not found in `impl for<'r, 's> FnMut<(&'r mut World, &'s mut Resources)>`
   |
   = note: `render_system` is a function, perhaps you wish to call it

error: aborting due to 3 previous errors

Some errors have detailed explanations: E0432, E0599.
For more information about an error, try `rustc --explain E0432`.
error: could not compile `bevy_webgl2`

To learn more, run the command again with --verbose.
warning: build failed, waiting for other jobs to finish...
error: build failed

Building on Linux, rustc nightly 1.50.0 2020-11-15

README example failed

I think the documentation should also include:

$ cargo install wasm-bindgen-cli
$ cargo install basic-http-server

Additionally, I think that the script should explicitly set CARGO_TARGET_DIR if it's not set:

$ CARGO_TARGET_DIR=`pwd`/target cargo make example sprite --profile release

Finally, I think a screenshot of a working version would be handy so I know what to expect. Given no explicit debug information, it seems like this is just dead on arrival for me.

Reproducible Steps:

  1. Uninstall wasm-bindgen

  2. Uninstall basic-http-server

  3. Unset CARGO_TARGET_DIR

  4. Then follow along below

Followed along with:

cargo install cargo-make
rustup target add wasm32-unknown-unknown
cargo make example sprite --profile release

And it failed with:

[cargo-make] INFO - Execute Command: "wasm-bindgen" "--remove-name-section" "--remove-producers-section" "--out-dir" "target" "--out-name" "wasm" "--target" "web" "--no-typescript" "${CARGO_TARGET_DIR}/wasm32-unknown-unknown/release/examples/sprite.wasm"
[cargo-make] ERROR - Error while executing command, error: Os {
    code: 2,
    kind: NotFound,
    message: "No such file or directory",
}
[cargo-make] WARN - Build Failed.

So just to make sure, I ran:

wasm-bindgen --remove-name-section --remove-producers-section --out-dir target --out-name wasm --target web --no-typescript target/wasm32-unknown-unknown/release/examples/sprite.wasm 
zsh: command not found: wasm-bindgen

Assumption here is that there's a step missing to install wasm-bindgen.

Googling, it sounds like I could just install wasm-bindgen-cli:

cargo install wasm-bindgen-cli

Once it's installed, the wasm-bindgen command above passed. However, I needed to explicitly add CARGO_TARGET_DIR to my environment:

CARGO_TARGET_DIR=`pwd`/target cargo make example sprite --profile release

The next blocker was lacking basic-http-server. This was resolved with cargo install basic-http-server.

After installing and setting up, I was greeted with an empty page. I'm not sure what I should be expecting.

Problem with version 0.5.0

On linux Ubuntu while setting up a small crossplatform project with version 0.5.0 I get :

error: Please select a feature to build for unix: x11, wayland

This issue was first listed here #42 and with correction in #41 but still, version 0.5.0 does not seem to be working as it still links to winit v0.24.0.

When is the next release planned ? Or is there any way to work around this issue ?
Thanks !

ps: Also not sure that https://github.com/mrk-its/bevy_webgl2_app_template/tree/ad71db7b7d1b91d92e3875cc50d2ddfd166c994a still works.

Light rendering

First off, a huge thanks to @mrk-its for the work on this plugin. I can see a ton of use of this in the future. I will be testing bevy_webgl2 in a project of mine and reporting back when I encounter issues, contributing where I am able.

Light sources are not behaving as expected. They distort colors, and under some circumstances even make a surface darker.
I assume this is known and a work-in-progress, but we can track the progress here.

bevy 0.3.0 3d_scene example
bevy_windows

bevy_webgl2 3d_scene example
bevy_webgl2

GLTF objects are sometimes all blue or colored red

I'm still working on getting my game published, so I'll either get a link to you in an hour or tomorrow. I load three different GLTF files, which you can get here: assets.zip. The file ship.glb should look like this:
Screenshot from 2021-04-23 22-49-21
However, sometimes, it will appear completely blue:
Screenshot from 2021-04-23 22-49-36
And sometimes, colored red:
Screenshot from 2021-04-23 22-49-27

It's pretty much a guessing game as to which will happen.

When this happens, the files ship.glb and Itokawa_1_1.glb (which both have images as their textures) have the same appearance, but cube.glb (which has a material defined by a single color) is completely unaffected. Additionally, any materials with a solid color created directly in Bevy are also unaffected.

This never happens natively, but I've seen it happen on FF and Chrome on Linux (Nvidia and Intel) and Windows (Intel) and Chrome on Chrome OS (Intel).

Text doesn't work if bevy is started within an async function

Maybe the title is a bit inaccurate, but I had trouble rendering text in my game. I looked at the network requests, and saw that the font assets were never requests. Weirdly enough, moving the App::run call out of the async function where I normally start bevy seems to fix the issue.

I.e. this is what I did before:

fn main() {
    wasm_bindgen_futures::spawn_local(async move {
        main_async().await.expect("main failed");
    })
}

async fn main_async() -> Result<(), Box<dyn std::error::Error>> {
    let mut app = App::new();
    app.add_plugins(bevy_webgl2::DefaultPlugins);
    app.add_startup_system(lobby_startup.system()).run();
    Ok(())
}

And this is what works:

fn main() {
    let mut app = App::new();
    app.add_plugins(bevy_webgl2::DefaultPlugins);
    app.add_startup_system(lobby_startup.system()).run();
}

I guess that perhaps running App::run(), which is a blocking call, inside an async function is probably making some other async task unhappy... The only problem is, I don't really understand how to solve this. How can I do async setup before starting bevy if bevy can't be started from an async task and webgl2 doesn't support proper threads?

Opengl native

Would it be easy to adapt this package to work with opengl as the native webGPU on bevy does not recognize my GPU (quadro 2000)?

nothing renders on macOS

when running cargo make example sprite --profile release, nothing renders

Firefox, Chrome and Safari on macOS

panicked at 'called `Option::unwrap()` on a `None` value', src/renderer/webgl2_render_resource_context.rs:551:55

Stack:

init/imports.wbg.__wbg_new_59cb74e423758ede@http://localhost:8000/target/wasm.js:340:19
@http://localhost:8000/target/wasm_bg.wasm:wasm-function[1761]:0x1ad125
@http://localhost:8000/target/wasm_bg.wasm:wasm-function[17779]:0x3af48b
@http://localhost:8000/target/wasm_bg.wasm:wasm-function[4786]:0x2a114e

reverting this commit makes it work again

Make a branch that supports bevy main

I think various people have already done this in their own forks of bevy_webgl2.

I was wondering if it would make sense to coordinate our efforts?

Perhaps having a bevy-main branch in this repo that works with the latest breaking changes in bevy?

That way, when bevy 0.6 is eventually release, we can just merge the bevy-main branch into main?

Conflict with last bevy

PS Z:\Projects\rust_projects\wasm-client\client> cargo build
    Updating crates.io index
error: failed to select a version for `wasm-bindgen`.
    ... required by package `bevy_webgl2 v0.5.0`
    ... which satisfies dependency `bevy_webgl2 = "^0.5"` of package `wasm-client v0.1.0 (Z:\Projects\rust_projects\wasm-client\client)`
versions that meet the requirements `=0.2.69` are: 0.2.69

all possible versions conflict with previously selected packages.

  previously selected package `wasm-bindgen v0.2.83`
    ... which satisfies dependency `wasm-bindgen = "^0.2.83"` of package `js-sys v0.3.60`
    ... which satisfies dependency `js-sys = "^0.3.60"` of package `wasm-bindgen-futures v0.4.33`
    ... which satisfies dependency `wasm-bindgen-futures = "^0.4.33"` of package `wgpu v0.14.0`
    ... which satisfies dependency `wgpu = "^0.14.0"` of package `bevy_render v0.9.0`
    ... which satisfies dependency `bevy_render = "^0.9.0"` of package `bevy_core_pipeline v0.9.0`
    ... which satisfies dependency `bevy_core_pipeline = "^0.9.0"` of package `bevy_gltf v0.9.0`
    ... which satisfies dependency `bevy_gltf = "^0.9.0"` of package `bevy_internal v0.9.0`
    ... which satisfies dependency `bevy_internal = "^0.9.0"` of package `bevy v0.9.0`
    ... which satisfies dependency `bevy = "^0.9"` of package `bevy-web-resizer v4.0.0`
    ... which satisfies dependency `bevy-web-resizer = "^4.0"` of package `wasm-client v0.1.0 (Z:\Projects\rust_projects\wasm-client\client)`

failed to select a version for `wasm-bindgen` which could resolve this conflict
PS Z:\Projects\rust_projects\wasm-client\client> cargo build
    Updating crates.io index
error: failed to select a version for `wasm-bindgen`.
    ... required by package `bevy_webgl2 v0.5.0`
    ... which satisfies dependency `bevy_webgl2 = "^0.5"` of package `wasm-client v0.1.0 (Z:\Projects\rust_projects\wasm-client\client)`
versions that meet the requirements `=0.2.69` are: 0.2.69

all possible versions conflict with previously selected packages.

  previously selected package `wasm-bindgen v0.2.83`
    ... which satisfies dependency `wasm-bindgen = "^0.2.83"` of package `js-sys v0.3.60`
    ... which satisfies dependency `js-sys = "^0.3.60"` of package `wasm-bindgen-futures v0.4.33`
    ... which satisfies dependency `wasm-bindgen-futures = "^0.4.33"` of package `wgpu v0.14.0`
    ... which satisfies dependency `wgpu = "^0.14.0"` of package `bevy_render v0.9.0`
    ... which satisfies dependency `bevy_render = "^0.9.0"` of package `bevy_core_pipeline v0.9.0`
    ... which satisfies dependency `bevy_core_pipeline = "^0.9.0"` of package `bevy_gltf v0.9.0`
    ... which satisfies dependency `bevy_gltf = "^0.9.0"` of package `bevy_internal v0.9.0`
    ... which satisfies dependency `bevy_internal = "^0.9.0"` of package `bevy v0.9.0`
    ... which satisfies dependency `bevy = "^0.9"` of package `wasm-client v0.1.0 (Z:\Projects\rust_projects\wasm-client\client)`

failed to select a version for `wasm-bindgen` which could resolve this conflict

Colors rendered differently compared to bevy default renderer

I've tried to render simple mesh with vertex colors:

mesh.set_attribute(Mesh::ATTRIBUTE_COLOR, vec![[0.7, 0.2, 0.2]; buffers.vertices.len()]);

and looks like webgl2 in this case interprets color as sRGB, and bevy as linearRGB
using same code in both (left is web):
same

but if in native version I convert color from sRGB to linear first, then result color will be the same

let color = Color::rgb(0.7, 0.2, 0.2).as_linear_rgba_f32();
mesh.set_attribute(
    Mesh::ATTRIBUTE_COLOR,
    vec![[color[0], color[1], color[2]]; buffers.vertices.len()],
);

to_linear

Failed to select a version for 'wasm-bindgen'

Im adding the required dependencies to my .toml file. I keep running into an error "failed to select a version for 'wasm-bindgen'.

Here is my toml file dependencies:

[dependencies]
bevy = {version = "0.5.0", default-features = false}
bevy_webgl2 = "0.5.2"
cfg-if = "1.0.0"
js-sys = "0.3.50"
parking_lot = "0.11.0"
regex = "1.4"
wasm-bindgen = "0.2.69"
web-sys = {version = "0.3.50", features = [
  'Document',
  'Element',
  'HtmlCanvasElement',
  'WebGlBuffer',
  'WebGlRenderingContext',
  'WebGl2RenderingContext',
  'WebGlProgram',
  'WebGlShader',
  'Window',
  'WebGlFramebuffer',
  'WebGlTexture',
  'WebGlUniformLocation',
  'WebGlActiveInfo',
  'WebGlVertexArrayObject',
  'WebGlSync',
]}
winit = {version = "0.24.0", features = ["web-sys"]}

[dev-dependencies]
compile-time-run = "0.2"
getrandom = {version = "0.2.3", features = ["wasm-bindgen"]}
rand = "0.8"

Here is the error:

error: failed to select a version for `wasm-bindgen`.
    ... required by package `js-sys v0.3.50`
    ... which is depended on by `bevy_blazor v0.1.0 (C:\Users\Andrew\Desktop\code\projects\Blazor-Bevy\Blazor-Bevy)`
versions that meet the requirements `^0.2.73` are: 0.2.74, 0.2.73

all possible versions conflict with previously selected packages.

  previously selected package `wasm-bindgen v0.2.69`
    ... which is depended on by `bevy_webgl2 v0.5.2`
    ... which is depended on by `bevy_blazor v0.1.0 (C:\Users\Andrew\Desktop\code\projects\Blazor-Bevy\Blazor-Bevy)`

failed to select a version for `wasm-bindgen` which could resolve this conflict

I've changed the version for wasm-bindgen back and forth but no luck.

Latest Winit Version Breaks bevy_webgl2

When using the latest bevy git commit (master branch of this repo), I get the following build error:

error: Please select a feature to build for unix: x11, wayland
--> /home/billy/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.25.0/src/platform_impl/linux/mod.rs:10:1
|
10 | compile_error!("Please select a feature to build for unix: x11, wayland");
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0392]: parameter T is never used
--> /home/billy/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.25.0/src/event_loop.rs:32:22
|
32 | pub struct EventLoop<T: 'static> {
| ^ unused parameter
|
= help: consider removing T, referring to it in a field, or using a marker such as PhantomData
= help: if you intended T to be a const parameter, use const T: usize instead

error[E0392]: parameter T is never used
--> /home/billy/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.25.0/src/event_loop.rs:43:34
|
43 | pub struct EventLoopWindowTarget<T: 'static> {
| ^ unused parameter
|
= help: consider removing T, referring to it in a field, or using a marker such as PhantomData
= help: if you intended T to be a const parameter, use const T: usize instead

error[E0392]: parameter T is never used
--> /home/billy/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.25.0/src/event_loop.rs:196:27
|
196 | pub struct EventLoopProxy<T: 'static> {
| ^ unused parameter
|
= help: consider removing T, referring to it in a field, or using a marker such as PhantomData
= help: if you intended T to be a const parameter, use const T: usize instead

error[E0392]: parameter T is never used
--> /home/billy/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.25.0/src/platform_impl/linux/mod.rs:543:20
|
543 | pub enum EventLoop<T: 'static> {
| ^ unused parameter
|
= help: consider removing T, referring to it in a field, or using a marker such as PhantomData
= help: if you intended T to be a const parameter, use const T: usize instead

error[E0392]: parameter T is never used
--> /home/billy/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.25.0/src/platform_impl/linux/mod.rs:550:25
|
550 | pub enum EventLoopProxy<T: 'static> {
| ^ unused parameter
|
= help: consider removing T, referring to it in a field, or using a marker such as PhantomData
= help: if you intended T to be a const parameter, use const T: usize instead

error[E0392]: parameter T is never used
--> /home/billy/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.25.0/src/platform_impl/linux/mod.rs:676:32
|
676 | pub enum EventLoopWindowTarget {
| ^ unused parameter
|
= help: consider removing T, referring to it in a field, or using a marker such as PhantomData
= help: if you intended T to be a const parameter, use const T: usize instead

Compiling bytemuck v1.5.1
error: aborting due to 7 previous errors

For more information about this error, try rustc --explain E0392.
error: could not compile winit

To learn more, run the command again with --verbose.
warning: build failed, waiting for other jobs to finish...

repo does not compile anymore

Hi,

When I try on apple m1 to compile the repository with this command :

cargo make

I've got this :

[cargo-make] INFO - cargo make 0.35.6
[cargo-make] INFO - Project: bevy_webgl2
[cargo-make] INFO - Build File: Makefile.toml
[cargo-make] INFO - Task: default
[cargo-make] INFO - Profile: development
[cargo-make] INFO - Running Task: legacy-migration
[cargo-make] INFO - Execute Command: "cargo" "fmt"
[cargo-make] INFO - Execute Command: "cargo" "build" "--all-features"
   Compiling bevy_log v0.5.0
error[E0277]: the trait bound `WASMLayer: __tracing_subscriber_Layer<Layered<EnvFilter, Registry>>` is not satisfied
  --> /Users/syl/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_log-0.5.0/src/lib.rs:92:46
   |
92 |               let subscriber = subscriber.with(tracing_wasm::WASMLayer::new(
   |  ______________________________________________^
93 | |                 tracing_wasm::WASMLayerConfig::default(),
94 | |             ));
   | |_____________^ the trait `__tracing_subscriber_Layer<Layered<EnvFilter, Registry>>` is not implemented for `WASMLayer`

error[E0277]: the trait bound `WASMLayer: __tracing_subscriber_Layer<Layered<EnvFilter, Registry>>` is not satisfied
  --> /Users/syl/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_log-0.5.0/src/lib.rs:95:65
   |
95 |             bevy_utils::tracing::subscriber::set_global_default(subscriber)
   |                                                                 ^^^^^^^^^^ the trait `__tracing_subscriber_Layer<Layered<EnvFilter, Registry>>` is not implemented for `WASMLayer`
   | 
  ::: /Users/syl/.cargo/registry/src/github.com-1ecc6299db9ec823/tracing-0.1.29/src/subscriber.rs:41:8
   |
41 |     S: Subscriber + Send + Sync + 'static,
   |        ---------- required by this bound in `bevy_utils::tracing::subscriber::set_global_default`
   |
   = note: required because of the requirements on the impl of `bevy_utils::tracing::Subscriber` for `Layered<WASMLayer, Layered<EnvFilter, Registry>>`

For more information about this error, try `rustc --explain E0277`.
error: could not compile `bevy_log` due to 2 previous errors
[cargo-make] ERROR - Error while executing command, exit code: 101
[cargo-make] WARN - Build Failed.

Does I miss something ?

Thanks for your help.

Panic on Firefox

Getting this error when trying to run examples on firefox:

'called `Result::unwrap()` on an `Err` value: "ERROR: 0:346: \'for\' : Invalid condition\n"', /home/intendednull/.cargo/git/checkouts/bevy_webgl2-bb0e279954ae087c/33dda29/src/renderer/webgl2_render_resource_context.rs:77:81

sprite.rs works, however 3d_scene.rs and breakout.rs do not. Let me know if I should test any other examples. Problem is present on latest release, master, and dev branch.

It was working until FF updated, so maybe a configuration setting was tweaked? Tried toggling every webgl2 setting I could find with no luck. Also tried a fresh install of both FF developer and stable.

System details:

$ screenfetch -n
 OS: Manjaro 21.0 Ornara
 Kernel: x86_64 Linux 5.10.23-1-MANJARO
 Shell: fish 3.1.2
 WM: XMonad
 CPU: AMD Ryzen 7 3700X 8-Core @ 16x 3.6GHz
 GPU: GeForce GTX 1070 Ti
 RAM: 10674MiB / 24034MiB
$ firefox-developer-edition --version
Mozilla Firefox 87.0b9

WebGL2 does appear to be enabled on my system:
image

White Screen Panic on Safari 14.0.1 iOS 14.2.1

User-agent: Mozilla/5.0 (iPhone; CPU iPhone OS 14_2_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0.1 Mobile/15E148 Safari/604.1
bevy_webgl2 version: https://github.com/indiv0/bevy_webgl2/tree/a53c9ca296a46019d833da9be6f69f099ac63159
bevy version: https://github.com/bevyengine/bevy/tree/2e2423139e0cd8efda3aa0d474d3eb231dad566b
Example source: https://github.com/indiv0/colonize/tree/75ee66f710a4b9444a4b2119f27422e6fdeb3723
Example compilation args:

cargo build --target wasm32-unknown-unknown --no-default-features --features wasm
wasm-bindgen --out-dir target --target web target/wasm32-unknown-unknown/debug/colonize.wasm
wasm-opt --debuginfo -Oz target/colonize_bg.wasm -o target/colonize_bg_opt.wasm
sed -i 's/_bg\.wasm/_bg_opt\.wasm/g' target/colonize.js

Example demo: https://dev.colonize.rs/
rustc version: rustc 1.50.0-nightly (f0f68778f 2020-12-09)

Hello! I'm trying to get my little voxel demo running on Safari on my iPhone, but all I'm seeing is a white screen.
These are the two error logs I'm seeing in the console:

colonize.js:353 panicked at 'called `Option::unwrap()` on a `None` value', /home/indiv0/.cargo/git/checkouts/bevy_webgl2-35250a857a3fcf31/a53c9ca/src/renderer/webgl2_render_resource_context.rs:97:14

Stack:

https://dev.colonize.rs/target/colonize.js:340:28
wasm-stub@[wasm code]
<?>.wasm-function[console_error_panic_hook::hook::hc8d5a98bcd201a39]@[wasm code]
<?>.wasm-function[core::ops::function::Fn::call::h3a520772681b692a]@[wasm code]
<?>.wasm-function[std::panicking::rust_panic_with_hook::h7ba07724d623fbd6]@[wasm code]
<?>.wasm-function[std::panicking::begin_panic_handler::{{closure}}::hf841a66ae6cb12c2]@[wasm code]
<?>.wasm-function[std::sys_common::backtrace::__rust_end_short_backtrace::h1aceb706833fcda2]@[wasm code]
<?>.wasm-function[rust_begin_unwind]@[wasm code]
<?>.wasm-function[core::panicking::panic_fmt::h125c8438143be5c3]@[wasm code]
<?>.wasm-function[core::panicking::panic::heade1ff345fea9ee]@[wasm code]
<?>.wasm-function[bevy_webgl2::renderer::webgl2_render_resource_context::WebGL2RenderResourceContext::initialize::ha3ac448d6c7c24b1]@[wasm code]
<?>.wasm-function[bevy_ecs::system::into_thread_local::<impl bevy_ecs::system::into_system::IntoSystem<(&mut bevy_ecs::core::world::World,&mut bevy_ecs::resource::resources::Resources),bevy_ecs::system::into_thread_local::ThreadLocalSystemFn> for F>::system::{{closure}}::h1409f7ef8aeb77d5]@[wasm code]
<?>.wasm-function[<bevy_ecs::system::into_thread_local::ThreadLocalSystemFn as bevy_ecs::system::system::System>::run_thread_local::h66d19defcf4ac825]@[wasm code]
<?>.wasm-function[<bevy_ecs::schedule::stage_executor::ParallelSystemStageExecutor as bevy_ecs::schedule::stage_executor::SystemStageExecutor>::execute_stage::h19c518754b474e51]@[wasm code]
<?>.wasm-function[<bevy_ecs::schedule::stage::SystemStage as bevy_ecs::schedule::stage::Stage>::run::ha482b36f9d8fd659]@[wasm code]
<?>.wasm-function[<bevy_ecs::schedule::Schedule as bevy_ecs::schedule::stage::Stage>::run::h46d0126e783dceb8]@[wasm code]
<?>.wasm-function[bevy_ecs::schedule::Schedule::initialize_and_run::h640e873cc53daab8]@[wasm code]
<?>.wasm-function[winit::platform_impl::platform::event_loop::EventLoop<T>::run::{{closure}}::h9c6289f041abba57]@[wasm code]
<?>.wasm-function[winit::platform_impl::platform::event_loop::runner::Shared<T>::handle_event::he1ae5c97e87f3cc2]@[wasm code]
<?>.wasm-function[winit::platform_impl::platform::event_loop::runner::Shared<T>::run_until_cleared::hdf6a9e2c1eddd23a]@[wasm code]
<?>.wasm-function[winit::platform_impl::platform::event_loop::runner::Shared<T>::set_listener::h68fd5ec39c25b8cb]@[wasm code]
<?>.wasm-function[winit::platform_impl::platform::event_loop::window_target::WindowTarget<T>::run::h3ecec7a408ed3963]@[wasm code]
<?>.wasm-function[winit::platform_impl::platform::event_loop::EventLoop<T>::run::hfae39a3100b437f3]@[wasm code]
<?>.wasm-function[bevy_winit::winit_runner::h0bcb21bb1ddfac59]@[wasm code]
<?>.wasm-function[core::ops::function::Fn::call::h1b29df3455b46949]@[wasm code]
<?>.wasm-function[bevy_app::app_builder::AppBuilder::run::h37e056c5fdfb003c]@[wasm code]
<?>.wasm-function[colonize::main::ha827ff1ad819c552]@[wasm code]
<?>.wasm-function[std::rt::lang_start::{{closure}}::h00c8646e66105f2b]@[wasm code]
<?>.wasm-function[std::rt::lang_start_internal::he20668ad5870f3e0]@[wasm code]
<?>.wasm-function[main]@[wasm code]
<?>.wasm-function[13174]@[wasm code]
wasm-stub@[wasm code]
__wbindgen_start@[native code]
https://dev.colonize.rs/target/colonize.js:987:26
asyncFunctionResume@[native code]
[native code]
promiseReactionJobWithoutPromise@[native code]
promiseReactionJob@[native code]
Unhandled Promise Rejection: RuntimeError: Unreachable code should not be executed (evaluating 'wasm.__wbindgen_start()')

Text is wavier than expected

Discovered this while testing bevy-debug-menu in a bare bones bevy_webgl2_app_template.

webgl2-text-wave

This gif is cycling between screenshots of the same app running with webgl2 and natively (macOS, high dpi).

I think that this could be related to bevyengine/bevy@b8fb462.

At least, the equivalent bevy_webgl2 shader still has the ceil in the last line.

I may look into this further at some point, but likely not for a good while.

WebAssembly crashing when loading mesh from loaded texture

Bevy version

0.4

Operating system & version

Ubuntu 18.04

What you did

Change the build from default bevy to wasm

What you expected to happen

Should be able to load and process the skybox

What actually happened

It is crashing

Additional information
Working default bevy commit: chaoticgood1/bevytest@d65065b

Wasm not working commit: chaoticgood1/bevytest@e48d689

Cause of error in bevytest/src/bevy_skybox/image.rs line 126 or 127, commenting either one of them makes the panicking goes away, but won't render anything. Hope this is helpful, thanks.

Error logs

panicked at 'called `Option::unwrap()` on a `None` value', /home/nickan/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_webgl2-0.4.2/src/webgl2_render_pass.rs:228:89

Stack:

Error
    at imports.wbg.__wbg_new_59cb74e423758ede (http://127.0.0.1:4000/target/wasm.js:377:19)
    at console_error_panic_hook::Error::new::hc91ec718933cceed (http://127.0.0.1:4000/target/wasm_bg.wasm:wasm-function[131916]:0x815b1f)
    at console_error_panic_hook::hook_impl::h9ad56955303e5175 (http://127.0.0.1:4000/target/wasm_bg.wasm:wasm-function[7982]:0x37a319)
    at console_error_panic_hook::hook::h855ef18b67e7ea42 (http://127.0.0.1:4000/target/wasm_bg.wasm:wasm-function[131915]:0x815b19)
    at core::ops::function::Fn::call::hfa8ec601b2d06713 (http://127.0.0.1:4000/target/wasm_bg.wasm:wasm-function[131886]:0x815a20)
    at std::panicking::rust_panic_with_hook::ha2032d5112bb8441 (http://127.0.0.1:4000/target/wasm_bg.wasm:wasm-function[5147]:0x2ed20b)
    at std::panicking::begin_panic_handler::{{closure}}::hae464eed10d0d166 (http://127.0.0.1:4000/target/wasm_bg.wasm:wasm-function[44067]:0x660b88)
    at std::sys_common::backtrace::__rust_end_short_backtrace::hb5a638417526adb2 (http://127.0.0.1:4000/target/wasm_bg.wasm:wasm-function[47112]:0x6839b4)
    at rust_begin_unwind (http://127.0.0.1:4000/target/wasm_bg.wasm:wasm-function[32814]:0x5c9cd1)
    at core::panicking::panic_fmt::h9021786fae10a3ab (http://127.0.0.1:4000/target/wasm_bg.wasm:wasm-function[47114]:0x683a1a)

Control canvas window size by rust code ?

WindowDescriptor is useless on the canvas window. If use js to control the size, it is also difficult to let rust know the concrete window's size.
Would it be better to add a new resource like CanvasWindowDescriptor or something to store user-defined size? Then we can set the inner size of the canvas before its initialized.

Desktop GL Support Through Glow

I was wondering whether or not you would be open to supporting desktop GL through use of the glow library.

I've succesfully ported a Rust WebGL2 renderer ( luminance-webgl ) to run on desktop with glow before and it was, for the most part, quite straight-forward. Would you be open to a pull request for that? I'm not positive this is something I will do, but I wanted to make sure that it was something you would be open to.

Panic in setup_vao (parking not supported) when using meshes without index arrays

The panic:

panicked at 'Parking not supported on this platform', C:\Users\Johan\.cargo\registry\src\github.com-1ecc6299db9ec823\parking_lot_core-0.8.3\src\thread_parker\wasm.rs:26:9

Stack:

Error
    at imports.wbg.__wbg_new_59cb74e423758ede (http://127.0.0.1:4000/target/wasm.js:368:19)
    at console_error_panic_hook::hook::hbf023161a6dac3e1 (http://127.0.0.1:4000/target/wasm_bg.wasm:wasm-function[3346]:0x465a0e)
    at core::ops::function::Fn::call::h1ca14bbebcfe87b9 (http://127.0.0.1:4000/target/wasm_bg.wasm:wasm-function[26016]:0x6f1d15)
    at std::panicking::rust_panic_with_hook::h1cacc8da6d7d1d07 (http://127.0.0.1:4000/target/wasm_bg.wasm:wasm-function[7156]:0x5bbc8e)
    at std::panicking::begin_panic::{{closure}}::h1a0c076847e21f44 (http://127.0.0.1:4000/target/wasm_bg.wasm:wasm-function[16842]:0x6c87b6)
    at std::sys_common::backtrace::__rust_end_short_backtrace::hb665934a9d09528b (http://127.0.0.1:4000/target/wasm_bg.wasm:wasm-function[16468]:0x6c4548)
    at std::panicking::begin_panic::hdfad4ef5d0e31977 (http://127.0.0.1:4000/target/wasm_bg.wasm:wasm-function[16843]:0x6c87e3)
    at <parking_lot_core::thread_parker::imp::ThreadParker as parking_lot_core::thread_parker::ThreadParkerT>::prepare_park::h803f74716b9affe2 (http://127.0.0.1:4000/target/wasm_bg.wasm:wasm-function[21913]:0x6e6d91)
    at parking_lot::raw_rwlock::RawRwLock::wait_for_readers::he74301f24c6b8ffc (http://127.0.0.1:4000/target/wasm_bg.wasm:wasm-function[382]:0x137498)
    at parking_lot::raw_rwlock::RawRwLock::lock_exclusive_slow::hcbae9234ea6fcc16 (http://127.0.0.1:4000/target/wasm_bg.wasm:wasm-function[963]:0x26847a)

imports.wbg.__wbg_error_4bb6c2a97407129a	@	wasm.js:380
$console_error_panic_hook::hook::hbf023161a6dac3e1	@	wasm_bg.wasm:0x465afc
$core::ops::function::Fn::call::h1ca14bbebcfe87b9	@	wasm_bg.wasm:0x6f1d15
$std::panicking::rust_panic_with_hook::h1cacc8da6d7d1d07	@	wasm_bg.wasm:0x5bbc8e
$std::panicking::begin_panic::{{closure}}::h1a0c076847e21f44	@	wasm_bg.wasm:0x6c87b6
$std::sys_common::backtrace::__rust_end_short_backtrace::hb665934a9d09528b	@	wasm_bg.wasm:0x6c4548
$std::panicking::begin_panic::hdfad4ef5d0e31977	@	wasm_bg.wasm:0x6c87e3
$<parking_lot_core::thread_parker::imp::ThreadParker as parking_lot_core::thread_parker::ThreadParkerT>::prepare_park::h803f74716b9affe2	@	wasm_bg.wasm:0x6e6d91
$parking_lot::raw_rwlock::RawRwLock::wait_for_readers::he74301f24c6b8ffc	@	wasm_bg.wasm:0x137498
$parking_lot::raw_rwlock::RawRwLock::lock_exclusive_slow::hcbae9234ea6fcc16	@	wasm_bg.wasm:0x26847a
$bevy_webgl2::webgl2_render_pass::WebGL2RenderPass::setup_vao::h9077b991f8d3f71d	@	wasm_bg.wasm:0xed68b
$<bevy_webgl2::webgl2_render_pass::WebGL2RenderPass as bevy_render::pass::render_pass::RenderPass>::draw::h1cb0e0162340374e	@	wasm_bg.wasm:0x51b678
$<bevy_render::render_graph::nodes::pass_node::PassNode<Q> as bevy_render::render_graph::node::Node>::update::{{closure}}::h9f8683abfcbcd0c7	@	wasm_bg.wasm:0x142fe7
$<bevy_webgl2::renderer::webgl2_render_context::WebGL2RenderContext as bevy_render::renderer::render_context::RenderContext>::begin_pass::hcd0fa5d3aec0a2d5	@	wasm_bg.wasm:0x1da7a4
$<bevy_render::render_graph::nodes::pass_node::PassNode<Q> as bevy_render::render_graph::node::Node>::update::h1fd598cff830f549	@	wasm_bg.wasm:0x150918
$bevy_ecs::world::World::resource_scope::h731c1bfd47d69791	@	wasm_bg.wasm:0xe1364
$bevy_webgl2::webgl2_renderer::WebGL2Renderer::update::h2aafb1fbc9883935	@	wasm_bg.wasm:0x47acac
$bevy_webgl2::webgl2_render_system::{{closure}}::haf638a172eebcee1	@	wasm_bg.wasm:0x6edfee
$<bevy_ecs::system::exclusive_system::ExclusiveSystemFn as bevy_ecs::system::exclusive_system::ExclusiveSystem>::run::h8c7141e5d50d575d	@	wasm_bg.wasm:0x68faa9
$<bevy_ecs::schedule::stage::SystemStage as bevy_ecs::schedule::stage::Stage>::run::h9a10e262690ecfd5	@	wasm_bg.wasm:0x3ba0f


$<bevy_ecs::schedule::Schedule as bevy_ecs::schedule::stage::Stage>::run::h3f349963010e4d9c	@	wasm_bg.wasm:0x558882
$bevy_app::app::App::update::h72c9226c09befbe8	@	wasm_bg.wasm:0x6e6c9c
$winit::platform_impl::platform::event_loop::EventLoop<T>::run::{{closure}}::h6d94cd94771d3614	@	wasm_bg.wasm:0x9627d
$winit::platform_impl::platform::event_loop::runner::Shared<T>::handle_event::h05075fde8523b8b5	@	wasm_bg.wasm:0x375d17
$winit::platform_impl::platform::event_loop::runner::Shared<T>::run_until_cleared::h48adc2b939bd7981	@	wasm_bg.wasm:0x368cbd
$winit::platform_impl::platform::event_loop::runner::Shared<T>::set_listener::hf9889df3a4cadda9	@	wasm_bg.wasm:0x4be04a
$winit::platform_impl::platform::event_loop::window_target::WindowTarget<T>::run::h6439e059a8c18b0d	@	wasm_bg.wasm:0x5f9236
$winit::platform_impl::platform::event_loop::EventLoop<T>::run::hd643cac313942d48	@	wasm_bg.wasm:0x66627e
$winit::event_loop::EventLoop<T>::run::h20f4eb005b2e1e09	@	wasm_bg.wasm:0x6c7c2a
$bevy_winit::run::hf70fcdb45beac0a5	@	wasm_bg.wasm:0x6c7c52
async function (async)		
init	@	wasm.js:1095
(anonymous)	@	(index):26
Show 16 more frames

Example mesh:

        let extent_x = 1.0 as f32;
        let extent_y = 1.0 as f32;

        let north_west = vec2(-extent_x, extent_y);
        let north_east = vec2(extent_x, extent_y);
        let south_west = vec2(-extent_x, -extent_y);
        let south_east = vec2(extent_x, -extent_y);
        let vertices = [ 
            [south_east.x, south_east.y, 0.0],
            [north_east.x, north_east.y, 0.0],
            [north_west.x, north_west.y, 0.0],
            [south_west.x, south_west.y, 0.0],
        ];

        let indices = Indices::U32(vec![0, 2, 1, 0, 3, 2]);

        let mut positions = Vec::<[f32; 3]>::new();
        for position in vertices.iter() {
            positions.push(*position);
        }

        let mut mesh = Mesh::new(PrimitiveTopology::TriangleStrip);
        // mesh.set_indices(Some(indices)); // ### Crashes without this line
        mesh.set_attribute(Mesh::ATTRIBUTE_POSITION, positions);
        mesh

I tracked it down to this line:

let mut pipelines = resources.pipelines.write();

Not sure how to debug further, it's getting a bit too far outside my comfort zone. I'll just use index arrays instead even though I don't really need them.

text_debug + Robbo example bugged in Firefox

The text_debug example is bugged (for me) using the latest Firefox and Firefox Developer Edition on Windows 10.

As you can see below - it will render everything for 2 or 3 frames, but then stop rendering part of the example:
broken_text_debug

Chrome displays the example without any problems.

WebGL 1

I am trying to get my bevy app to run on older versions of safari, how difficult would it be to convert the code here to run on WebGL 1 instead of 2?

Build fails with recent bevy master

due to bevyengine/bevy#1236

error[E0046]: not all trait items implemented, missing: `copy_texture_to_buffer`, `copy_texture_to_texture`
  --> /Users/robparrett/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_webgl2-0.4.2/src/renderer/webgl2_render_context.rs:29:1
   |
29 | impl RenderContext for WebGL2RenderContext {
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `copy_texture_to_buffer`, `copy_texture_to_texture` in implementation
   |
   = help: implement the missing item: `fn copy_texture_to_buffer(&mut self, _: TextureId, _: [u32; 3], _: u32, _: BufferId, _: u64, _: u32, _: Extent3d) { todo!() }`
   = help: implement the missing item: `fn copy_texture_to_texture(&mut self, _: TextureId, _: [u32; 3], _: u32, _: TextureId, _: [u32; 3], _: u32, _: Extent3d) { todo!() }`

error: aborting due to previous error

iOS is not supported

I guess this is due to the choice of the API webGL 2 which is not supported by Apple. Any way to get around this issue?

vsync

When #28 is implemented add vsync option

Shader compilation panics

First of all, a major thanks for making this software! With bevy_webgl2, I can now run my (still relavely simple) 2D game in the browser.

Sadly, this only worked fine when I was simply drawing geometric squares on a window. Since I actually went beyond drawing simple squares and started loading a tilemap and spawning a small dungeon, I got the following error in my browser at runtime:

hiveworld.js:359 panicked at 'called `Result::unwrap()` on an `Err` value: "ERROR: 0:1: \'\n\' : invalid version directive\nERROR: 0:5: \'layout\' : syntax error\n\u{0}"', /home/zaszi/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_webgl2-0.4.2/src/renderer/webgl2_render_resource_context.rs:74:81

When digging into what this is actually referring to, it seems my project specifically breaks on shader compilation within bevy_webgl2:

match &shader.source {
            ShaderSource::Glsl(source) => {
                info!("compiling shader: {:?}", source);
                compile_shader(&self.device.get_context(), shader_type, source).unwrap()
            }
            _ => {
                panic!("unsupported shader format");
            }
        }

Here are the relevant bits of my Cargo.toml (note: conditional dependency features are a nightly-only feature gated behind the -Zfeatures=itarget flag and won't work on stable). Additionally, the game runs perfectly fine natively on Linux.

[lib]
crate-type = ["cdylib", "rlib"]

[features]
default = []

[dependencies]
wasm-bindgen = "0.2"
# bevy_tilemap = "0.3"
bevy_tilemap = { git = "https://github.com/joshuajbouw/bevy_tilemap.git", rev = "a0d26fc" }
oorandom = "11.1"

[dev-dependencies]
wasm-bindgen-test = "0.2"

[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
bevy = {version = "0.4", default-features = false, features = ["bevy_dynamic_plugin", "bevy_wgpu", "bevy_winit", "png", "render", "x11", "wayland"]}
getrandom = "0.2"

[target.'cfg(target_arch = "wasm32")'.dependencies]
bevy = {version = "0.4", default-features = false, features = ["bevy_winit", "png", "render"]}
bevy_webgl2 = "0.4"
console_error_panic_hook = "0.1"
getrandom = { version = "0.1", features = ["wasm-bindgen"] }
wee_alloc = "0.4"

[profile.release]
lto = true
panic = "abort"

Browser: Qutebrowser, but happens on Firefox and likely others too.
Rustc: 1.51.0-nightly (a62a76047 2021-01-13)
Distribution: wasm-pack, I manually host the wasm, js and asset files.

I'm at a bit of a loss as where to continue troubleshooting this. I'm not doing anything unique or special with Bevy (yet) that isn't common in examples, besides the usage of bevy_tilemap (which should work on WASM). Perhaps someone can point me in the right direction here?

Breakout example: ball disappeared from the game.

I modified the source code of the breakout example to match the original code in bevyengine/examples
that is, put the bottom wall back so that the ball is confined always.

I leave the browser tab unattended for a quite long amount of time. After a while, all the bricks are cleared by the bouncing ball.

The issue is:
At some indeterminate time, the bouncing ball just disappeared from the game.
(The paddle is still there and controllable as normal)
I have not with my own eyes seen the point of time of disappearance, so I cannot say how long it takes to happen.

Using Windows 10, latest rust, master branch of bevyengine, master branch of this repo
Using nightly rust.

I tried to reproduce the issue on a Windows10 breakout build, but I was not able to completely do so because minimizing the window crashes the program (known issue at bevyengine). I did not also try to reproduce the issue by just overlapping the window.

Reporting this issue as it may be a commonly-seen problem, e.g. scenario of people playing long-running games in the browser, expecting everything to work and be there coming back after a 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.