FEX code caches: capture, upload, download and a toggle

Merged
UT
14d ago
+1311-2

Description

FEX code caches for the app, in three parts.

Capture and upload. When a container's FEXCore pack ships FEXOfflineCompiler64.exe (gn-6 and later; detected from the installed pack, no version strings), the launch sets FEX_ENABLECODECACHINGWIP=1 so FEX writes a code map per process. After exit the maps go to POST /api/code-maps as deltas: each container keeps a ledger of blocks already sent, and a map with nothing new is dropped.

Download. A launch dependency hashes the game's executable, the DLLs beside it and the Steam client DLLs (once per file version), asks POST /api/code-caches/lookup by code identity (every PE section except .rsrc and .reloc, so stamped engine builds still match), and puts the returned caches into the prefix's fex-emu/cache/ under the file name FEX expects on this device. Gzip or, when the device holds the previous version, a zstd patch. Verified by size and sha256 through a temp file; a failure never blocks the launch.

Toggle. Settings > Emulation > "FEX code caches" (16 locales), on by default; off disables all of the above.

Nothing changes for containers on 2610-gn-5 or earlier. Server side: gamenative-cloudflare-workers #90, #91, #92 (merged, deployed).

Tested on a Retroid Pocket 6 (SD 8 Gen 2, FEX 2611-gn-6)

  • Capture and upload: Brotato, Borderlands 2, Celeste; second sessions upload only new blocks.
  • Download: two removed Brotato caches restored before launch, sha256-identical; Celeste (no cache of its own) received the Steam client caches compiled by the other two games.
  • Effect of a loaded cache: launch to menu 77.7 s vs 82.4 s (Brotato), 66.5 s vs 71.7 s (Borderlands 2); no change in capped gameplay.
  • Open: one Celeste intro stall with shared caches that did not reproduce on a repeat; the zstd patch path has not run on a device yet.

Debug builds target a real API with adb shell setprop debug.gamenative.api_base https://api.gamenative.app.

Recording

Loading screen shows "Checking FEX code cache" / "Downloading FEX code cache (n/m)"; logcat tags FexCodeMaps and FexCodeCache.

Type of Change

  • Bug fix
  • Performance / stability improvement
  • Compatibility improvements
  • Other (requires prior approval)

Checklist

  • If I have access to #code-changes, I have discussed this change there and it has been green-lighted. If I do not have access, I have still provided clear context in this PR. If I skip both, I accept that this change may face delays in review, may not be reviewed at all, or may be closed.
  • This change aligns with the current project scope (core functionality, stability, or performance). If not, it has been explicitly approved beforehand.
  • I have attached a recording of the change.
  • I have read and agree to the contribution guidelines in CONTRIBUTING.md.