feat: the PowerVR runtime is a downloaded add-on pack, not bundled in the APK (#2157)

* feat: the PowerVR runtime is a downloaded add-on pack, not bundled in the APK

* fix: a stopped session cancels the PowerVR pack download

* fix: a session stopped during runtime unpacking ends before staging

* fix: a failed PowerVR pack download ends the session with a message
This commit is contained in:
Kurt Himebauch authored and GitHub committed 2026-11-05 22:58:10 -05:00
1 parent 3733c50902
commit 4cbd7722f8
43 files changed
+77 -13

No files matched your search

@@ -149,5 +149,8 @@ internal class AddonPack(
listOf("version", "comet"))
val BUTLER = AddonPack("butler", BuildConfig.PACK_BUTLER_SHA256, BuildConfig.PACK_BUTLER_SIZE,
listOf("version", "butler", "7z.so", "libc7zip.so"))
@JvmField
val POWERVR = AddonPack("powervr", BuildConfig.PACK_POWERVR_SHA256, BuildConfig.PACK_POWERVR_SIZE,
listOf("runtime.tzst", "version.txt"))
}
}
@@ -5,9 +5,11 @@ import android.os.Build;
import android.system.ErrnoException;
import android.system.Os;
import android.system.OsConstants;
import com.droiddeck.launcher.core.AddonPack;
import com.droiddeck.launcher.core.FileUtils;
import com.droiddeck.launcher.core.TarZst;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
@@ -21,7 +23,6 @@ import org.json.JSONObject;
/** Isolated glibc-to-Android Vulkan bridge. It does not replace the rootfs's Mesa libraries. */
public final class SystemVulkanDriver {
private static final String ASSET = "hybris/runtime.tzst";
/** Vendor HALs the bridge loads. Samsung Xclipse (Exynos, sgpu) is experimental. */
private static final String[] HALS = {
"/vendor/lib64/hw/vulkan.powervr.so",
@@ -144,13 +145,17 @@ public final class SystemVulkanDriver {
if (!isPowerVr()) throw new IOException("System PowerVR Vulkan driver is unavailable");
if (!renderNodeAvailable()) throw new IOException(
"System PowerVR requires an identifiable, readable and writable DRM render node");
if (!AddonPack.POWERVR.await(context)) throw new IOException(
"Couldn't download the PowerVR graphics runtime. Check your connection and try again.");
File target = runtimeDirectory(context);
File base = target.getParentFile();
if (complete(target)) return target;
if (!base.isDirectory() && !base.mkdirs()) throw new IOException("Cannot create system Vulkan directory");
File staged = new File(base, ".stage-" + UUID.randomUUID());
try {
if (!TarZst.extractAsset(context, ASSET, staged)) throw new IOException("Cannot unpack system Vulkan runtime");
try (FileInputStream archive = new FileInputStream(AddonPack.POWERVR.file(context, "runtime.tzst"))) {
if (!TarZst.extract(archive, staged)) throw new IOException("Cannot unpack system Vulkan runtime");
}
for (String name : REQUIRED)
if (!present(staged, name)) throw new IOException("Missing system Vulkan component: " + name);
if (!new File(staged, "run-proton.py").canExecute())
@@ -175,8 +180,9 @@ public final class SystemVulkanDriver {
/** The current APK's versioned runtime path, without extracting or modifying it. */
public static File runtimeDirectory(Context context) throws IOException {
String version;
if (!AddonPack.POWERVR.installed(context)) throw new IOException("PowerVR graphics runtime is not installed");
try (BufferedReader input = new BufferedReader(new InputStreamReader(
context.getAssets().open("hybris/version.txt"), StandardCharsets.US_ASCII))) {
new FileInputStream(AddonPack.POWERVR.file(context, "version.txt")), StandardCharsets.US_ASCII))) {
version = input.readLine();
}
if (version == null || !version.matches("[0-9a-f]{64}")) throw new IOException("Invalid system Vulkan runtime version");
@@ -476,10 +476,19 @@ class SessionService : Service() {
val stillStarting = { gen == sessionGen && SessionState.running }
val prootPack = LinuxRuntime.patchedProot(this) || AddonPack.PROOT.await(this, stillStarting)
val directAudioPack = AddonPack.DIRECTAUDIO.await(this, stillStarting)
val systemVulkan = SystemVulkanDriver.usesDefault(SessionPrefs.linuxDriver(this))
val powerVrPack = !systemVulkan || (stillStarting() && AddonPack.POWERVR.await(this, stillStarting))
if (!stillStarting()) {
Log.i(TAG, "session stopped while add-on packs were downloading")
return
}
if (!powerVrPack) {
val message = getString(R.string.session_powervr_missing)
Log.e(TAG, "powervr pack unavailable; the system graphics runtime cannot be prepared")
failSession(gen, "POWERVR_MISSING", message, -1)
stopSession(-1, gen)
return
}
if (!directAudioPack) {
Log.w(TAG, "directaudio pack unavailable; game audio drivers will not be staged")
mainHandler.post {
@@ -501,8 +510,12 @@ class SessionService : Service() {
.onFailure { Log.w(TAG, "agent environment skipped", it) }
.getOrDefault(emptyList())
try {
if (SystemVulkanDriver.usesDefault(SessionPrefs.linuxDriver(this))) {
if (systemVulkan) {
SystemVulkanDriver.prepare(this)
if (!stillStarting()) {
Log.i(TAG, "session stopped while the system graphics runtime was unpacking")
return
}
pruneSystemVulkanRuntime()
}
SessionFiles.stage(this, root, startsSession = true)