mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-18 12:28:40 +00:00
feat: x86-64 client follows DroidDeck-Components' fex.json; fuller x86-64 session logs (#1053)
FEX builds can reach devices without an app release: while the x86-64 client is selected the app reads DroidDeck-Components' fex.json (directly, on its own thread, not in Offline Mode) and a session passes that build to droiddeck-steam-x64, which installs it only once its sha256 matches and its programs load, keeping the replaced files aside until the installed copy loads too; it keeps a working installed build otherwise and falls back to the build it pins. FEX is built and published by Components' build-fex.yml on its single fex release; this repository's build-fex.yml only checks the build. x86-64 session logs name the FEX build and its source, the rootfs and the client's builds, report the rootfs download in tenths, and say in one line when the web helper's GPU process keeps exiting, with x86 glxinfo and vulkaninfo through FEX. Settings shows the FEX build installed.
This commit is contained in:
1 parent
798386d02a
commit
292295ba30
12 files changed
+488
-58
No files matched your search
@@ -1906,6 +1906,9 @@ class MainActivity : ComponentActivity() {
|
||||
val scanGeneration = ++libraryScanGeneration
|
||||
val artRefreshesAtStart = HashMap(steamArtRefreshes)
|
||||
if (shortcutPicker) shortcutLibraryScanning = true
|
||||
if (SessionPrefs.steamClientArch(this) == "x86_64" && !OfflineMode.enabled(this)) {
|
||||
Thread({ com.droiddeck.launcher.session.FexCatalog.refresh(this) }, "fex-catalog").start()
|
||||
}
|
||||
Thread({
|
||||
val emus = Library.emulators(this) { id -> DesktopCatalog.installed(this, id) != null }
|
||||
ui.post { if (scanGeneration == libraryScanGeneration) emulatorList = emus }
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
package com.droiddeck.launcher.session
|
||||
|
||||
import android.content.Context
|
||||
import android.util.Log
|
||||
import com.droiddeck.launcher.core.DownloadSource
|
||||
import com.droiddeck.launcher.core.Downloader
|
||||
import org.json.JSONObject
|
||||
import java.io.File
|
||||
|
||||
/**
|
||||
* The FEX build DroidDeck-Components' fex.json names for the x86-64 client. A session uses the last copy read.
|
||||
* Components' build-fex.yml replaces the archive on its single `fex` release and records the build's version;
|
||||
* a release per build (fex-2610-r5) is still read.
|
||||
*/
|
||||
object FexCatalog {
|
||||
private const val TAG = "FexCatalog"
|
||||
const val CATALOG_URL = "https://raw.githubusercontent.com/Droid-Deck/DroidDeck-Components/main/fex.json"
|
||||
private const val RELEASES = "https://github.com/Droid-Deck/DroidDeck-Components/releases/download/"
|
||||
private const val REFRESH_MS = 10 * 60 * 1000L
|
||||
private val TAG_FORMAT = Regex("""fex-\d+-r\d+""")
|
||||
private val VERSION_FORMAT = Regex("""\d+-r\d+""")
|
||||
private val SHA256 = Regex("[0-9a-f]{64}")
|
||||
|
||||
data class Build(val tag: String, val url: String, val sha256: String)
|
||||
|
||||
@Volatile private var refreshedAt = 0L
|
||||
|
||||
private fun file(context: Context) = File(context.filesDir, "fex-catalog.json")
|
||||
|
||||
internal fun parse(text: String): Build? = runCatching {
|
||||
val o = JSONObject(text)
|
||||
val release = o.getString("release")
|
||||
val url = o.getString("url")
|
||||
val sha = o.getString("sha256").lowercase()
|
||||
val version = o.optString("version")
|
||||
val tag = when {
|
||||
TAG_FORMAT.matches(release) -> release
|
||||
release == "fex" && VERSION_FORMAT.matches(version) -> "fex-$version"
|
||||
else -> return@runCatching null
|
||||
}
|
||||
Build(tag, url, sha).takeIf { url == "$RELEASES$release/fex.tzst" && SHA256.matches(sha) }
|
||||
}.getOrNull()
|
||||
|
||||
fun cached(context: Context): Build? = runCatching { parse(file(context).readText()) }.getOrNull()
|
||||
|
||||
/** Reads fex.json straight from GitHub (a digest never comes from a mirror), at most every ten minutes. */
|
||||
@Synchronized
|
||||
fun refresh(context: Context, now: Long = System.currentTimeMillis()): Build? {
|
||||
if (now - refreshedAt < REFRESH_MS) return cached(context)
|
||||
refreshedAt = now
|
||||
val text = Downloader.downloadDirect(CATALOG_URL) ?: return cached(context)
|
||||
val build = parse(text) ?: run {
|
||||
Log.w(TAG, "fex.json not usable; keeping the last one")
|
||||
return cached(context)
|
||||
}
|
||||
runCatching {
|
||||
val f = file(context)
|
||||
val tmp = File(f.path + ".tmp")
|
||||
tmp.writeText(text)
|
||||
if (!tmp.renameTo(f)) tmp.delete()
|
||||
}
|
||||
return build
|
||||
}
|
||||
|
||||
/** For droiddeck-steam-x64: the build and every source its archive may come from (it checks the sha256). */
|
||||
fun environment(build: Build, sources: List<String> = DownloadSource.candidates(build.url)): List<String> = listOf(
|
||||
"BL_FEX_TAG=${build.tag}",
|
||||
"BL_FEX_SHA256=${build.sha256}",
|
||||
"BL_FEX_URLS=" + sources.joinToString(" "),
|
||||
)
|
||||
}
|
||||
@@ -590,6 +590,7 @@ class SessionService : Service() {
|
||||
SessionState.steamClientArch?.let { arch ->
|
||||
guest.add("BL_STEAM_CLIENT_ARCH=$arch")
|
||||
SessionPaths.current()?.let { SessionArtifacts.recordClient(it, arch) }
|
||||
if (arch == "x86_64") FexCatalog.cached(this)?.let { guest.addAll(FexCatalog.environment(it)) }
|
||||
}
|
||||
if (SessionState.mode == MODE_STEAM) {
|
||||
guest.add("BL_GAMESCOPE_STRETCH_16X9=" + (if (SessionPrefs.stretch16x9(this)) "1" else "0"))
|
||||
|
||||
@@ -152,13 +152,21 @@ class ModeSettingsActions(
|
||||
|
||||
/** "2610 r3" from droiddeck-steam-x64's FEX_TAG line (fex-2610-r3), the build the x86-64 client downloads. */
|
||||
internal fun fexVersionOf(script: String): String? =
|
||||
Regex("""(?m)^FEX_TAG=fex-(\d+)-r(\d+)\s*$""").find(script)?.let { "${it.groupValues[1]} r${it.groupValues[2]}" }
|
||||
Regex("""(?m)^FEX_TAG=(fex-\d+-r\d+)\s*$""").find(script)?.let { fexVersionOfTag(it.groupValues[1]) }
|
||||
|
||||
/** "2610 r5" from a tag such as fex-2610-r5. */
|
||||
internal fun fexVersionOfTag(tag: String): String? =
|
||||
Regex("""fex-(\d+)-r(\d+)""").matchEntire(tag.trim())?.let { "${it.groupValues[1]} r${it.groupValues[2]}" }
|
||||
|
||||
/** The build installed in the runtime, else the one fex.json names, else the one the launcher pins. */
|
||||
@Composable
|
||||
private fun x64FexVersion(context: android.content.Context): String? = remember {
|
||||
runCatching {
|
||||
context.assets.open("linuxfs/usr/local/bin/droiddeck-steam-x64").bufferedReader().use { fexVersionOf(it.readText()) }
|
||||
}.getOrNull()
|
||||
val root = com.droiddeck.launcher.runtime.LinuxRuntime.rootDir(context)
|
||||
runCatching { java.io.File(root, "usr/local/share/fex-emu/.droiddeck-tag").readText() }.getOrNull()?.let(::fexVersionOfTag)
|
||||
?: com.droiddeck.launcher.session.FexCatalog.cached(context)?.tag?.let(::fexVersionOfTag)
|
||||
?: runCatching {
|
||||
context.assets.open("linuxfs/usr/local/bin/droiddeck-steam-x64").bufferedReader().use { fexVersionOf(it.readText()) }
|
||||
}.getOrNull()
|
||||
}
|
||||
|
||||
@Composable
|
||||
|
||||
Reference in new issue
Block a user