#5856 An option to prevent hibernation#5879
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds a user-facing preference to control whether the viewer should prevent the host OS from sleeping/hibernating when the user is not Away, and wires that setting through to per-platform implementations (Windows/macOS/Linux). It also adjusts build configuration to surface platform-specific sources in IDEs.
Changes:
- Added a new Preferences UI combo box backed by a new saved setting (
OSHibernationMode). - Implemented OS sleep/hibernation prevention hooks on Windows/macOS/Linux and toggled behavior based on Away state.
- Updated CMake targets to include platform-specific files for IDE visibility.
Reviewed changes
Copilot reviewed 16 out of 16 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
| indra/newview/skins/default/xui/en/panel_preferences_setup.xml | Adds UI for selecting OS hibernation prevention mode. |
| indra/newview/llviewerwindow.cpp | Changes suspend handling to send stats and optionally disconnect depending on mode. |
| indra/newview/llappviewerwin32.h | Declares Windows override hook for OS hibernation mode. |
| indra/newview/llappviewerwin32.cpp | Implements Windows sleep/hibernate inhibition via SetThreadExecutionState. |
| indra/newview/llappviewermacosx.h | Declares macOS hook for OS hibernation mode. |
| indra/newview/llappviewermacosx.cpp | Calls into Objective-C++ implementation to apply the mode; restores behavior on cleanup. |
| indra/newview/llappviewermacosx-objc.mm | Implements macOS power assertions for inhibiting sleep/display sleep. |
| indra/newview/llappviewermacosx-objc.h | Declares the Objective-C++ bridge function for hibernation mode changes. |
| indra/newview/llappviewerlinux.h | Declares Linux hook and helper state for power inhibition. |
| indra/newview/llappviewerlinux.cpp | Implements Linux D-Bus-based inhibition/uninhibition logic and lifecycle cleanup. |
| indra/newview/llappviewer.h | Adds eHibernationMode, platform hook, and a connection member for settings change tracking. |
| indra/newview/llappviewer.cpp | Applies mode on login/disconnect/Away transitions; updates stats sending signature. |
| indra/newview/llagent.cpp | Toggles permit/deny behavior when entering/leaving Away. |
| indra/newview/CMakeLists.txt | Adds platform source lists for IDE visibility and exclusion from other platforms. |
| indra/newview/app_settings/settings.xml | Adds the persisted OSHibernationMode saved setting. |
| indra/llwindow/CMakeLists.txt | Adds platform file lists for IDE visibility and exclusion from other platforms. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| else if (mode == 2) | ||
| { | ||
| // Prevent OS from sleeping/hibernating, prevent screen from going off | ||
| CFStringRef assertionName = CFSTR("Second Life Viewer"); | ||
| // kIOPMAssertionTypeNoIdleSleep prevents idle sleep | ||
| // kIOPMAssertionTypeNoDisplaySleep prevents display sleep | ||
| IOReturn result = IOPMAssertionCreateWithName( | ||
| kIOPMAssertionTypeNoDisplaySleep, | ||
| kIOPMAssertionLevelOn, | ||
| assertionName, | ||
| &gPowerAssertionID | ||
| ); |
There was a problem hiding this comment.
according to macos's documentation: the idle display will not sleep when enabled, and consequently the system will not idle sleep.
https://developer.apple.com/documentation/iokit/kiopmassertiontypenodisplaysleep
| width="300"> | ||
| Prevent OS from hibernating if not Away: | ||
| </text> | ||
| <combo_box | ||
| control_name="OSHibernationMode" |
75d7005 to
87d650a
Compare
87d650a to
6f5c1c0
Compare
Draft as it needs a bit more work and testing, for now only built it on windows.