Skip to content

Windows not sending WindowEvent::RedrawRequested when request_redraw is called #4656

Description

@Klemen2

Description

This is most likely related to #3648
As far as I can tell RedrawRequest is only sent here

WM_PAINT => {
userdata.window_state_lock().redraw_requested =
userdata.event_loop_runner.should_buffer();
// We'll buffer only in response to `UpdateWindow`, if win32 decides to redraw the
// window outside the normal flow of the event loop. This way mark event as handled
// and request a normal redraw with `RedrawWindow`.
if !userdata.event_loop_runner.should_buffer() {
userdata.send_window_event(window, WindowEvent::RedrawRequested);
}

Digging into windows documentation WM_PAINT is only sent by the system or when another application makes a request to paint a portion of an application's window (https://learn.microsoft.com/en-us/windows/win32/gdi/wm-paint) and that it will only be sent when there are no messages in the application's message queue.

So when you are for example actively moving the mouse in the window and you are requesting a redraw after each event and this redraw is not quick enough, RedrawRequest will not be sent as next event like on other platforms and will wait until you either slow down or stop as the message queue fills up in between. This could be seen in: DioxusLabs/blitz#595 where redrawing at 300+ fps isn't fast enough for the message queue to stay empty for WM_PAINT to happen.

#4653 that apparently fixes #3648 does not fix this issue

Windows version

Microsoft Windows [Version 10.0.26200.8875]

Winit version

0.31.0-beta.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    B - bugDang, that shouldn't have happenedDS - win32Affects the Win32/Windows backend

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions