Repository navigation
Kill a stopping screen recorder only once it stops making progress - #15122
omarchybot wants to merge 1 commit into
Conversation
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>
|
| 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" |
There was a problem hiding this comment.
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!
|
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 There is also an older open pull request for the same issue, #12559, which raises the flat deadline to 30 seconds with an Waiting on the maintainer to settle whether this is a bug fix or an enhancement. |
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_screenrecordingnow 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>/statmoving. 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'sSIGSTOPreproduction, 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.shstops a stand-in recorder that keeps writing for 10 seconds after SIGINT, and one that ignores SIGINT and does nothing. The first is killed onquattroand 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.