Open aircloud opened 4 years ago
A bit of a necropost, but you can use the objc2-foundation v0.2.2
crate and the activity API:
use objc2_foundation::{NSProcessInfo, NSActivityOptions, NSString};
// Disable app-nap
let activity = NSProcessInfo::processInfo().beginActivityWithOptions_reason(
NSActivityOptions::NSActivityUserInitiatedAllowingIdleSystemSleep,
&NSString::from_str("No napping on the job!"),
);
// Keep the `activity` around while having app-nap disabled
// Re-enable app-nap
NSProcessInfo::processInfo().endActivity(&activity);
None of this is specific to Winit.
Web has implemented a few ways to manage throttling. I also plan to expose a way to prevent screen dimming or system sleep (see #3351).
I think that this area, after all these are a lot of different things, is in scope for Winit, considering that it is related to managing the event loop.
I don't know about other backends, but Web has something similar to app nap: most browsers start freezing apps when not focused or not in use, so I will be adding an API that prevents that. Maybe this could be a cross-platform API?
WDYT?
Hmm, yeah, I can see the similarity, I'm not opposed to making some of this a more general (instead of a platform-specific) API.
Currently I have a problem about the process not executed for serval seconds in 'app nap' mode,
more information about 'app nap' is there
and there is the problem: https://stackoverflow.com/questions/61810703/a-very-strange-problem-that-winit-block-the-output-from-other-threads
Is there currently a way to abandon the app nap mode?