Bugs

Galaxy XR: every 2D↔3D switch leaks ~650 MB of DMA-BUF memory until Android's low-memory killer kills VD

28d agoPending

Setup

Headset: Samsung Galaxy XR (SM-I610), Android XR (Android 14), build I610UEU2AZF3
Virtual Desktop on the headset: 1.34.25.0 (versionCode 10722)
Streamer on the PC: codec H.264 (the headset logs c2.qti.avc.decoder.low_latency)
Disclosure: my headset is rooted. Root is only how I could measure this (dmabuf_dump). A small tool of mine on the headset reads the tracking cameras, and its DMA-BUF usage stayed constant at 52 MB the whole time.

What happens For a while I thought VD was crashing randomly in longer sessions. It isn't a crash: there's no tombstone and no crash report. Android's low-memory killer (lmkd) kills VD because the device runs out of memory. Before that, lmkd had already killed about 150 other processes, so VD went last, at oom_adj 0 (foreground).

The memory that fills up is DMA-BUF (graphics/video buffers). It grows every time I switch VD between 2D and 3D, and it never comes back.

Steps to reproduce

Connect to the PC and stream.
Switch between 2D and 3D in VD, back and forth, about every 10 s.
Watch VD's DMA-BUF total (dmabuf_dump as root, the per-process "PROCESS TOTAL").

Measurement (VD's own DMA-BUF total in MB, from my second test run; the compositor's total in brackets)

Switch3D2D
15831 (2781)5364 (1724)
26483 (2781)6018 (1724)
37133 (2781)6671 (1724)
47775 (2781)7325 (1724)

Each 2D→3D→2D round trip leaves ~650 MB behind in VD's process, the same every time.
The compositor releases its share each time (2781 → 1724 MB). VD doesn't release its own.
While I don't switch, the numbers stay flat, both while streaming and while idle. So it's the switch, not streaming time.
Each switch re-creates the video decoders, and the jumps match those times to the second: in 2D one decoder at 3840×2160, in 3D four instances (logged sizes 1536×1408 and 1152×1088). It looks like the old decoders' output buffers are never freed.

The two kills

Normal session: DMA-BUF total went from 1.5 GB after boot to 9.4 GB. VD was killed at 23:27:34 after about 95 minutes.
Deliberate test (4 round trips at ~10 s, after earlier switches in the same session): VD went from 1.4 GB right after its restart to 7.3 GB. The total reached 10.5 GB and VD was killed again at 23:41:39 (killinfo kill reason 2, adj 0). Swap was mostly used up as well.

The device has 16 GB, so with a few switches per session, VD ends up being killed.

Expected When the decoders are re-created, the old buffers are released, and VD's DMA-BUF usage stays about the same across switches.

Workaround Don't switch in a session, or restart VD after a few switches. Restarting frees everything.

I can provide the full logcat, dmabuf_dump output and the per-second samples if they help.

1 comment

  1. Jens Zier27d ago

    Since the layout got a bit scrambled when pasting, here is the table with the memory usage formatted with spaces:

    Switch 3D 2D
    1 5831 (2781) 5364 (1724)
    2 6483 (2781) 6018 (1724)
    3 7133 (2781) 6671 (1724)
    4 7775 (2781) 7325 (1724)

    Another user on discord mentioned he has experienced the same issue at least once. I understand that people normally do not switch that much during a session, but I also have the issue where one display suddenly hangs and only displays a static image - switching to 2d and back is the known workaround...