NSApp nextEventMatchingMask Is Taking Long

I’m currently running into issues where nextEventMatchingMask is taking at least 0,02 seconds and even in some cases 0,07 seconds just to return a nil event. This is causing me to not be able to hit my target frame rate of 60fps. Is this expected behaviour? It happens but with distantPast and nil untilDates.
I've figured out that a call to

Code Block
[[window contentView] setNeedsDisplay:YES];


makes the following call to nextEventMatchingMask take a long time. What's the recommended way to get around this while still updating the view?

It happened for me too on MacMini M4 Pro, without setNeedsDisplay after updating to MacOS 26 and it remains in MacOS 27. The larger the window is, the longer it delays, so 5 ms for 1080p and 0.3 ms for a small window.