Skip to content

Use ProcessInfo.beginActivity instead of IOPMAssertion#130

Open
edde746 wants to merge 1 commit intofluttercommunity:mainfrom
edde746:fix/macos-processinfo-activity
Open

Use ProcessInfo.beginActivity instead of IOPMAssertion#130
edde746 wants to merge 1 commit intofluttercommunity:mainfrom
edde746:fix/macos-processinfo-activity

Conversation

@edde746
Copy link
Copy Markdown

@edde746 edde746 commented May 4, 2026

Summary

Replace the macOS wakelock implementation’s deprecated kIOPMAssertionTypeNoDisplaySleep IOKit assertion with ProcessInfo.beginActivity.

Justification

The current implementation uses kIOPMAssertionTypeNoDisplaySleep, which Apple’s SDK headers mark as deprecated since macOS 10.7 in favor of kIOPMAssertPreventUserIdleDisplaySleep.

ProcessInfo.beginActivity expresses the plugin’s intent more directly: while wakelock is enabled, request both .idleDisplaySleepDisabled and .idleSystemSleepDisabled; when disabled, end the activity.

This avoids deprecated assertion types and simplifies state tracking by storing the returned activity token instead of managing an IOPMAssertionID plus a separate boolean.

Sources

Replace the deprecated IOPMAssertionCreateWithName API with the modern
ProcessInfo.processInfo.beginActivity() API for preventing display and
system idle sleep on macOS. This is the Apple-recommended approach and
works reliably on recent macOS versions.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant