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

Calling unconfigure_swapchain and destroy_surface together causes the window to stop responding and crash #3242

Open
Dooskington opened this issue May 2, 2020 · 0 comments

Comments

@Dooskington
Copy link
Contributor

  • GFX version: 0.5.0, with dx12 backend version 0.5.0
  • OS: Windows 10
  • GPU: Nvidia Quadro M1200

Here is the cleanup code I am using, for context. The unconfigure_swapchain line towards the end causes the crash. I can have either the destroy_surface, or the unconfigure, but not both.

impl Drop for Renderer {
    fn drop(&mut self) {
        let device = self.device.borrow();
        unsafe {
            device.destroy_render_pass(self.render_pass.take().unwrap());

            device.destroy_buffer(self.uniform_buffer.take().unwrap());
            device.free_memory(self.uniform_buffer_memory.take().unwrap());

            for semaphore in self.frame_semaphores.take().unwrap() {
                device.destroy_semaphore(semaphore);
            }

            for fence in self.frame_fences.take().unwrap() {
                device.destroy_fence(fence);
            }

            // The following line crashes:
            self.surface.as_mut().unwrap().unconfigure_swapchain(&device);
            self.instance.destroy_surface(self.surface.take().unwrap());

            device.wait_idle().unwrap();
            for mut command_pool in self.command_pools.take().unwrap() {
                command_pool.reset(true);
                device.destroy_command_pool(command_pool);
            }
        }
    }
}

There's no HRESULT or panic message to share, the window just stops responding, then when I close it, the terminal logs error code 255.

bors bot added a commit to gfx-rs/wgpu that referenced this issue May 4, 2020
637: Wait for idle before destroying swapchains r=kvark a=kvark

Follow up to #636 
I was trying to address the D3D12 error in gfx-rs/gfx#3242
The debug messages complain about a resource being used by the queue while it's being destroyed. I thought forcing a wait there would help, but it does not. I think it's still a good change to land though.

In the meantime, I wonder if it considers the swapchain to be used because it's currently presented. Could be something else I'm missing here.

Co-authored-by: Dzmitry Malyshau <dmalyshau@mozilla.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants