mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-18 20:36:04 +00:00
fix(session): preserve guest monotonic time after long pauses (#2393)
This commit is contained in:
1 parent
cd05c96d10
commit
01bfe8519e
14 files changed
+519
-13
No files matched your search
@@ -822,6 +822,7 @@ class SessionService : Service() {
|
||||
},
|
||||
zramControl = File(filesDir, "${LinuxRuntime.DIR}/tmp/.bl-zram"),
|
||||
clockControl = File(filesDir, "${LinuxRuntime.DIR}/tmp/.bl-clock"),
|
||||
mapClockControl = { WaylandCompositor.nativeSetClockControl(it.path) },
|
||||
pagedOut = { processes, unacknowledged, residentKb, swapKb, swapBeforeKb, millis ->
|
||||
Log.i(TAG, "paged out $processes processes ($unacknowledged unacknowledged) in $millis ms: " +
|
||||
"resident ${residentKb / 1024} MB, zram ${swapBeforeKb / 1024} -> ${swapKb / 1024} MB")
|
||||
|
||||
@@ -23,6 +23,7 @@ internal class SessionSuspendController(
|
||||
private val executor: ExecutorService = Executors.newSingleThreadExecutor(),
|
||||
private val zramControl: File? = null,
|
||||
private val clockControl: File? = null,
|
||||
private val mapClockControl: (File) -> Unit = {},
|
||||
private val nowNanos: () -> Long = System::nanoTime,
|
||||
private val pagedOut: (processes: Int, unacknowledged: Int, residentKb: Long, swapKb: Long, swapBeforeKb: Long, millis: Long) -> Unit =
|
||||
{ _, _, _, _, _, _ -> },
|
||||
@@ -154,6 +155,7 @@ internal class SessionSuspendController(
|
||||
frozenSince = null
|
||||
val control = clockControl?.takeIf { it.isFile && it.length() >= Long.SIZE_BYTES } ?: return
|
||||
try {
|
||||
mapClockControl(control)
|
||||
RandomAccessFile(control, "rw").use { file ->
|
||||
val bytes = ByteArray(Long.SIZE_BYTES)
|
||||
file.readFully(bytes)
|
||||
|
||||
@@ -50,6 +50,7 @@ object CompositorHost {
|
||||
refreshHz: Float,
|
||||
fpsLimit: Int,
|
||||
): Boolean {
|
||||
WaylandCompositor.nativeSetClockControl(java.io.File(context.filesDir, "${com.droiddeck.launcher.runtime.LinuxRuntime.DIR}/tmp/.bl-clock").path)
|
||||
ownVsyncThread = SessionPrefs.vsyncThread(context)
|
||||
WaylandCompositor.nativeSetRenderOnCommit(SessionPrefs.renderOnCommit(context))
|
||||
pace(refreshHz, fpsLimit)
|
||||
@@ -135,7 +136,9 @@ object CompositorHost {
|
||||
vsyncRunning = false
|
||||
}
|
||||
|
||||
@Synchronized
|
||||
fun newSession() {
|
||||
WaylandCompositor.nativeSetClockControl(null)
|
||||
if (started) WaylandCompositor.nativeResetFirstFrame()
|
||||
}
|
||||
|
||||
|
||||
@@ -178,6 +178,8 @@ public final class WaylandCompositor {
|
||||
|
||||
public static native void nativeVsync(long frameTimeNanos);
|
||||
|
||||
public static native void nativeSetClockControl(String path);
|
||||
|
||||
public static native int nativeCompositorTid();
|
||||
|
||||
private static native String nativeCompositorFault();
|
||||
|
||||
Reference in new issue
Block a user