From e04eb840909ae4dbe59c1fa50305de8c6a9fc785 Mon Sep 17 00:00:00 2001 From: Ahmad Sayed Alsayed Ebrahim Date: Thu, 15 Oct 2026 05:09:39 +0300 Subject: [PATCH] Mali bridge: keep the server's cache directory in the app's files, not its cache Android empties an app's cacheDir when storage runs low; it took the bridge's pipeline caches, the probe profile, stuck-pipelines and the env file from under a running server. The directory is now files/vkbridge-pipelines (--cache-dir and the in-app start alike), and an existing cache/vkbridge-pipelines is moved there once. Nothing trims filesDir, so the server's own limits bound it (64 MB per pipeline cache file, a total limit in newer servers). --- .../launcher/gpu/VkBridgeComponent.kt | 27 ++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/droiddeck/launcher/gpu/VkBridgeComponent.kt b/app/src/main/java/com/droiddeck/launcher/gpu/VkBridgeComponent.kt index 599e5e5d8b..8033d8effe 100644 --- a/app/src/main/java/com/droiddeck/launcher/gpu/VkBridgeComponent.kt +++ b/app/src/main/java/com/droiddeck/launcher/gpu/VkBridgeComponent.kt @@ -1,5 +1,6 @@ package com.droiddeck.launcher.gpu +import android.content.Context import android.os.Process import android.util.Log import com.droiddeck.launcher.core.HostProcess @@ -18,7 +19,7 @@ class VkBridgeComponent(private val socket: File, private val logFile: File) : S return } socket.parentFile?.mkdirs() - val cacheDir = File(app().cacheDir, "vkbridge-pipelines").apply { mkdirs() } + val cacheDir = cacheDir(app()) if (VkBridgeNative.start(app(), socket, logFile, cacheDir)) { Log.i(TAG, "server ready in the app's process at $socket") return @@ -54,6 +55,30 @@ class VkBridgeComponent(private val socket: File, private val logFile: File) : S companion object { private const val TAG = "VkBridge" + private const val CACHE_DIR = "vkbridge-pipelines" + + fun cacheDir(context: Context): File { + val dir = File(context.filesDir, CACHE_DIR) + val old = File(context.cacheDir, CACHE_DIR) + if (old.isDirectory) migrate(old, dir) + dir.mkdirs() + return dir + } + + private fun migrate(old: File, dir: File) { + val moved = if (!dir.exists()) old.renameTo(dir) else false + if (!moved) { + dir.mkdirs() + old.listFiles()?.forEach { f -> + val to = File(dir, f.name) + if (to.exists()) return@forEach + if (!f.renameTo(to)) runCatching { f.copyRecursively(to, overwrite = false) } + } + old.deleteRecursively() + } + Log.i(TAG, "bridge cache moved from $old to $dir") + } + const val BINARY = "libvkbridge_server.so" const val GUEST_ICD = "/usr/local/share/vkbridge/droidbridge_icd.json" const val GUEST_LIB = "/usr/local/lib/vkbridge/libvulkan_droidbridge.so"