macos-app-nap 0.0.1

Control App Nap on macOS systems
Documentation
  • Coverage
  • 0%
    0 out of 2 items documented0 out of 1 items with examples
  • Size
  • Source code size: 6.88 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 523.16 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 12s Average build duration of successful builds.
  • all releases: 12s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • x3ro/macos-app-nap
    8 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • x3ro

Preventing macOS AppNap

On macOS, AppNap is a mechanism of reducing the energy consumption of apps by suspending them if the user is not interacting with an app.

As a concrete example, when running the druid timer example with some debug output added around the timer event, you'll notice that the output slows down significantly after about a minute if the application windows is in the background an completely invisible / covered by other windows.

To prevent this, e.g. if you're doing processing in the background and are relying on the timer, you can use this crate. Currently it only supports disabling App Nap entirely for the applications. More granular control is likely possible and desirable, and may be added in the future (pull requests welcome!).

Usage

Fairly simple at the moment:

fn main() {
    macos_app_nap::prevent();
}

Potential improvements

  • The C helper could be replaced by using/adapting the audio_thread_priority crate, which appears to be doing something very similar.

License

MIT. See LICENSE.md for details.