-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
WebGL: INVALID_OPERATION drawArrays with repo #5732
Copy link
Copy link
Closed
Labels
A-RenderingDrawing game state to the screenDrawing game state to the screenC-BugAn unexpected or incorrect behaviorAn unexpected or incorrect behaviorO-WebSpecific to web (WASM) buildsSpecific to web (WASM) builds
Description
Bevy version
0.8.0
Relevant system information
- WASM builds
`AdapterInfo { name: "ANGLE (NVIDIA, NVIDIA GeForce GTX 1080 Ti Direct3D11 vs_5_0 ps_5_0, D3D11)", vendor: 4318, device: 0, device_type: Other, backend: Gl }}`What you did
Creating a color material and/or mesh then removing the entity that is rendering it triggers an error in the console.
The minimal repo case is located here for easy cloning + running via trunk: https://github.com/AlexOkafor/bevy_webgl_invalid_op_repo
Relevant code below:
use std::time::Duration;
use bevy::{prelude::*, sprite::MaterialMesh2dBundle};
fn main() {
App::new()
.add_plugins(DefaultPlugins)
.add_startup_system(setup)
.add_system(update_ticker)
.run();
}
#[derive(Component)]
struct Ticker {
timer: Timer,
}
fn setup(
mut cmd: Commands,
mut meshes: ResMut<Assets<Mesh>>,
mut materials: ResMut<Assets<ColorMaterial>>,
) {
// This is needed otherwise the invalid operation will not fire.
cmd.spawn_bundle(Camera2dBundle {
..Default::default()
});
cmd.spawn()
.insert(Ticker {
timer: Timer::new(Duration::from_secs(5), false),
})
.insert_bundle(MaterialMesh2dBundle {
mesh: meshes.add(shape::Quad::default().into()).into(),
material: materials.add(ColorMaterial::from(Color::WHITE)),
transform: Transform::from_translation(Vec3::new(0.0, 0.0, 1.0)),
..Default::default()
});
}
// delete the entity after 5 seconds.
fn update_ticker(mut cmd: Commands, time: Res<Time>, mut q: Query<(Entity, &mut Ticker)>) {
for (e, mut t) in q.iter_mut() {
t.timer.tick(time.delta());
if t.timer.just_finished() {
cmd.entity(e).despawn();
}
}
}What went wrong
when the same code is run natively, there doesn't seem to be any errors coming to the console.
Additional information

logs: 127.0.0.1-1660842111571.log
- currently, workarounds are to make sure either:
- don't delete the entities
- keep an entity with that material/mesh in the scene off camera
discord discussion: https://discord.com/channels/691052431525675048/1008708052519755916
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
A-RenderingDrawing game state to the screenDrawing game state to the screenC-BugAn unexpected or incorrect behaviorAn unexpected or incorrect behaviorO-WebSpecific to web (WASM) buildsSpecific to web (WASM) builds