rust-windowing / rust-windowing/winit

WaitCancelled on macOS without other events

Open
#1,985 5 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

C - needs investigation DS - appkit DS - x11 S - platform parity
Dominant language
Rust
Stars
6.2k
Forks
1.3k
Avg merge
2d 19h
Merged PRs (30d)
9

Description

I was playing with nannou today and I noticed that their LoopMode::Wait is not working on macOS. This is intended to prevent rerenders unless an input or window event is received. It achieves this by using winit's ControlFlow::Wait under the hood. This works fine on Windows, but on macOS, the wait is interrupted (at 60fps), even though there are (as far as I can tell) no events requiring that the wait be interrupted.

I ran winit/examples/window.rs on my Macbook Pro and saw many instances of the following event sequence:

...
NewEvents(WaitCancelled { start: Instant { t: 1014694701148459 }, requested_resume: None })
MainEventsCleared
RedrawRequested(WindowId(Id(140590972026416)))
RedrawEventsCleared
NewEvents(WaitCancelled { start: Instant { t: 1014694701163499 }, requested_resume: None })
MainEventsCleared
RedrawRequested(WindowId(Id(140590972026416)))
RedrawEventsCleared
...

I have a couple questions regarding this behavior:

  1. Is it expected that one would receive NewEvents when there don't seem to be any such events?
  2. Does the winit API guarantee that your wait won't be interrupted if there are no new events?

If the answer to (2) is "no", it seems like the nannou LoopMode::Wait implementation will need to change, regardless of whether this is unexpected / buggy behavior.

Related issue in nannou: https://github.com/nannou-org/nannou/issues/781

Thanks! Let me know if I can help with anything.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Run winit/examples/window.rs on macOS and inspect the reported NewEvents(WaitCancelled) sequence around MainEventsCleared and RedrawRequested. Compare the observed behavior with ControlFlow::Wait and the related nannou issue; document whether the interruption is expected and whether the API guarantees an uninterrupted wait.

Written by the indexing model from the issue text.

Assessment

Tech stack
macos, rust
Domain
desktop, operating-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.