display(visionOS): disable background auto-suspend on visionOS

The auto-suspend can trigger any time user does not focus on view.
This commit is contained in:
osy 2024-02-21 10:57:28 -08:00
parent 689367a9c3
commit 9a871c0c7d
2 changed files with 8 additions and 0 deletions

View File

@ -25,6 +25,8 @@
<array>
<string>iOS-Remote</string>
</array>
<key>Platform</key>
<string>iOS</string>
</dict>
<dict>
<key>Type</key>
@ -35,6 +37,8 @@
<string>AutosaveBackground</string>
<key>DefaultValue</key>
<true/>
<key>Platform</key>
<string>iOS</string>
</dict>
<dict>
<key>Type</key>

View File

@ -499,6 +499,7 @@ extension VMSessionState {
}
func didEnterBackground() {
#if !os(visionOS)
logger.info("Entering background")
let shouldAutosaveBackground = UserDefaults.standard.bool(forKey: "AutosaveBackground")
if shouldAutosaveBackground && vmState == .started {
@ -521,14 +522,17 @@ extension VMSessionState {
task = .invalid
}
}
#endif
}
func didEnterForeground() {
#if !os(visionOS)
logger.info("Entering foreground!")
if (hasAutosave && vmState == .started) {
logger.info("Deleting snapshot")
vm.requestVmDeleteState()
}
#endif
}
}