From 678e16af4d3901f488f1133398307bf153b44b92 Mon Sep 17 00:00:00 2001 From: ASEbrahim <264076441+ASEbrahim@users.noreply.github.com> Date: Tue, 20 Oct 2026 15:23:59 +0300 Subject: [PATCH] Mali old DXVK: a failed detection keeps the last automatic choice, one Proton failing does not stop the others, the bridge file's driver_api counts unless promotion=on When nothing could be read (no apps-vulkan file and VulkanInfo failing), every automatic choice was undone: a 1.1 phone went back to a DXVK that cannot start, and the next session flipped it again. Now an automatic choice is undone only when the Vulkan is known and wants none. Each Proton's swap or undo is on its own: a failure (a missing saved copy, an I/O error) is said in the result and the remaining Protons still get theirs. When the Proton is the same but its saved copy is gone, the choice stays and is said, instead of being forgotten with DXVK 1.10.3 still installed. apps-vulkan: the version counts only with promotion=on; otherwise, and in files from servers before the field (which wrote a promoted version even where it was not trusted), driver_api does. A file whose driver_api is not the driver's own version (a driver update, a server rolled back) is left out. --- .../com/droiddeck/launcher/gpu/AppVulkan.kt | 13 ++++-- .../launcher/session/ComponentsManager.kt | 15 +++++-- .../launcher/session/BridgeDxvkTest.kt | 41 +++++++++++++++++-- 3 files changed, 58 insertions(+), 11 deletions(-) diff --git a/app/src/main/java/com/droiddeck/launcher/gpu/AppVulkan.kt b/app/src/main/java/com/droiddeck/launcher/gpu/AppVulkan.kt index 437f232f86..59818f263d 100644 --- a/app/src/main/java/com/droiddeck/launcher/gpu/AppVulkan.kt +++ b/app/src/main/java/com/droiddeck/launcher/gpu/AppVulkan.kt @@ -27,18 +27,23 @@ data class AppVulkan( if (!DeviceSupport.vkBridge(context)) return null val native = VulkanInfo.query() val file = File(VkBridgeComponent.cacheDir(context), BRIDGE_FILE) - val fromBridge = FileUtils.readString(file)?.let { fromBridgeFile(it, native["device"]) } + val fromBridge = FileUtils.readString(file)?.let { fromBridgeFile(it, native["device"], native["api"]) } val found = fromBridge ?: fromDriver(native) Log.i(TAG, found?.label ?: "unknown (driver query: ${native["error"] ?: "no api line"})") return found } - internal fun fromBridgeFile(text: String, driverDevice: String?): AppVulkan? { + internal fun fromBridgeFile(text: String, driverDevice: String?, driverApi: String? = null): AppVulkan? { val map = keyValues(text) val device = map["device"] if (device != null && driverDevice != null && device != driverDevice) return null - val (major, minor) = version(map["api"]) ?: return null - return AppVulkan(major, minor, bool(map["shader_int64"]), map["max_push_constants"]?.toIntOrNull(), "bridge") + val fileDriver = version(map["driver_api"]) + val native = version(driverApi) + if (fileDriver != null && native != null && fileDriver != native) return null + val promoted = map["promotion"]?.trim()?.lowercase() == "on" + val (major, minor) = (if (promoted) version(map["api"]) else fileDriver ?: version(map["api"])) ?: return null + return AppVulkan(major, minor, bool(map["shader_int64"]), map["max_push_constants"]?.toIntOrNull(), + if (promoted) "bridge, promoted" else "bridge") } internal fun fromDriver(map: Map): AppVulkan? { diff --git a/app/src/main/java/com/droiddeck/launcher/session/ComponentsManager.kt b/app/src/main/java/com/droiddeck/launcher/session/ComponentsManager.kt index ca5afd557c..17f3d93da2 100644 --- a/app/src/main/java/com/droiddeck/launcher/session/ComponentsManager.kt +++ b/app/src/main/java/com/droiddeck/launcher/session/ComponentsManager.kt @@ -1041,8 +1041,13 @@ object ComponentsManager { val p = proton(context, protonId) val state = loadState(context) val entry = state.sub("active").optJSONObject(p.id)?.optJSONObject(comp) - if (entry?.optString("protonVersion") == p.version && originalFile(context, p, comp).isFile) + val sameProton = entry?.optString("protonVersion") == p.version + if (sameProton && originalFile(context, p, comp).isFile) return restore(context, protonId, comp, safeName(p.version)) + if (sameProton) { + Log.w(TAG, "${p.name}: its own ${LABEL[comp]} copy is gone; keeping ${entry?.optString("label")}") + return "${LABEL[comp]}: ${p.name} keeps ${entry?.optString("label")} (its own copy is gone)" + } state.sub("active").optJSONObject(p.id)?.remove(comp) saveState(context, state) "${LABEL[comp]}: ${p.name} keeps its own copy" @@ -1064,11 +1069,13 @@ object ComponentsManager { if (rules.isEmpty() && !bridgeSession) return null val installed = protons(context) val lines = mutableListOf() - if (bridgeSession) { + fun each(p: Proton, what: () -> String): String = + runCatching(what).getOrElse { e -> Log.w(TAG, "${p.name}: ${e.message}", e); "${p.name}: ${e.message ?: e.javaClass.simpleName}" } + if (bridgeSession && vulkan != null) { val state = loadState(context) for (p in installed) { val entry = state.optJSONObject("active")?.optJSONObject(p.id)?.optJSONObject("dxvk") - if (bridgeRule == null && autoChoiceStale(entry, null)) lines.add(undoAuto(p.id, "dxvk")) + if (bridgeRule == null && autoChoiceStale(entry, null)) lines.add(each(p) { undoAuto(p.id, "dxvk") }) } } for ((rule, auto) in rules) { @@ -1085,7 +1092,7 @@ object ComponentsManager { continue } if (auto) lines.add("${vulkan?.label}: DXVK ${rule.file}") - lines.add(targets.joinToString("; ") { if (auto) applyAuto(it.id, rule.file) else apply(it.id, rule.file) }) + lines.add(targets.joinToString("; ") { p -> if (auto) each(p) { applyAuto(p.id, rule.file) } else apply(p.id, rule.file) }) } return lines.filter { it.isNotEmpty() }.joinToString("; ").ifEmpty { null } } diff --git a/app/src/test/java/com/droiddeck/launcher/session/BridgeDxvkTest.kt b/app/src/test/java/com/droiddeck/launcher/session/BridgeDxvkTest.kt index 9bcc7b6829..5f621a23a4 100644 --- a/app/src/test/java/com/droiddeck/launcher/session/BridgeDxvkTest.kt +++ b/app/src/test/java/com/droiddeck/launcher/session/BridgeDxvkTest.kt @@ -59,13 +59,24 @@ class BridgeDxvkTest { } @Test fun theBridgesFileWinsForItsOwnGpuOnly() { - val text = "device=Mali-G710 MC10\napi=1.2.177\ndriver_api=1.1.177\nshader_int64=0\nmax_push_constants=128\n" - assertEquals(promoted, AppVulkan.fromBridgeFile(text, "Mali-G710 MC10")) - assertEquals(promoted, AppVulkan.fromBridgeFile(text, null)) + val text = "device=Mali-G710 MC10\napi=1.2.177\ndriver_api=1.1.177\npromotion=on\nshader_int64=0\nmax_push_constants=128\n" + val on = promoted.copy(source = "bridge, promoted") + assertEquals(on, AppVulkan.fromBridgeFile(text, "Mali-G710 MC10")) + assertEquals(on, AppVulkan.fromBridgeFile(text, null)) + assertEquals(on, AppVulkan.fromBridgeFile(text, "Mali-G710 MC10", "1.1.177")) assertNull(AppVulkan.fromBridgeFile(text, "Mali-G720 Immortalis MC12")) assertNull(AppVulkan.fromBridgeFile("device=x\n", null)) } + @Test fun withoutPromotionOnTheDriversVersionCounts() { + val g710File = g710.copy(source = "bridge") + val off = "device=Mali-G710 MC10\napi=1.1.177\ndriver_api=1.1.177\npromotion=off\nshader_int64=0\nmax_push_constants=128\n" + assertEquals(g710File, AppVulkan.fromBridgeFile(off, "Mali-G710 MC10", "1.1.177")) + val old = "device=Mali-G710 MC10\napi=1.3.177\ndriver_api=1.1.177\nshader_int64=0\nmax_push_constants=128\n" + assertEquals(g710File, AppVulkan.fromBridgeFile(old, "Mali-G710 MC10")) + assertNull(AppVulkan.fromBridgeFile(off, "Mali-G710 MC10", "1.3.212")) + } + @Test fun anAdrenoSessionIsNotTouched() { proton("proton-exp") assertNull(run(g710, bridge = false)) @@ -120,6 +131,30 @@ class BridgeDxvkTest { assertNull(state().getJSONObject("active").optJSONObject("proton-exp")?.optJSONObject("dxvk")) } + @Test fun aFailedDetectionKeepsTheLastAutomaticChoice() { + proton("proton-exp") + writeState("proton-exp", JSONObject().put("file", old).put("protonVersion", "experimental-11").put("auto", true)) + assertNull(run(null)) + assertEquals(old, state().getJSONObject("active").getJSONObject("proton-exp").getJSONObject("dxvk").getString("file")) + } + + @Test fun oneProtonFailingDoesNotStopTheOthers() { + proton("ge") + proton("proton-exp") + val applied = mutableListOf() + val result = run(g710, applyAuto = { id, file -> if (id == "ge") error("disk full"); applied += "$id $file"; "swapped $id" }) + assertEquals(listOf("proton-exp $old"), applied) + assertTrue(result!!, result.contains("disk full") && result.contains("swapped proton-exp")) + } + + @Test fun aChoiceWhoseSavedCopyIsGoneIsKept() { + proton("proton-exp") + writeState("proton-exp", JSONObject().put("file", old).put("label", "DXVK 1.10.3").put("protonVersion", "experimental-11").put("auto", true)) + val result = run(full, undoAuto = { id, comp -> ComponentsManager.undoAutoChoice(context, id, comp) }) + assertTrue(result!!, result.contains("its own copy is gone")) + assertEquals(old, state().getJSONObject("active").getJSONObject("proton-exp").getJSONObject("dxvk").getString("file")) + } + @Test fun aProtonUpdateWithNoRuleLeftJustForgetsTheChoice() { proton("proton-exp", "experimental-12") writeState("proton-exp", JSONObject().put("file", old).put("protonVersion", "experimental-11").put("auto", true))