diff --git a/app/src/main/java/com/droiddeck/launcher/SessionActivity.kt b/app/src/main/java/com/droiddeck/launcher/SessionActivity.kt index 6de07a00dc..d8ded91035 100644 --- a/app/src/main/java/com/droiddeck/launcher/SessionActivity.kt +++ b/app/src/main/java/com/droiddeck/launcher/SessionActivity.kt @@ -2001,9 +2001,17 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback { if (line.contains(FEX_MISSING)) fexMissing = true } val steamSetup = com.droiddeck.launcher.session.SteamClientSetupFailure.find(text.lineSequence()) + val launchFailure = com.droiddeck.launcher.session.SessionLaunchFailure.find(text.lineSequence()) if (steamSetup != null) { val message = getString(if (steamSetup.download) R.string.session_end_steam_download else R.string.session_end_steam_setup) EndHint(listOfNotNull(message, steamSetup.curlError).joinToString("\n")) + } else if (launchFailure == com.droiddeck.launcher.session.SessionLaunchFailure.STEAM_ILLEGAL_INSTRUCTION) { + val message = getString(R.string.session_end_steam_sigill) + val fallback = if (SessionState.steamClientArch == "arm64") getString(R.string.session_end_steam_try_x64) else null + EndHint(listOfNotNull(message, fallback).joinToString("\n")) + } else if (launchFailure == com.droiddeck.launcher.session.SessionLaunchFailure.VULKAN_DEVICE_MISSING) { + val adreno = com.droiddeck.launcher.gpu.GpuInfo.detect().family != com.droiddeck.launcher.gpu.GpuInfo.Family.NOT_ADRENO + EndHint(getString(if (adreno) R.string.session_end_vulkan_device else R.string.session_end_gpu_unsupported)) } else if (fexMissing) { val what = com.droiddeck.launcher.frontend.Library.nameForProgram(SessionState.program) ?: getString(R.string.session_end_program) EndHint(getString(R.string.session_end_fex_missing, what), evenOnSuccess = true) diff --git a/app/src/main/java/com/droiddeck/launcher/core/DeviceReport.kt b/app/src/main/java/com/droiddeck/launcher/core/DeviceReport.kt index 903851a5a9..0d3900dc14 100644 --- a/app/src/main/java/com/droiddeck/launcher/core/DeviceReport.kt +++ b/app/src/main/java/com/droiddeck/launcher/core/DeviceReport.kt @@ -29,6 +29,11 @@ import java.util.Locale object DeviceReport { private const val TAG = "DeviceReport" + internal fun cpuFeaturesSummary(cpuInfo: String): String = cpuInfo.lineSequence() + .filter { it.substringBefore(':').trim() == "Features" } + .map { it.substringAfter(':').trim().split(Regex("\\s+")).filter(String::isNotEmpty).joinToString(" ") } + .filter(String::isNotEmpty).distinct().joinToString(" | ").ifEmpty { "not reported" } + fun write(context: Context, target: File, mode: String) { try { target.writeText(build(context, mode)) @@ -141,6 +146,7 @@ object DeviceReport { h("CPU and memory") k("Cores", CpuCores.all.size) + k("CPU features", cpuFeaturesSummary(FileUtils.readString(File("/proc/cpuinfo")).orEmpty())) b.append("Core ceilings ") b.append(CpuCores.all.joinToString(", ") { c -> "cpu$c " + (CpuCores.maxGhz(c)?.let { String.format(Locale.US, "%.2f GHz", it) } ?: "?") diff --git a/app/src/main/java/com/droiddeck/launcher/gpu/TurnipDriver.java b/app/src/main/java/com/droiddeck/launcher/gpu/TurnipDriver.java index 9978409c5f..9bae92e42a 100644 --- a/app/src/main/java/com/droiddeck/launcher/gpu/TurnipDriver.java +++ b/app/src/main/java/com/droiddeck/launcher/gpu/TurnipDriver.java @@ -22,6 +22,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.List; +import java.util.function.Supplier; import java.util.zip.ZipEntry; import java.util.zip.ZipInputStream; @@ -47,10 +48,16 @@ public final class TurnipDriver { private final Context context; private final File contentDir; + private final Supplier gpuDetector; public TurnipDriver(Context context) { + this(context, GpuInfo.Companion::detect); + } + + TurnipDriver(Context context, Supplier gpuDetector) { this.context = context; this.contentDir = new File(context.getFilesDir(), "graphics_driver"); + this.gpuDetector = gpuDetector; } public String driverPath(String driverId) { @@ -284,7 +291,12 @@ public final class TurnipDriver { } String quest = QuestExperimental.INSTANCE.defaultAndroidDriver(); if (quest != null) return quest; - int model = GpuInfo.Companion.detect().getModel(); + GpuInfo gpu = gpuDetector.get(); + if (gpu.getFamily() == GpuInfo.Family.NOT_ADRENO) { + Log.i(TAG, "not an Adreno GPU; leaving the display driver to the system"); + return null; + } + int model = gpu.getModel(); Log.i(TAG, "gpu model: " + (model == 0 ? "unknown" : model)); return chooseByModel(model, android.os.Build.VERSION.SDK_INT); } diff --git a/app/src/main/java/com/droiddeck/launcher/session/SessionLaunchFailure.kt b/app/src/main/java/com/droiddeck/launcher/session/SessionLaunchFailure.kt new file mode 100644 index 0000000000..22d8b952cd --- /dev/null +++ b/app/src/main/java/com/droiddeck/launcher/session/SessionLaunchFailure.kt @@ -0,0 +1,42 @@ +package com.droiddeck.launcher.session + +enum class SessionLaunchFailure { + STEAM_ILLEGAL_INSTRUCTION, + VULKAN_DEVICE_MISSING; + + companion object { + private val ANSI = Regex("\u001b\\[[0-?]*[ -/]*[@-~]") + private val STEAM_EXIT = Regex("== steam exited rc=(\\d+)") + + fun find(lines: Sequence): SessionLaunchFailure? { + var steamStarted = false + var illegalInstruction = false + var missingDevice = false + lines.forEach { raw -> + val line = ANSI.replace(raw, "").trim() + when { + line.startsWith("== droiddeck-session ") -> { + steamStarted = false + illegalInstruction = false + missingDevice = false + } + line.startsWith("== STEP ") && line.contains("starting the Steam client") -> { + steamStarted = true + illegalInstruction = false + } + STEAM_EXIT.matches(line) && steamStarted -> + illegalInstruction = STEAM_EXIT.matchEntire(line)?.groupValues?.get(1) == "132" + line.startsWith("[gamescope]") && line.contains("vulkan:") -> when { + line.contains("failed to find physical device") -> missingDevice = true + line.contains("selecting physical device") -> missingDevice = false + } + } + } + return when { + illegalInstruction -> STEAM_ILLEGAL_INSTRUCTION + missingDevice -> VULKAN_DEVICE_MISSING + else -> null + } + } + } +} diff --git a/app/src/main/res/values-zh-rCN/strings.xml b/app/src/main/res/values-zh-rCN/strings.xml index 68d927ebb2..48a8db152d 100644 --- a/app/src/main/res/values-zh-rCN/strings.xml +++ b/app/src/main/res/values-zh-rCN/strings.xml @@ -2957,4 +2957,8 @@ 6DoF 虚拟屏幕 在光线充足的房间内缓慢环顾四周。\n不要遮挡追踪摄像头,并面向家具等有明显细节的物体。 DroidDeck ChArUco 30 mm + Steam 因非法指令(SIGILL)停止。这可能是 CPU 指令兼容问题,也可能是客户端崩溃。请分享日志并附上设备信息。 + 可尝试“Steam 设置 → Steam 客户端 → x86-64(实验)”。此选项需要额外下载,运行速度也可能更慢。 + Linux 图形驱动未找到可用的 Vulkan 设备。请确认所选 Linux GPU 驱动支持这颗 GPU。 + 当前配置缺少兼容这颗 GPU 的 Linux Vulkan 驱动,会话无法启动。Adreno Turnip 驱动不能为联发科/Mali GPU 增加支持。 diff --git a/app/src/main/res/values-zh-rHK/strings.xml b/app/src/main/res/values-zh-rHK/strings.xml index a39c7b101d..7683b0d64b 100644 --- a/app/src/main/res/values-zh-rHK/strings.xml +++ b/app/src/main/res/values-zh-rHK/strings.xml @@ -2957,4 +2957,8 @@ 6DoF 虛擬螢幕 在光線充足的房間內緩慢環顧四周。\n不要遮擋追蹤攝影機,並面向家具等有明顯細節的物體。 DroidDeck ChArUco 30 mm + Steam 因非法指令(SIGILL)停止。這可能是 CPU 指令兼容問題,也可能是客戶端崩潰。請分享記錄並附上裝置資訊。 + 可嘗試「Steam 設定 → Steam 客戶端 → x86-64(實驗)」。此選項需要額外下載,執行速度也可能更慢。 + Linux 圖形驅動程式未找到可用的 Vulkan 裝置。請確認所選 Linux GPU 驅動程式支援這顆 GPU。 + 目前設定缺少兼容這顆 GPU 的 Linux Vulkan 驅動程式,工作階段無法啟動。Adreno Turnip 驅動程式無法為聯發科/Mali GPU 增加支援。 diff --git a/app/src/main/res/values-zh-rTW/strings.xml b/app/src/main/res/values-zh-rTW/strings.xml index d29f3cef46..2bc8dc3c7f 100644 --- a/app/src/main/res/values-zh-rTW/strings.xml +++ b/app/src/main/res/values-zh-rTW/strings.xml @@ -2957,4 +2957,8 @@ 6DoF 虛擬螢幕 在光線充足的房間內緩慢環顧四周。\n不要遮擋追蹤攝影機,並面向家具等有明顯細節的物體。 DroidDeck ChArUco 30 mm + Steam 因非法指令(SIGILL)停止。這可能是 CPU 指令相容問題,也可能是用戶端當機。請分享記錄並附上裝置資訊。 + 可嘗試「Steam 設定 → Steam 用戶端 → x86-64(實驗)」。此選項需要額外下載,執行速度也可能更慢。 + Linux 圖形驅動程式未找到可用的 Vulkan 裝置。請確認所選 Linux GPU 驅動程式支援這顆 GPU。 + 目前設定缺少相容這顆 GPU 的 Linux Vulkan 驅動程式,工作階段無法啟動。Adreno Turnip 驅動程式無法為聯發科/Mali GPU 增加支援。 diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index c449a05be5..392c67ebfa 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -3046,4 +3046,8 @@ Saved views can be recalculated. Start a new calibration to capture in the current tracking frame. Hand model checksum mismatch OpenCV could not load + Steam stopped with an illegal instruction (SIGILL). This can be a CPU instruction compatibility problem or a client crash. Share the logs with your device details. + You can try Steam settings → Steam client → x86-64 (experimental). It needs an additional download and may run more slowly. + The Linux graphics driver could not find a usable Vulkan device. Check that the selected Linux GPU driver supports this GPU. + This session cannot start because this GPU has no compatible Linux Vulkan driver in the current setup. Adreno Turnip drivers cannot enable support for MediaTek/Mali GPUs. diff --git a/app/src/test/java/com/droiddeck/launcher/core/DeviceReportCpuTest.kt b/app/src/test/java/com/droiddeck/launcher/core/DeviceReportCpuTest.kt new file mode 100644 index 0000000000..88520b21c6 --- /dev/null +++ b/app/src/test/java/com/droiddeck/launcher/core/DeviceReportCpuTest.kt @@ -0,0 +1,20 @@ +package com.droiddeck.launcher.core + +import org.junit.Assert.assertEquals +import org.junit.Test + +class DeviceReportCpuTest { + @Test fun onlyFeatureListsAreReportedAndDifferentCoreCapabilitiesAreKept() { + val cpuInfo = """ + processor : 0 + Features : fp asimd aes + Serial : private-device-id + processor : 1 + Features : fp asimd aes atomics + processor : 2 + Features : fp asimd aes + """.trimIndent() + assertEquals("fp asimd aes | fp asimd aes atomics", DeviceReport.cpuFeaturesSummary(cpuInfo)) + assertEquals("not reported", DeviceReport.cpuFeaturesSummary("processor : 0\n")) + } +} diff --git a/app/src/test/java/com/droiddeck/launcher/gpu/TurnipDriverAutoTest.kt b/app/src/test/java/com/droiddeck/launcher/gpu/TurnipDriverAutoTest.kt index 95713589ea..123fcee195 100644 --- a/app/src/test/java/com/droiddeck/launcher/gpu/TurnipDriverAutoTest.kt +++ b/app/src/test/java/com/droiddeck/launcher/gpu/TurnipDriverAutoTest.kt @@ -1,6 +1,11 @@ package com.droiddeck.launcher.gpu +import android.os.Environment +import android.os.Build import com.droiddeck.launcher.session.QuestExperimental +import com.droiddeck.launcher.session.SessionPrefs +import java.io.File +import org.junit.After import org.junit.Assert.assertEquals import org.junit.Before import org.junit.Test @@ -9,6 +14,7 @@ import org.robolectric.RobolectricTestRunner import org.robolectric.RuntimeEnvironment import org.robolectric.annotation.Config import org.robolectric.shadows.ShadowBuild +import org.robolectric.util.ReflectionHelpers @RunWith(RobolectricTestRunner::class) @Config(sdk = [28], manifest = Config.NONE) @@ -16,10 +22,23 @@ class TurnipDriverAutoTest { @Before fun reset() { ShadowBuild.setModel("Phone") ShadowBuild.setDevice("phone") + overrideFile().delete() } + @After fun cleanUp() { + overrideFile().delete() + SessionPrefs.setAndroidDriver(RuntimeEnvironment.getApplication(), TurnipDriver.AUTO) + File(RuntimeEnvironment.getApplication().filesDir, "graphics_driver/test-pinned").deleteRecursively() + } + + private fun overrideFile() = File(Environment.getExternalStorageDirectory(), "Download/droiddeck-driver") + + private fun gpu(model: Int, adreno: Boolean = true) = GpuInfo( + "test GPU", model, GpuInfo.familyOf(adreno, model), "", false, + ) + @Test fun questModelsUseTheirPatchedDriverAsTheFallback() { - val driver = TurnipDriver(RuntimeEnvironment.getApplication()) + val driver = TurnipDriver(RuntimeEnvironment.getApplication()) { error("Quest must not use generic GPU detection") } for (model in listOf("Quest 3", "Quest 3S", "Quest 2")) { ShadowBuild.setModel(model) assertEquals(if (model == "Quest 2") QuestExperimental.DRIVER_A6XX else QuestExperimental.DRIVER, @@ -27,8 +46,54 @@ class TurnipDriverAutoTest { } } - @Test fun otherDevicesRetainTheGenericFallback() { - assertEquals("turnip25.1.0", TurnipDriver(RuntimeEnvironment.getApplication()).autoId()) + @Test fun aNonAdrenoDeviceDoesNotAutomaticallyLoadTurnip() { + assertEquals(GpuInfo.Family.NOT_ADRENO, GpuInfo.detect().family) + assertEquals("system", TurnipDriver(RuntimeEnvironment.getApplication()).autoId()) + } + + @Test fun autoSelectionUsesTheDetectedFamilyAndModel() { + val context = RuntimeEnvironment.getApplication() + for ((detected, expected) in listOf( + gpu(0, adreno = false) to "system", + gpu(0) to "turnip25.1.0", + gpu(650) to "turnip26.3.0-a6xx", + gpu(730) to "turnip25.1.0", + gpu(850) to "turnip-sdk36", + )) { + var calls = 0 + assertEquals(expected, TurnipDriver(context) { calls++; detected }.autoId()) + assertEquals(1, calls) + } + } + + @Test fun nonAdrenoDoesNotUseTheAndroid16TurnipFallback() { + val context = RuntimeEnvironment.getApplication() + val sdk = Build.VERSION.SDK_INT + try { + ReflectionHelpers.setStaticField(Build.VERSION::class.java, "SDK_INT", 36) + assertEquals("system", TurnipDriver(context) { gpu(0, adreno = false) }.autoId()) + assertEquals("turnip-sdk36", TurnipDriver(context) { gpu(0) }.autoId()) + } finally { + ReflectionHelpers.setStaticField(Build.VERSION::class.java, "SDK_INT", sdk) + } + } + + @Test fun externalOverrideStillTakesPriorityOverDetection() { + val driver = TurnipDriver(RuntimeEnvironment.getApplication()) { error("override must precede detection") } + overrideFile().parentFile!!.mkdirs() + overrideFile().writeText("system") + assertEquals("system", driver.autoId()) + overrideFile().writeText("a8") + assertEquals("turnip-sdk36", driver.autoId()) + } + + @Test fun aManuallySelectedImportedDriverStillTakesPriorityOverDetection() { + val context = RuntimeEnvironment.getApplication() + val dir = File(context.filesDir, "graphics_driver/test-pinned").apply { mkdirs() } + File(dir, "meta.json").writeText("""{"libraryName":"test.so"}""") + File(dir, "test.so").writeText("") + SessionPrefs.setAndroidDriver(context, "test-pinned") + assertEquals("test-pinned", TurnipDriver(context) { error("manual choice must precede detection") }.install()) } @Test fun normalizedGpuModelsSelectExistingGenerationDrivers() { diff --git a/app/src/test/java/com/droiddeck/launcher/session/SessionLaunchFailureTest.kt b/app/src/test/java/com/droiddeck/launcher/session/SessionLaunchFailureTest.kt new file mode 100644 index 0000000000..e36f237509 --- /dev/null +++ b/app/src/test/java/com/droiddeck/launcher/session/SessionLaunchFailureTest.kt @@ -0,0 +1,54 @@ +package com.droiddeck.launcher.session + +import org.junit.Assert.assertEquals +import org.junit.Assert.assertNull +import org.junit.Test + +class SessionLaunchFailureTest { + private fun find(vararg lines: String) = SessionLaunchFailure.find(lines.asSequence()) + + @Test fun installedSteamThatExitsWithSigillHasACpuFailureHint() { + assertEquals(SessionLaunchFailure.STEAM_ILLEGAL_INSTRUCTION, find( + "== STEP 06:35:36.987 Steam client ready", + "== STEP 06:35:41.058 starting the Steam client", + "/usr/local/bin/droiddeck-session: line 309: 1192 Illegal instruction steam", + "== steam exited rc=132", + "(EE) failed to read Wayland events: Broken pipe", + )) + } + + @Test fun gamescopeWithoutAPhysicalDeviceHasAGraphicsFailureHint() { + assertEquals(SessionLaunchFailure.VULKAN_DEVICE_MISSING, find( + "[gamescope] [\u001b[0;31mError\u001b[0m] \u001b[0;37mvulkan:\u001b[0m failed to find physical device", + "SDL_Vulkan_CreateSurface failed: VK_KHR_wayland_surface extension is not enabled in the Vulkan instance.Failed to create backend.", + )) + } + + @Test fun unrelatedIllegalInstructionsAndExitCodesAreNotBlamedOnSteam() { + assertNull(find("game: Illegal instruction", "== steam exited rc=132")) + assertNull(find("== STEP 12:00:00 starting the Steam client", "== steam exited rc=139")) + assertNull(find("== STEP 12:00:00 starting the Steam client", "== steam exited rc=1320")) + assertNull(find("== STEP 12:00:00 starting the Steam client", "== steam exited rc=0")) + } + + @Test fun onlyTheLatestClientAttemptCounts() { + assertNull(find( + "== STEP 12:00:00 starting the Steam client", "== steam exited rc=132", + "== STEP 12:01:00 starting the Steam client", "== steam exited rc=0", + )) + } + + @Test fun aLaterSuccessfulDeviceSelectionClearsTheGraphicsFailure() { + assertNull(find( + "[gamescope] [Error] vulkan: failed to find physical device", + "[gamescope] [Info] vulkan: selecting physical device 'Turnip Adreno (TM) 610': queue family 0", + )) + } + + @Test fun aNewSessionDoesNotReuseAnOldFailure() { + assertNull(find( + "== STEP 12:00:00 starting the Steam client", "== steam exited rc=132", + "== droiddeck-session Fri Oct 23 12:01:00 mode=steam", + )) + } +} diff --git a/docs/development/steam-launch-hardware.md b/docs/development/steam-launch-hardware.md new file mode 100644 index 0000000000..234dedeac9 --- /dev/null +++ b/docs/development/steam-launch-hardware.md @@ -0,0 +1,61 @@ +# Steam startup failures on older CPUs and non-Adreno GPUs + +These are different failures, even when neither reaches the Steam interface. + +## Steam exits with SIGILL (#1376) + +The [Redmi Note 8 report](https://github.com/Droid-Deck/DroidDeck/issues/1376) +shows gamescope selecting Adreno 610 successfully, all 17 client parts being +downloaded, and the native Steam executable immediately exiting with status +132 (`Illegal instruction`). The failure occurs after installation, not during +the runtime download. The supplied logs do not identify the faulting program +counter or CPU feature flags, so they cannot establish the exact instruction. + +The official ARM64 Steam client and web helper inspected during this +investigation contain LSE atomic instructions. This is a compatibility concern +for CPUs without LSE, not proof that LSE caused this particular crash. Device +reports now include only the kernel's CPU `Features` lists, without unrelated +`/proc/cpuinfo` fields such as serial numbers. + +After SIGILL, the failure screen explains the signal and, for an ARM64 client, +points to **Steam settings → Steam client → x86-64 (experimental)**. This is an +explicit user choice with an additional download and emulation overhead. It +does not establish that the device can run every component or game. + +The x86-64 client normally reuses a matching-build native ARM web helper. +When CPU feature flags explicitly lack `atomics`, it now retains the existing +x86 web helper instead. Otherwise the fallback could re-enter native code +containing the same instruction class. All reported core feature lists must +include that exact flag; absent or unreadable feature data retains the prior +behavior. Explicit x86-helper selection and the client-build matching rule +remain unchanged. + +## gamescope cannot find a Vulkan device (#1368) + +The [MT6993 report](https://github.com/Droid-Deck/DroidDeck/issues/1368) shows a +non-Adreno device starting with an Adreno Turnip display driver, followed by +gamescope failing to find a physical device through the Linux freedreno ICD. +Steam has not been started in that trace. + +Automatic Android display-driver selection now leaves non-Adreno GPUs on the +system driver rather than choosing Turnip from the Android SDK version. An +Adreno GPU with an unknown model still uses the existing SDK fallback; Quest, +external overrides and manual selections retain their priority. The failure +screen distinguishes an unavailable Linux Vulkan device from a failed Steam +download. + +This does not implement MT6993/Mali graphics support. The Linux session needs +a driver for that GPU and kernel, and the Android compositor also has Vulkan +requirements. The system Android driver alone does not provide the Linux +driver; the desktop's software rendering does not replace the outer +compositor. Removing the unsupported-device notice or importing Adreno +Turnip cannot supply these missing components. + +## Verification boundary + +Regression tests cover actual automatic driver selection, log classification +and the x86 client's web-helper selection. The supplied session logs can be +replayed through the classifier. No target phone was available, and the +specific ARM64 instruction fault has not been reproduced under a debugger. +Neither report should be treated as verified fixed on hardware based on these +tests alone. diff --git a/tools/linuxfs/overlay/usr/local/bin/droiddeck-steam-x64 b/tools/linuxfs/overlay/usr/local/bin/droiddeck-steam-x64 index e52a4e9858..26fbeeca45 100755 --- a/tools/linuxfs/overlay/usr/local/bin/droiddeck-steam-x64 +++ b/tools/linuxfs/overlay/usr/local/bin/droiddeck-steam-x64 @@ -901,13 +901,25 @@ x64_gpu_watch() { x64_gpu_probe } +x64_arm_webhelper_cpu_supported() { + local status=0 + # Valve's native ARM web helper contains LSE atomics; missing CPU data cannot establish incompatibility. + awk -F: ' + $1 ~ /^[[:space:]]*Features[[:space:]]*$/ { + if ($2 !~ /(^|[[:space:]])atomics([[:space:]]|$)/) unsupported = 1 + } + END { exit unsupported ? 1 : 0 } + ' /proc/cpuinfo 2>/dev/null || status=$? + [ "$status" != 1 ] +} + x64_exec() { x64_env cd "$STEAM_X64" # The client checksums its files at start and reinstalls over edited ones, so the session shim (preload/net.c) # swaps the web helper at exec. The arm64 helper only comes up against a client of the same build. if [ "${BL_X64_X86_WEBHELPER:-0}" != 1 ] && [ -x /usr/local/bin/droiddeck-x64-arm-webhelper ] && - [ -x "$ARM_STEAM/steamrtarm64/steamwebhelper" ]; then + [ -x "$ARM_STEAM/steamrtarm64/steamwebhelper" ] && x64_arm_webhelper_cpu_supported; then local chan x86_build arm_build chan=$(cat "$STEAM_X64/package/beta" 2>/dev/null || echo "$X64_CHANNEL") x86_build=$(awk -F'"' '$2 == "version" { print $4; exit }' "$STEAM_X64/package/steam_client_${chan}_steamrt64.manifest" 2>/dev/null || true) @@ -1142,4 +1154,4 @@ for attempt in 1 2 3 4 5; do ( x64_exec -clientbeta "$X64_CHANNEL" -no-cef-sandbox "${cef[@]}" "$@" ) >>"$LOG" 2>&1 || rc=$? step "client exited rc=$rc" [ "$rc" = 42 ] || break -done \ No newline at end of file +done diff --git a/tools/tests/test_steam_x64_cpu.py b/tools/tests/test_steam_x64_cpu.py new file mode 100644 index 0000000000..ad8e2dc271 --- /dev/null +++ b/tools/tests/test_steam_x64_cpu.py @@ -0,0 +1,79 @@ +import os +from pathlib import Path +import subprocess +import tempfile +import unittest + +SCRIPT = Path(__file__).resolve().parents[1] / 'linuxfs/overlay/usr/local/bin/droiddeck-steam-x64' + + +class SteamX64CpuTest(unittest.TestCase): + def selection(self, features, *, forced=False, same_build=True, unreadable=False): + with tempfile.TemporaryDirectory() as tmp: + root = Path(tmp) + arm = root / 'arm' + x64 = root / 'x64' + for base in (arm, x64): + (base / 'package').mkdir(parents=True) + (arm / 'steamrtarm64').mkdir() + (arm / 'steamrtarm64/steamwebhelper').touch(mode=0o700) + shim = root / 'arm-shim' + shim.touch(mode=0o700) + (x64 / 'package/beta').write_text('publicbeta\n') + for base, arch, version in ((x64, 'steamrt64', '123'), (arm, 'linuxarm64', '123' if same_build else '122')): + (base / f'package/steam_client_publicbeta_{arch}.manifest').write_text(f'"version" "{version}"\n') + cpuinfo = root / 'cpuinfo' + if not unreadable: + cpuinfo.write_text(features) + text = SCRIPT.read_text() + start = text.find('x64_arm_webhelper_cpu_supported() {') + helper = text[start:text.index('x64_exec() {')] if start >= 0 else '' + selection = text.split('x64_exec() {', 1)[1].split(' mkdir -p "$STEAM_X64/logs"', 1)[0] + shell = helper + '\nx64_env() { :; }\nx64_webhelper_gpu() { return 1; }\nselect_helper() {' + selection + '\nprintf "%s|%s\\n" "${BL_X64_ARM_WEBHELPER:-x86}" "${BL_WEBHELPER_ARGS:-}";\n}\nselect_helper\n' + shell = shell.replace('/proc/cpuinfo', str(cpuinfo)).replace('/usr/local/bin/droiddeck-x64-arm-webhelper', str(shim)) + env = dict(os.environ, STEAM_X64=str(x64), ARM_STEAM=str(arm), X64_CHANNEL='publicbeta', BL_X64_X86_WEBHELPER='1' if forced else '0') + env.pop('BL_X64_ARM_WEBHELPER', None) + env.pop('BL_WEBHELPER_ARGS', None) + result = subprocess.run(['bash', '-eu', '-c', shell], env=env, capture_output=True, text=True) + self.assertEqual(result.returncode, 0, result.stderr) + return result.stdout.strip(), str(shim) + + def test_missing_atomics_keeps_x86_helper(self): + result, _ = self.selection('Features : fp asimd aes crc32\n') + self.assertEqual(result, 'x86|stock') + + def test_atomics_keeps_same_build_arm_helper(self): + result, arm = self.selection('Features : fp asimd atomics aes\n') + self.assertEqual(result, arm + '|') + + def test_exact_token_required(self): + result, _ = self.selection('Features : fp noatomics atomics_extra\n') + self.assertEqual(result, 'x86|stock') + + def test_any_explicit_core_without_atomics_keeps_x86_helper(self): + result, _ = self.selection('processor : 0\nFeatures : fp atomics\nprocessor : 1\nFeatures : fp aes\n') + self.assertEqual(result, 'x86|stock') + + def test_empty_features_is_explicitly_unsupported(self): + result, _ = self.selection('Features : \n') + self.assertEqual(result, 'x86|stock') + + def test_absent_features_preserves_existing_behavior(self): + result, arm = self.selection('processor : 0\n') + self.assertEqual(result, arm + '|') + + def test_unreadable_cpuinfo_preserves_existing_behavior(self): + result, arm = self.selection('', unreadable=True) + self.assertEqual(result, arm + '|') + + def test_forced_x86_still_wins(self): + result, _ = self.selection('Features : atomics\n', forced=True) + self.assertEqual(result, 'x86|stock') + + def test_supported_cpu_still_requires_same_build(self): + result, _ = self.selection('Features : atomics\n', same_build=False) + self.assertEqual(result, 'x86|stock') + + +if __name__ == '__main__': + unittest.main()