I'm updating iced_baseview to the new baseview version, and I'm running into a weird issue. (Sorry, I probably should have worked on this sooner before the new baseview version was released.)
The render_wgpu example works just fine, and the egui wgpu renderer accepted the new PlatformHandle in my egui_baseview crate. But for some reason, Iced doesn't like the PlatformHandle I give it. It panics with the error:
thread '<unnamed>' (42147) panicked at /home/billydm/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/wgpu-27.0.1/src/backend/wgpu_core.rs:3793:18:
wgpu error: Validation Error
Caused by:
In Surface::configure
Invalid surface
(Tested on Linux, I haven't tested this on MacOS or Windows.)
I checked the backtrace, and it is panicking in compositor.configure_surface() here (which is called from compositor.create_surface()): https://github.com/iced-rs/iced/blob/595af03a9f1806f1052685081e50909d596dcdc8/wgpu/src/window/compositor.rs#L320
Strangely I am able to get it to work by giving Iced this small wrapper instead:
#[derive(Clone)]
struct WindowWrapper {
window: raw_window_handle::RawWindowHandle,
display: raw_window_handle::RawDisplayHandle,
}
impl WindowWrapper {
fn new(window: &baseview::WindowContext) -> Self {
Self {
window: window.window_handle().unwrap().as_raw(),
display: window.display_handle().unwrap().as_raw(),
}
}
}
impl raw_window_handle::HasWindowHandle for WindowWrapper {
fn window_handle(
&self,
) -> Result<raw_window_handle::WindowHandle<'_>, raw_window_handle::HandleError> {
Ok(unsafe { raw_window_handle::WindowHandle::borrow_raw(self.window) })
}
}
impl raw_window_handle::HasDisplayHandle for WindowWrapper {
fn display_handle(
&self,
) -> Result<raw_window_handle::DisplayHandle<'_>, raw_window_handle::HandleError> {
Ok(unsafe { raw_window_handle::DisplayHandle::borrow_raw(self.display) })
}
}
unsafe impl Send for WindowWrapper {}
unsafe impl Sync for WindowWrapper {}
Also this wrapper does NOT work if I instead pass it the PlatformHandle:
impl WindowWrapper {
fn new(window: &baseview::PlatformHandle) -> Self {
Self {
window: window.window_handle().unwrap().as_raw(),
display: window.display_handle().unwrap().as_raw(),
}
}
}
Here is the full implementation: https://codeberg.org/RustAudio/iced_baseview/src/commit/949cee921b72271b8824fc265d95dc6cc875a939/src/shell/mod.rs#L225
I'm updating
iced_baseviewto the new baseview version, and I'm running into a weird issue. (Sorry, I probably should have worked on this sooner before the new baseview version was released.)The
render_wgpuexample works just fine, and the egui wgpu renderer accepted the newPlatformHandlein myegui_baseviewcrate. But for some reason, Iced doesn't like thePlatformHandleI give it. It panics with the error:(Tested on Linux, I haven't tested this on MacOS or Windows.)
I checked the backtrace, and it is panicking in
compositor.configure_surface()here (which is called fromcompositor.create_surface()): https://github.com/iced-rs/iced/blob/595af03a9f1806f1052685081e50909d596dcdc8/wgpu/src/window/compositor.rs#L320Strangely I am able to get it to work by giving Iced this small wrapper instead:
Also this wrapper does NOT work if I instead pass it the
PlatformHandle:Here is the full implementation: https://codeberg.org/RustAudio/iced_baseview/src/commit/949cee921b72271b8824fc265d95dc6cc875a939/src/shell/mod.rs#L225