Skip to content

Kill a stopping screen recorder only once it stops making progress - #15122

Open
omarchybot wants to merge 1 commit into
quattrofrom
fix/issue-12469
Open

omarchybot wants to merge 1 commit into
quattrofrom
fix/issue-12469

Conversation

@omarchybot

Copy link
Copy Markdown
Collaborator

Fixes #12469

Stopping a screen recording sends the recorder SIGINT, which is when gpu-screen-recorder flushes its encoder and writes the rest of the mp4, and then sent SIGKILL after a flat 5 seconds. On a slow, throttled or loaded machine writing the recording out can take longer than that, so the recorder was killed mid-write, the "Recording process had to be force-killed" toast appeared, and the video was cut short, as the report shows with 85 seconds of footage lost.

stop_screenrecording now waits as long as the recorder is making progress: the recording file growing, or, when its pid was saved, its CPU time in /proc/<pid>/stat moving. A recorder that has done neither for 5 seconds has stalled and is killed exactly as before, so a hung recorder still takes 5 seconds to clear, and the reporter's SIGSTOP reproduction, which is a stalled recorder, is still killed. A recorder that keeps going after SIGINT is killed after about a minute, so a stop can never hang behind one that ignores it. Once the wait passes 5 seconds, a "Saving screen recording" notification says the recorder is still writing it out, since the bar indicator keeps showing the recording until the stop finishes.

Two things are the maintainer's to weigh. The one-minute ceiling and the notification are choices rather than the defect itself; both can go without undoing the fix. And progress is read from CPU time and file size, so a recorder blocked for 5 seconds on storage or the GPU with neither moving is still killed; that is far narrower than a flat deadline, not zero.

test/shell.d/screenrecording-stop-test.sh stops a stand-in recorder that keeps writing for 10 seconds after SIGINT, and one that ignores SIGINT and does nothing. The first is killed on quattro and finishes with this change; the second is killed with and without it.

Diagnosed and fixed by Claude Opus 5.5, with Codex at medium effort as a second opinion. Codex confirmed the 5 second deadline in the source and found a readiness race in the new test, fixed here; its last round found nothing open.

Stop sent SIGINT and then SIGKILL after a flat 5 seconds, so on a slow or loaded machine a recorder still writing out its recording was killed mid-write and the video truncated. Wait instead while the recording grows or the recorder uses CPU, kill one that has done neither for 5 seconds as before, and give up after about a minute. Past 5 seconds, say the recording is still being saved, so the longer wait does not read as a hang.

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

greptile-apps Bot commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 4/5

[Medium impact] Changes screen recording shutdown logic and adds test.

The PR appears safe to merge, with a non-blocking request to cover the remaining stop conditions in tests.

Findings

  1. P2 Two stop conditions remain untested ▶

Summary

Replaces the fixed screen-recorder stop deadline with checks for file growth and CPU work.

  • Screen recording stops wait for progress before killing the recorder.

Acknowledged choices:

  • omarchybot explicitly identifies the one-minute ceiling and saving notification as maintainer choices.
  • omarchybot explicitly acknowledges that five seconds blocked on storage or the GPU can still trigger a forced stop.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Send SIGINT] --> B{Recorder still running?}
  B -->|No| F[Finalize recording]
  B -->|Yes| C{Stalled for five seconds or total limit reached?}
  C -->|Yes| G[Force-kill and report error]
  C -->|No| D[Wait and read file size and CPU time]
  D --> E{Progress changed?}
  E -->|Yes| H[Reset stall count]
  E -->|No| I[Increase stall count]
  H --> B
  I --> B
Loading

Reviews (1) · Last reviewed commit: "Kill a stopping screen recorder only onc..." · Reviewed by Greptile

Comment on lines +70 to +79
stop_recording slow
! grep -Fxq KILL "$tmp/signals" || fail "a recorder still writing out its recording is not killed" "$(<"$tmp/signals")"
[[ -e $tmp/finished ]] || fail "a slow recorder finishes writing out its recording"
grep -Fq "Screen recording saved" "$tmp/notifications" || fail "a slow recorder's recording is announced as saved" "$(<"$tmp/notifications")"
pass "stop waits for a recorder that takes more than 5 seconds to write out its recording"

stop_recording stalled
grep -Fxq KILL "$tmp/signals" || fail "a recorder that has stalled is killed" "$(cat "$tmp/signals" 2>/dev/null)"
grep -Fq "force-killed" "$tmp/notifications" || fail "a killed recorder is announced as such" "$(<"$tmp/notifications")"
pass "stop kills a recorder that has stalled"

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 Two stop conditions remain untested

Both cases would still pass if CPU-time checks were removed: slow grows the file, and stalled does neither. Neither case reaches the one-minute limit while progress continues.

Add a recorder that uses CPU without growing the file and one that keeps making progress while ignoring SIGINT. Otherwise, these new stop conditions can break without failing the tests.

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!

@jandrusk

Copy link
Copy Markdown

Fixes #12469 — SIGKILL only after 5s of no progress (size + utime/stime), hard cap ~60s, with a “still writing” notification. Better than a flat grace bump (#12559). Ready for review.

@omarchybot

Copy link
Copy Markdown
Collaborator Author

The classification of this pull request is unsettled, so it has no class label yet and has not been taken further. Claude Opus 5.5 classified it as a bug fix: on quattro, stop_screenrecording in bin/omarchy-capture-screenrecording kills a recorder that is still writing out its file after a flat 5 seconds, which is the truncation #12469 reports. Codex at medium effort, asked the same question separately, classified it as an enhancement, which reads the change as altering stop behaviour on purpose — the progress-based wait, the one-minute ceiling and the new "Saving screen recording" notification — rather than fixing something broken. Nothing was run on a worker for this pass and no second review of the diff itself was done; that waits on the classification.

There is also an older open pull request for the same issue, #12559, which raises the flat deadline to 30 seconds with an OMARCHY_SCREENRECORD_STOP_TIMEOUT override. The two are competing fixes rather than duplicates, and which approach to take is the maintainer's call.

Waiting on the maintainer to settle whether this is a bug fix or an enhancement.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

screenrecording: 5s SIGINT grace before SIGKILL truncates recordings on slow or loaded systems

2 participants