Compare commits

..
Author SHA1 Message Date
btns29andbtns29 38c2c00c86 Keep safe webhelper layout on Mali bridge (#3420)
* Keep safe webhelper layout on Mali bridge

* Name the zygote regression in the layout test

---------

Co-authored-by: btns29 <btns29@users.noreply.github.com>
2026-11-29 15:53:48 -05:00
13 changed files with 40 additions and 118 deletions

No files matched your search

@@ -6349,7 +6349,10 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
if (!intent.hasExtra(EXTRA_LINK_TASK)) intent.putExtra(EXTRA_LINK_TASK, this.intent.getIntExtra(EXTRA_LINK_TASK, -1))
setIntent(intent)
if (::pip.isInitialized) pip.refresh(true)
if (intent.getBooleanExtra(EXTRA_STEAMVR, false) && SessionState.mode == SessionService.MODE_STEAM) requestSteamVr()
if (intent.getBooleanExtra(EXTRA_STEAMVR, false) && SessionState.mode == SessionService.MODE_STEAM) {
SessionState.steamVr = true
steamVrAutoTried = false
}
if (intent.action == SessionService.ACTION_HOME_GUIDE) {
handleHomeGuideIntent(intent)
} else if (intent.action == SessionService.ACTION_RESUME) {
@@ -6438,10 +6441,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
private val questSteamVrRequest = object : Runnable {
override fun run() {
if (com.droiddeck.launcher.session.QuestSteamVrLaunch.takeRequest(this@SessionActivity) &&
SessionState.running && SessionState.mode == SessionService.MODE_STEAM) {
if (com.droiddeck.launcher.session.QuestSteamVrLaunch.opensDirectly(steamVrStatus)) steamVrAction("start")
else requestSteamVr()
}
SessionState.running && SessionState.mode == SessionService.MODE_STEAM) steamVrAction("start")
uiHandler.postDelayed(this, 1000)
}
}
@@ -6500,12 +6500,6 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
updateHeadTracker()
}
private fun requestSteamVr() {
SessionState.steamVr = true
steamVrAutoTried = false
steamVrInstallTried = false
}
private fun steamVrAction(action: String) {
if (action == "start" && com.droiddeck.launcher.session.QuestExperimental.isSupported()) {
startActivity(android.content.Intent(this, QuestXrActivity::class.java))
@@ -6983,7 +6977,6 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
SessionState.mode == SessionService.MODE_STEAM, steamVrAutoTried, steamVrInstallTried) ?: return
if (action == "start") steamVrAutoTried = true else steamVrInstallTried = true
Log.i(TAG, "requested SteamVR $action (glasses=${glasses.model}, output=$glassesOutputActive, control=${glasses.canControl})")
if (action == "install") Toast.makeText(this, R.string.cardboard_steamvr_installing, Toast.LENGTH_LONG).show()
steamVrAction(action)
}
@@ -951,7 +951,6 @@ internal object EnhancedSessionLogShare {
"battlenet.log", "spawned.log", "flatpak-install.log", "cef_log.txt", "cef_log.previous.txt", "droiddeck-bionic.log",
"console_log.txt", "webhelper_js.txt", "controller_support.txt", "systemperfmanager.txt",
"rpcs3", "RPCS3.log",
"droiddeck-steamvr-launch.log", "droiddeck-vrstartup.log",
)
private val KNOWN_COMPONENT_PATTERNS = listOf(
Regex("[0-9]{4}-[0-9]{2}-[0-9]{2}-[0-9]{2,}-[a-z0-9-]{1,24}"),
@@ -1,7 +1,6 @@
package com.droiddeck.launcher.session
import android.content.Context
import com.droiddeck.launcher.gpu.SteamVr
import java.io.File
/**
@@ -33,7 +32,4 @@ object QuestSteamVrLaunch {
fun takeRequest(context: Context): Boolean =
QuestExperimental.isSupported() && File(context.filesDir, "$DIR/$REQUEST").delete()
fun opensDirectly(status: SteamVr.Status?): Boolean =
status == SteamVr.Status.READY || status == SteamVr.Status.RUNNING
}
@@ -114,23 +114,6 @@ class EnhancedSessionLogShareTest {
SessionLogShare.clear(app)
}
@Test fun steamVrLaunchLogsAreSharedUnderTheirNames() {
val session = tmp.newFolder("2026-11-29-05-steam")
session.resolve("session.log").writeText("startup ok\n")
val steam = session.resolve("steam").apply { mkdirs() }
steam.resolve("droiddeck-steamvr-launch.log").writeText("downloading SteamVR (571 MB)\n")
steam.resolve("droiddeck-vrstartup.log").writeText("vrstartup ok\n")
steam.resolve("unknown-tool.log").writeText("other\n")
val zips = EnhancedSessionLogShare.create(app, session)
val names = zips.flatMap { zip -> ZipFile(zip).use { archive -> archive.entries().toList().map { it.name } } }
assertTrue(names.contains("${session.name}/steam/droiddeck-steamvr-launch.log"))
assertTrue(names.contains("${session.name}/steam/droiddeck-vrstartup.log"))
assertTrue(names.none { it.endsWith("/unknown-tool.log") })
SessionLogShare.clear(app)
}
@Test fun oversizedFilesKeepBoundedBeginningAndTailAndDeclareTruncation() {
val session = tmp.newFolder("2026-11-04-02-game")
session.resolve("steam-7.log").writeText("begin\n" + "middle\n".repeat(100) + "tail\n")
@@ -1,24 +0,0 @@
package com.droiddeck.launcher.session
import com.droiddeck.launcher.gpu.SteamVr
import org.junit.Assert.assertEquals
import org.junit.Test
class QuestSteamVrLaunchTest {
@Test fun aLibraryRequestOpensTheImmersiveViewOnlyWhenSteamVrIsInstalled() {
assertEquals(
setOf(SteamVr.Status.READY, SteamVr.Status.RUNNING),
SteamVr.Status.values().filter { QuestSteamVrLaunch.opensDirectly(it) }.toSet(),
)
assertEquals(false, QuestSteamVrLaunch.opensDirectly(null))
}
@Test fun aRequestThatHasToInstallSteamVrGoesThroughTheAutomaticInstallThenStart() {
assertEquals("install", SteamVr.autoAction(SteamVr.Status.NOT_INSTALLED, requested = true, loading = false,
steamSession = true, startTried = false, installTried = false))
assertEquals(null, SteamVr.autoAction(SteamVr.Status.INSTALLING, requested = true, loading = false,
steamSession = true, startTried = false, installTried = true))
assertEquals("start", SteamVr.autoAction(SteamVr.Status.READY, requested = true, loading = false,
steamSession = true, startTried = false, installTried = true))
}
}
+2 -4
View File
@@ -145,10 +145,8 @@ verification against the actual phone's Steam version after installation.
The helper serializes installation/startup and avoids restarting an active
DroidDeck SteamVR session. Library launch diagnostics are in
`droiddeck-steamvr-launch.log` in Steam's logs directory, next to
`droiddeck-vrstartup.log`, and Share logs includes both. On a Quest the helper
only asks the app for SteamVR: the app installs it if needed, showing that it is
downloading, then opens the immersive view. It does not intercept
`${XDG_RUNTIME_DIR:-/tmp}/droiddeck-steamvr/library-launch.log`; normal runtime
logs remain in `vrstartup.log` and Steam's logs directory. It does not intercept
arbitrary external `steam://` URLs or change VR game launch arguments.
Only VR-only games (`vr_only`) wait for SteamVR and start it. Games where VR is
-4
View File
@@ -83,10 +83,6 @@ and display timing, and returns owned stereo images tagged with the latest eye p
SteamVR haptics return through the tracking bridge. No root or separate XR APK
is required. Other devices retain their existing SteamVR start behavior.
Play on SteamVR in Steam's library does the same: if SteamVR is not installed yet,
DroidDeck shows that it is downloading SteamVR, installs it, then opens the
immersive view.
The left Touch menu button is SteamVR's system button and toggles its dashboard.
The right Meta button remains reserved by the headset OS.
@@ -224,15 +224,23 @@ if [ -n "${DD_VK_DRIVER:-}" ]; then
unset dd_icd_lib
fi
dd_webhelper_layout() {
local layout
if [ -n "${DD_VKBRIDGE_WEBHELPER_ARGS:-}" ]; then
printf '%s\n' "$DD_VKBRIDGE_WEBHELPER_ARGS"
elif [ -z "${DD_VKBRIDGE_CEF_ANGLE:-}" ]; then
echo stock
elif [ "$DD_VKBRIDGE_CEF_ANGLE" = vulkan ] && [ "${DD_VKBRIDGE_CEF_VULKAN:-1}" != 0 ]; then
echo "--use-gl=angle --use-angle=vulkan +Vulkan +VulkanFromANGLE +DefaultANGLEVulkan"
else
echo "--use-gl=angle --use-angle=$DD_VKBRIDGE_CEF_ANGLE"
return
fi
if [ -z "${DD_VKBRIDGE_CEF_ANGLE:-}" ]; then
echo stock
return
fi
# ANGLE switches must not replace the helper's stable single-process layout.
layout="--no-zygote --in-process-gpu -AudioServiceOutOfProcess"
if [ "$DD_VKBRIDGE_CEF_ANGLE" = vulkan ] && [ "${DD_VKBRIDGE_CEF_VULKAN:-1}" != 0 ]; then
layout="$layout --use-gl=angle --use-angle=vulkan +Vulkan +VulkanFromANGLE +DefaultANGLEVulkan"
else
layout="$layout --use-gl=angle --use-angle=$DD_VKBRIDGE_CEF_ANGLE"
fi
printf '%s\n' "$layout"
}
dd_now_ms() {
if [ -n "${EPOCHREALTIME:-}" ]; then
@@ -546,10 +546,10 @@ VR_JS = r"""
def launch_steamvr():
say("SteamVR library launch: using the DroidDeck ARM64 helper")
logs = os.path.join(os.path.expanduser("~"), ".local/share/Steam/logs")
state = os.path.join(os.environ.get("XDG_RUNTIME_DIR", "/tmp"), "droiddeck-steamvr")
try:
os.makedirs(logs, exist_ok=True)
with open(os.path.join(logs, "droiddeck-steamvr-launch.log"), "a") as log:
os.makedirs(state, exist_ok=True)
with open(os.path.join(state, "library-launch.log"), "a") as log:
return subprocess.Popen([VR_HELPER, "launch"], stdin=subprocess.DEVNULL,
stdout=log, stderr=subprocess.STDOUT, start_new_session=True)
except OSError as e:
@@ -103,15 +103,15 @@ case "${1:-status}" in
launch)
exec 8>"$state/launch.lock"
flock -n 8 || exit 0
if [ -f "$state/quest-immersive" ]; then
: > "$state/xr-request"
echo "asked DroidDeck to install SteamVR if needed and open the Quest's immersive view"
exit 0
fi
if ! installed; then
"$0" install || exit $?
while [ -f "$state/installing" ]; do sleep 1; done
fi
if [ -f "$state/quest-immersive" ]; then
: > "$state/xr-request"
echo "asked DroidDeck to open the Quest's immersive view, which starts SteamVR"
exit 0
fi
"$0" start
;;
status)
+9 -8
View File
@@ -6,6 +6,7 @@ from pathlib import Path
SESSION = Path(__file__).resolve().parents[1] / "linuxfs/overlay/usr/local/bin/droiddeck-session"
KEYS = ("DD_VKBRIDGE_WEBHELPER_ARGS", "DD_VKBRIDGE_CEF_ANGLE", "DD_VKBRIDGE_CEF_VULKAN")
BASE = "--no-zygote --in-process-gpu -AudioServiceOutOfProcess"
def layout_function():
@@ -27,14 +28,14 @@ class WebhelperLayoutTest(unittest.TestCase):
def test_angle_on_vulkan_brings_chromiums_vulkan_compositing(self):
self.assertEqual(self.layout(DD_VKBRIDGE_CEF_ANGLE="vulkan"),
"--use-gl=angle --use-angle=vulkan +Vulkan +VulkanFromANGLE +DefaultANGLEVulkan")
BASE + " --use-gl=angle --use-angle=vulkan +Vulkan +VulkanFromANGLE +DefaultANGLEVulkan")
def test_vulkan_compositing_can_be_left_off(self):
def test_vulkan_compositing_can_be_left_off_without_zygotes(self):
self.assertEqual(self.layout(DD_VKBRIDGE_CEF_ANGLE="vulkan", DD_VKBRIDGE_CEF_VULKAN="0"),
"--use-gl=angle --use-angle=vulkan")
BASE + " --use-gl=angle --use-angle=vulkan")
def test_other_angle_backends_get_only_the_angle_switches(self):
self.assertEqual(self.layout(DD_VKBRIDGE_CEF_ANGLE="gl"), "--use-gl=angle --use-angle=gl")
self.assertEqual(self.layout(DD_VKBRIDGE_CEF_ANGLE="gl"), BASE + " --use-gl=angle --use-angle=gl")
def test_explicit_layout_wins(self):
self.assertEqual(self.layout(DD_VKBRIDGE_CEF_ANGLE="vulkan", DD_VKBRIDGE_WEBHELPER_ARGS="--x +Y"),
@@ -57,10 +58,10 @@ class WebhelperLayoutTest(unittest.TestCase):
env = {k: v for k, v in os.environ.items() if k not in KEYS}
run = lambda **s: subprocess.run(["bash", "-c", "set -u\n" + script], env={**env, **s},
capture_output=True, text=True, check=True).stdout.strip()
self.assertEqual(run(), "--use-gl=angle --use-angle=vulkan")
self.assertEqual(run(), BASE + " --use-gl=angle --use-angle=vulkan")
self.assertEqual(run(DD_VKBRIDGE_CEF_VULKAN="1"),
"--use-gl=angle --use-angle=vulkan +Vulkan +VulkanFromANGLE +DefaultANGLEVulkan")
self.assertEqual(run(DD_VKBRIDGE_CEF_ANGLE="gl"), "--use-gl=angle --use-angle=gl")
BASE + " --use-gl=angle --use-angle=vulkan +Vulkan +VulkanFromANGLE +DefaultANGLEVulkan")
self.assertEqual(run(DD_VKBRIDGE_CEF_ANGLE="gl"), BASE + " --use-gl=angle --use-angle=gl")
def test_empty_settings_are_kept_as_set(self):
script = ': "${DD_VKBRIDGE_CEF_ANGLE=vulkan}" "${DD_VKBRIDGE_CEF_VULKAN=0}"\n' + layout_function() + "dd_webhelper_layout\n"
@@ -69,7 +70,7 @@ class WebhelperLayoutTest(unittest.TestCase):
capture_output=True, text=True, check=True).stdout.strip()
self.assertEqual(run(DD_VKBRIDGE_CEF_ANGLE=""), "stock")
self.assertEqual(run(DD_VKBRIDGE_CEF_VULKAN=""),
"--use-gl=angle --use-angle=vulkan +Vulkan +VulkanFromANGLE +DefaultANGLEVulkan")
BASE + " --use-gl=angle --use-angle=vulkan +Vulkan +VulkanFromANGLE +DefaultANGLEVulkan")
if __name__ == "__main__":
+2 -4
View File
@@ -1003,15 +1003,13 @@ class SwitchToDesktopTest(unittest.TestCase):
self.assertEqual(patched["launch_steamvr"].call_count, 2)
def test_vr_launch_runs_helper_without_shell_in_background(self):
with tempfile.TemporaryDirectory() as tmp, mock.patch.dict(os.environ, {"HOME": tmp}):
with tempfile.TemporaryDirectory() as tmp, mock.patch.dict(os.environ, {"XDG_RUNTIME_DIR": tmp}):
with mock.patch.object(self.globals["subprocess"], "Popen") as popen:
LIVE["launch_steamvr"]()
self.assertEqual(popen.call_args.args, ([LIVE["VR_HELPER"], "launch"],))
self.assertTrue(popen.call_args.kwargs["start_new_session"])
self.assertNotIn("shell", popen.call_args.kwargs)
self.assertEqual(popen.call_args.kwargs["stdout"].name,
str(Path(tmp) / ".local/share/Steam/logs/droiddeck-steamvr-launch.log"))
self.assertTrue((Path(tmp) / ".local/share/Steam/logs/droiddeck-steamvr-launch.log").exists())
self.assertTrue((Path(tmp) / "droiddeck-steamvr/library-launch.log").exists())
def test_the_request_goes_to_steamos_session_select(self):
helper = LIVE["Helper"]("/steam", 1)
-26
View File
@@ -274,32 +274,6 @@ class SteamVrHelperTest(unittest.TestCase):
self.assertTrue(vrpath.is_file())
self.assertTrue(xr.is_symlink())
def launch(self):
self.executable(self.commands / 'curl', 'echo curl >> "$CURL_CALLS"; exit 22')
self.environment['CURL_CALLS'] = str(self.root / 'curl-calls')
self.helper.chmod(0o755)
return subprocess.run(['sh', str(self.helper), 'launch'], env=self.environment,
capture_output=True, text=True, timeout=5)
def test_quest_launch_hands_a_missing_steamvr_to_the_app_without_downloading_it(self):
(self.steamvr / 'bin/linuxarm64/vrstartup').unlink()
state = self.runtime / 'droiddeck-steamvr'
state.mkdir(parents=True)
(state / 'quest-immersive').touch()
result = self.launch()
self.assertEqual(result.returncode, 0, result.stderr)
self.assertTrue((state / 'xr-request').is_file())
self.assertFalse((self.root / 'curl-calls').exists())
self.assertFalse((state / 'installing').exists())
def test_launch_elsewhere_still_installs_a_missing_steamvr_itself(self):
(self.steamvr / 'bin/linuxarm64/vrstartup').unlink()
result = self.launch()
self.assertEqual(result.returncode, 1)
self.assertIn('download failed', result.stdout)
self.assertTrue((self.root / 'curl-calls').is_file())
self.assertFalse((self.runtime / 'droiddeck-steamvr/xr-request').exists())
if __name__ == '__main__':
unittest.main()