Skip to content

Not receiving WindowEvent::RedrawRequested after using Window to create Surface with WGPU #3495

@daxpedda

Description

@daxpedda

Discussed in #3494

Originally posted by BernhardLThomas February 15, 2024
Hello, I've been playing around with winit and wgpu recently and I encountered an issue causing me to no longer receive WindowEvent::RedrawRequested events in the event loop.

Specifically this seems to happen as soon as I pass a reference to the Window to the Instance::create_surface method to create a surface.

I'm on MacOS with the current stable toolchain (1.76.0)

The following is a minimal example which causes the issue:

fn main() {
    let event_loop = winit::event_loop::EventLoop::new().unwrap();
    let window = winit::window::Window::new(&event_loop).unwrap();

    let instance = wgpu::Instance::new(wgpu::InstanceDescriptor {
        ..Default::default()
    });
    // this line causes the issue
    let surface = instance.create_surface(window).unwrap();

    event_loop.run(|event, elwt| match event {
        winit::event::Event::WindowEvent { window_id, event } => match event {
            winit::event::WindowEvent::CloseRequested => elwt.exit(),
            winit::event::WindowEvent::Resized(size) => {
                println!("resize: {:?}", size);
            }
            winit::event::WindowEvent::RedrawRequested => {
                println!("redraw_requested");
            }
            _ => (),
        },
        _ => (),
    });
}

Originally posted by BernhardLThomas February 15, 2024
I should clarify, manually calling Window::request_redraw will still result in a WindowEvent::RedrawRequested. What I'm not receiving is redraw requests when resizing the window or similar.

Metadata

Metadata

Assignees

No one assigned

    Labels

    B - bugDang, that shouldn't have happenedDS - appkitAffects the AppKit/macOS backend

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions