-
Notifications
You must be signed in to change notification settings - Fork 253
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
Crashes with throttling render assets #310
Comments
Hi! Are you sure this is an issue with |
This doesn't actually cause a crash but it causes the window to not render. use bevy::prelude::*;
use bevy_egui::{EguiContexts, EguiPlugin};
fn main() {
App::new()
.add_plugins(DefaultPlugins)
.add_plugins(EguiPlugin)
// Systems that create Egui widgets should be run during the `CoreSet::Update` set,
// or after the `EguiSet::BeginPass` system (which belongs to the `CoreSet::PreUpdate` set).
.add_systems(Update, ui_example_system)
.run();
}
fn ui_example_system(mut contexts: EguiContexts, mut commands: Commands) {
commands.insert_resource( bevy::render::render_asset::RenderAssetBytesPerFrame::new(4096));
egui::Window::new("Hello").show(contexts.ctx_mut(), |ui| {
ui.label("world");
});
} This one causes it to crash use bevy::prelude::*;
use bevy_egui::{EguiContexts, EguiPlugin, EguiRenderToTextureHandle};
use wgpu_types::{Extent3d, TextureUsages};
fn main() {
let mut app = App::new();
app.add_plugins(DefaultPlugins);
app.add_plugins(EguiPlugin);
app.add_systems(Startup, setup_worldspace);
app.add_systems(Update, (update_screenspace, update_worldspace));
app.run();
}
fn update_screenspace(mut contexts: EguiContexts, mut commands: Commands) {
commands.insert_resource( bevy::render::render_asset::RenderAssetBytesPerFrame::new(4096));
egui::Window::new("Screenspace UI").show(contexts.ctx_mut(), |ui| {
ui.label("I'm rendering to screenspace!");
});
}
fn update_worldspace(
mut contexts: Query<&mut bevy_egui::EguiContext, With<EguiRenderToTextureHandle>>,
) {
for mut ctx in contexts.iter_mut() {
egui::Window::new("Worldspace UI").show(ctx.get_mut(), |ui| {
ui.label("I'm rendering to a texture in worldspace!");
});
}
}
fn setup_worldspace(
mut images: ResMut<Assets<Image>>,
mut meshes: ResMut<Assets<Mesh>>,
mut materials: ResMut<Assets<StandardMaterial>>,
mut commands: Commands,
) {
let output_texture = images.add({
let size = Extent3d {
width: 256,
height: 256,
depth_or_array_layers: 1,
};
let mut output_texture = Image {
// You should use `0` so that the pixels are transparent.
data: vec![0; (size.width * size.height * 4) as usize],
..default()
};
output_texture.texture_descriptor.usage |= TextureUsages::RENDER_ATTACHMENT;
output_texture.texture_descriptor.size = size;
output_texture
});
commands.spawn(PbrBundle {
mesh: meshes.add(Cuboid::new(1.0, 1.0, 1.0).mesh()),
material: materials.add(StandardMaterial {
base_color: Color::WHITE,
base_color_texture: Some(Handle::clone(&output_texture)),
alpha_mode: AlphaMode::Blend,
// Remove this if you want it to use the world's lighting.
unlit: true,
..default()
}),
..default()
});
commands.spawn(EguiRenderToTextureHandle(output_texture));
commands.spawn(Camera3dBundle {
transform: Transform::from_xyz(1.5, 1.5, 1.5).looking_at(Vec3::new(0., 0., 0.), Vec3::Y),
..default()
});
} ( these are taken from your examples and just inserted the command ) |
Thank you for the example! I was able to reproduce the issue.
|
This will be fixed by #325 . |
try
commands.insert_resource( bevy::render::render_asset::RenderAssetBytesPerFrame::new(4096), );
Result: crash
The text was updated successfully, but these errors were encountered: