[Bug]: Android Device panel video stutters on Windows: hub launches emulators with -gpu auto, which resolves to SwiftShader
Area
apps/server
Steps to reproduce
- On a Windows host with a discrete GPU, enable the Device panel and open any Android emulator.
- Watch the streamed video: it stutters.
- Inspect the guest:
adb shell getprop ro.hardware.eglreportsemulationand SurfaceFlinger reports GLES rendererSwiftShader. The running qemu command line shows-no-audio -no-window -no-metrics -gpu auto -no-boot-anim -port <p> -camera-back/-front imagefile:....
Expected behavior
The emulator renders on the host GPU (-gpu host -> guest GLES renderer Android Emulator OpenGL ES Translator (NVIDIA GeForce RTX 3070/PCIe/SSE2) on the same machine) and the Device panel video is smooth.
Actual behavior
expo-device-hub's buildEmulatorArgs (@expo/hub-android-utils, bundled in dist/server/index.mjs) hardcodes -gpu auto for its headless launches. Under -no-window on Windows, auto resolves to SwiftShader software GL, so guest rendering - and everything the panel streams - is CPU-bound and stuttery. Verified live: relaunching the same AVD with -gpu host moves the guest onto the host GPU and is smooth.
Notably, the vendored serve-emu CLI already treats host as the right default: its --gpu option defaults to host with help text saying the AVD's auto "often falls back to a software compositor that stutters" (and recommends swiftshader_indirect only on headless hosts). The hub's own launch path just never exposes that choice.
Impact
Major degradation for every Windows user of the Android Device panel - all sessions render in software. Silent failure mode: no error, just a choppy panel, so users have no signal pointing at the cause.
Version or commit
main @ f0d76fcbb2; expo-device-hub pinned at 0.26.1 (apps/server/src/device/deviceToolVersions.json)
Environment
Windows, NVIDIA GeForce RTX 3070, Android SDK emulator (API 36 AVDs)
Workaround
EXPO_DEVICE_HUB_EMULATOR_EXTRA_ARGS="-gpu host" in the server environment - the env var is appended after the hardcoded args in buildEmulatorArgs, so the later -gpu wins. Both hub spawn paths already forward it (LocalDeviceHost.hubEnvironment, sshDeviceScript).
Investigation notes
The repo-side fix seam already exists and is used for camera overrides:
apps/server/src/device/LocalDeviceHost.tshubEnvironmentcomputes emulator-arg overrides (-camera-front/back emulatedwhen the SDK lacksimagefile) and injects them as[overrides, user EXPO_DEVICE_HUB_EMULATOR_EXTRA_ARGS]- the user's own env value lands last and still wins.apps/server/src/device/sshDeviceScript.tsdoes the same for SSH device hosts.- Both sides record
emulatorExtraArgson the running hub and respawn it when the computed value changes, so a new override costs exactly one hub restart after upgrade.
A minimal fix would add -gpu host to those computed overrides, gated by GPU presence since -gpu host fails on GPU-less hosts: always on win32/darwin, on linux only when a GPU exists (e.g. /dev/dri present). Related precedent for why the gate matters: #34470, where a user-forced -gpu host on a headless Linux/Xorg + passed-through iGPU setup SIGSEGV'd during quick-boot snapshot load.
Two upstream bugs in expo/expo-device-hub surfaced during the same session, reported here so they can be filed/tracked appropriately:
buildEmulatorArgshardcodes-gpu auto; the hub should default tohoston GPU-equipped hosts (or honor a gpu config) to match its own vendored serve-emu default.vendor/serve-emuprepareDeviceServerJarprobestest -fon the device-sidescrcpy-serverjar. An interruptedadb pushleaves a 0-byte file that passes-f, so every later session start fails withscrcpy process exited during startup (code=134)in a 5 s cooldown loop until the device file is removed by hand.test -s(or comparing size against the local jar) would self-heal.
I tried to reproduce this on the current build and could not.
Commit c89ca0a2f2 (origin/main). The live stutter needs a Windows or macOS host with a real GPU, and no worker has one (the Windows pool is GPU-less Windows Server VMs). It was not reproduced live. Confirmed by inspection and a test: (1) npm pack [email protected] (the version pinned in apps/server/src/device/deviceToolVersions.json). dist/server/index.mjs buildEmulatorArgs returns -avd <name> -no-audio -no-window -no-metrics -gpu auto -no-boot-anim -port <p> ...extraArgs ...EXPO_DEVICE_HUB_EMULATOR_EXTRA_ARGS. vendor/serve-emu/dist/cli.js says the AVD's auto 'often falls back to a software compositor'. (2) On main, LocalDeviceHost.hubEnvironment and sshDeviceScript add only -camera-* emulated overrides and never a -gpu flag. (3) Added a test to apps/server/src/device/LocalDeviceHost.test.ts that runs hubEnvironment on win32 and darwin with an imagefile-capable emulator and expects EXPO_DEVICE_HUB_EMULATOR_EXTRA_ARGS to be -gpu host. vp test run src/device/LocalDeviceHost.test.ts: both new cases fail (received undefined), the other 26 pass. Third-party measurements on open PR #39929: Windows 11 RTX 4070 and macOS M5 Pro both land on SwiftShader with -gpu auto (macOS 45-51% janky frames). -gpu host moves rendering to the GPU.
Closing as not planned. If it still happens for you, reply with the exact steps and the version you are on and it will be looked at again.