Skip to content

#5856 An option to prevent hibernation#5879

Draft
akleshchev wants to merge 2 commits into
developfrom
andreyk/viewer_5856
Draft

#5856 An option to prevent hibernation#5879
akleshchev wants to merge 2 commits into
developfrom
andreyk/viewer_5856

Conversation

@akleshchev
Copy link
Copy Markdown
Contributor

@akleshchev akleshchev commented May 29, 2026

  • Exposed OS specific files in IDE (without compiling)
  • OS hibernation mode UI
  • OS hibernation implementation for mac, windows and linux

Draft as it needs a bit more work and testing, for now only built it on windows.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread indra/newview/app_settings/settings.xml Outdated
Comment thread indra/newview/llappviewermacosx-objc.h Outdated
Comment thread indra/newview/llappviewerlinux.h
Comment thread indra/newview/llappviewer.cpp
Comment thread indra/newview/llappviewermacosx-objc.mm
Comment on lines +109 to +120
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
);
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Comment thread indra/newview/CMakeLists.txt Outdated
Comment thread indra/llwindow/CMakeLists.txt
Comment on lines +259 to +263
width="300">
Prevent OS from hibernating if not Away:
</text>
<combo_box
control_name="OSHibernationMode"
@akleshchev akleshchev force-pushed the andreyk/viewer_5856 branch from 75d7005 to 87d650a Compare May 29, 2026 23:00
@akleshchev akleshchev force-pushed the andreyk/viewer_5856 branch from 87d650a to 6f5c1c0 Compare May 29, 2026 23:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants