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

Timer events don't fire while menus are open #881

Open
thecodewarrior opened this issue Apr 28, 2020 · 2 comments
Open

Timer events don't fire while menus are open #881

thecodewarrior opened this issue Apr 28, 2020 · 2 comments
Labels
bug does not behave the way it is supposed to shell concerns the shell abstraction

Comments

@thecodewarrior
Copy link
Contributor

It seems that for some reason the NSTimer that backs the timer events doesn't fire while a menu is open. When the menu is closed the event fires immediately and things continue as usual.

You can see this effect by opening the timer example and clicking the application menu. The box which normally is shifted over every 10ms should freeze in place until the menu is closed. By increasing the interval (10ms -> 5000ms) and the jump distance (2px -> 20px) it's easier to see how events are delayed and fired immediately once the menu is closed.

I did some digging and the handle_timer function in window.rs isn't called, so the issue is happening somewhere on the NSTimer side. After some research, it seems like the menu might be somehow "hogging" whatever run loop the NSTimer is scheduled on, meaning the timer can't check whether to trigger until the menu closes and "releases" the run loop.

@luleyleo luleyleo added bug does not behave the way it is supposed to shell/mac concerns the macOS backend labels Apr 28, 2020
@xStrom xStrom changed the title Timer events don't fire while menus are open on macOS Timer events don't fire while menus are open Apr 28, 2020
@xStrom xStrom added shell concerns the shell abstraction and removed shell/mac concerns the macOS backend labels Apr 28, 2020
@xStrom
Copy link
Member

xStrom commented Apr 28, 2020

This issue also exists on Windows with the context menu. The timer event gets dropped completely when the context menu is open. In addition, when there are multiple windows with timers and I open the context menu, then the whole app crashes due to double mutable borrow.

For the multi-window and context menu testing I modified the multiwin example by adding the following into the Glow widget's event method:

let interval = std::time::Duration::from_millis(1000);
match event {
    Event::WindowConnected => {
        ctx.request_timer(interval);
    }
    Event::Timer(_) => {
        ctx.request_timer(interval);
        println!("Timer fired!");
    }
    _ => (),
}

@xStrom
Copy link
Member

xStrom commented Apr 28, 2020

I confirmed the app menu bug on macOS. The context menu also causes the same issue on macOS, i.e. the timers get delayed. When multiple windows are open then opening the context menu delays the timers on all of them. There's no crash on macOS though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug does not behave the way it is supposed to shell concerns the shell abstraction
Projects
None yet
Development

No branches or pull requests

3 participants