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

[Windows] Opening the window system menu or right clicking the title bar freezes the event loop #1484

Open
filnet opened this issue Feb 27, 2020 · 10 comments
Labels
B - bug Dang, that shouldn't have happened DS - windows

Comments

@filnet
Copy link
Contributor

filnet commented Feb 27, 2020

No description provided.

filnet pushed a commit to filnet/winit that referenced this issue Feb 27, 2020
This fixes a panic.
Note that the WM_PAINT event is now sent to the modal_redraw_method
which is more correct and avoids an unecessary redraw of the window.

Relates to but does does not fix rust-windowing#1484
filnet added a commit to filnet/winit that referenced this issue Feb 28, 2020
This fixes a panic.
Note that the WM_PAINT event is now sent to the modal_redraw_method
which is more correct and avoids an unecessary redraw of the window.

Relates to but does does not fix rust-windowing#1484
@aloucks
Copy link
Contributor

aloucks commented Mar 1, 2020

Related: #894

@filnet
Copy link
Contributor Author

filnet commented Mar 1, 2020

@aloucks Yep.

In this PR the event loop will freeze:

  • when pressing the left mouse button on any title bar button (window icon, minimize, maximize, close)
  • when pressing the right mouse button anywhere on the title bar
  • while the window menu is open (either by left clicking the window icon or right clicking anywhere in the title bar).

@ryanisaacg ryanisaacg added DS - windows B - bug Dang, that shouldn't have happened labels Mar 3, 2020
filnet added a commit to filnet/winit that referenced this issue Mar 6, 2020
This fixes a panic.
Note that the WM_PAINT event is now sent to the modal_redraw_method
which is more correct and avoids an unecessary redraw of the window.

Relates to but does does not fix rust-windowing#1484
@Osspial Osspial closed this as completed in 2f27f64 Mar 7, 2020
@aloucks
Copy link
Contributor

aloucks commented Mar 7, 2020

I think this was closed by accident:

Relates to but does does not fix #1484

@filnet
Copy link
Contributor Author

filnet commented Mar 8, 2020

Issue is still there. Please reopen this issue.

@filnet
Copy link
Contributor Author

filnet commented Mar 10, 2020

Ping

@Osspial Osspial reopened this Mar 11, 2020
@Osspial
Copy link
Contributor

Osspial commented Mar 11, 2020

I was hoping that #1496 would fix this, but it actually seems to make it worse - with that, the event loop doesn't resume until the window gets resized. I'll take a look at figuring out why that happens.

@Osspial
Copy link
Contributor

Osspial commented Mar 11, 2020

I'm pretty sure this is related to #894.

@mooman219
Copy link

mooman219 commented Dec 18, 2021

We can detect when we enter this frozen state via WM_ENTERMENULOOP, WM_EXITMENULOOP, and WM_ENTERIDLE . Can't we just kick ourselves and fire events in this state?

This works for example while retaining a working context menu:

winuser::WM_ENTERIDLE => {
    let mut message: MSG = zeroed();
    while PeekMessageW(
            &mut message as *mut MSG,
            window_handle,
            0,
            0,
            PM_NOREMOVE,
        ) == 0
    {
        fire_event(MainEventsCleared);
    }
    SUCCESS
}

This doesn't cover the other cases where freezes happen, but this is definitely one of them.

@madsmtm
Copy link
Member

madsmtm commented Feb 28, 2025

From the Bevy discord:

when you you right click the title bar to get the menu (or pressing and holding the min/max buttons), you enter the modal loop where your application is completely frozen. This isn't a winit bug per-se, but an architecture design challenge. There is no way to resolve this without running code in a different thread (other than trying something exotic with the Windows Fibers API). I mention the Fibers API because there's an open PR in GLFW attempting to solve the same problem with Fibers. The PR is quite old at this point and was not merged. The general consensus that I've seen is to always run the simulation/render logic in a separate thread from the event loop. Elmindreda (the GLFW maintainer) has given that feedback in the past. Attempting to resolve the issue with Fibers would definitely be in Winit though, not in Bevy. I don't know if Fibers would even fully solve the problem since it was never merged. GLFW/Fibers PR: glfw/glfw#1426

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
B - bug Dang, that shouldn't have happened DS - windows
Development

No branches or pull requests

6 participants