Skip to content

Commit

Permalink
fix(ribir): 🐛 crash when creating a zero-sized window
Browse files Browse the repository at this point in the history
  • Loading branch information
M-Adoo authored and rchangelog[bot] committed May 16, 2024
1 parent 6cc3a48 commit 47578cd
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ Please only add new entries below the [Unreleased](#unreleased---releasedate) he

- **example**: run example in web wasm (#571 @wjian23)


### Fixed

- **ribir**: fixed the crash issue when the shell window is zero-sized at startup. (#582, @M-Adoo)


### Documented

- **core**: Explained when to use `unsubscribe` with `watch!`. (#556, @M-Adoo)
Expand Down
11 changes: 7 additions & 4 deletions ribir/src/backends/wgpu_backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,17 @@ impl<'a> WinitBackend<'a> for WgpuBackend<'a> {
let surface = instance.create_surface(window).unwrap();
let wgpu = ribir_gpu::WgpuImpl::new(instance, Some(&surface)).await;
let size = window.inner_size();
surface.configure(wgpu.device(), &Self::surface_config(size.width, size.height));
let size = DeviceSize::new(size.width as i32, size.height as i32);

WgpuBackend {
size: DeviceSize::new(size.width as i32, size.height as i32),
let mut wgpu = WgpuBackend {
size: DeviceSize::zero(),
surface,
backend: ribir_gpu::GPUBackend::new(wgpu, AntiAliasing::Msaa4X),
current_texture: None,
}
};
wgpu.on_resize(size);

wgpu
}

fn on_resize(&mut self, size: DeviceSize) {
Expand Down

0 comments on commit 47578cd

Please sign in to comment.