Skip to content
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

"parent device is lost" panic when maximizing & sometimes launching #3043

Open
squeezebunny opened this issue Sep 21, 2022 · 2 comments
Open
Labels
api: vulkan Issues with Vulkan area: wsi Issues with swapchain management or windowing type: bug Something isn't working

Comments

@squeezebunny
Copy link

thread 'main' panicked at 'Error in Queue::submit: parent device is lost', C:\...\github.com-1ecc6299db9ec823\wgpu-0.13.1\src\backend\direct.rs:281:9

When dragging the window, it does have a brief stutter. When I maximize during the stutter, the program locks up for a few seconds before crashing with that error. It is easier to do than you would think; it crashes if the stutter happens during the maximize animation.

It also occurs occasionally when launching. Less so with the single buffer write in the example below, but much more common with the writes in my larger project.

If this is not a bug, I am wondering if there is some way to handle this error without causing the parent device panic, because it is not clear.

It is on a very simple wgpu setup and I'm just writing to a small buffer. If I remove the buffer write, the stutter does not happen. I'll paste any code I believe is relevant below.

It happens on the Vulkan backend, but not DX12.

wgpu 0.13.1
Windows 11 running on a Surface Laptop 2

#[repr(C)]
#[derive(Copy, Clone, Debug, Pod, Zeroable)]
struct Global {
    mvp: [[f32; 4]; 4],
}

fn set_view_projection(buffer: &Buffer, queue: &Queue, mvp: Mat4) {
    queue.write_buffer(
        buffer,
        0,
        bytemuck::cast_slice(&[Global {
            mvp: mvp.to_cols_array_2d(),
        }]),
    );
}

...
Event::RedrawRequested(_) => {
    let size = window.inner_size();

    set_view_projection(
        &matrix_buf,
        &queue,
        Mat4::orthographic_lh(0.0, size.width as f32, size.height as f32, 0.0, -1.0, 500.0),
    );

    let frame = match surface.get_current_texture() {
        Ok(f) => f,
        Err(_) => return, // stop the draw if no texture found
    };

    let view = frame.texture.create_view(&TextureViewDescriptor::default());

    let mut encoder =
        device.create_command_encoder(&CommandEncoderDescriptor { label: None });

    {
        let mut rpass = encoder.begin_render_pass(&RenderPassDescriptor {
            label: None,
            color_attachments: &[Some(RenderPassColorAttachment {
                view: &view,
                resolve_target: None,
                ops: Operations {
                    load: LoadOp::Load,
                    store: true,
                },
            })],
            depth_stencil_attachment: None,
        });
        rpass.set_pipeline(&render_pipeline);
        rpass.set_vertex_buffer(0, vertex_buffer.slice(..));
        rpass.set_index_buffer(index_buffer.slice(..), IndexFormat::Uint32);
        rpass.set_bind_group(0, &group, &[]);
        rpass.draw_indexed(0..3 as u32, 0, 0..1);
    }

    queue.submit(Some(encoder.finish()));
    frame.present();
}
@gents83
Copy link
Contributor

gents83 commented Oct 6, 2022

Did you tried to re-configure the surface on size change?

@squeezebunny
Copy link
Author

Yes, I was reconfiguring the surface on size change. But I was also having very strange performance issues with wgpu on integrated graphics with the few machines I tried so I've since changed libraries, much to my dismay. 😣

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: vulkan Issues with Vulkan area: wsi Issues with swapchain management or windowing type: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants