🐛 Fix recording stopping when user triggers UAC elevation#91
Merged
Conversation
* ✨ Enhance iKAT recording script with user validation and restart logic; update test paths * ✨ Update Remove-ExpiredRecordings.Tests.ps1 to test .ts file deletion instead of .mkv
…ns with exit code lesson
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Fixes a bug where the iKAT session recording would permanently stop whenever the recorded user (
dpuerner) launched a process as administrator (triggering a UAC elevation prompt). Also adds logarithmic backoff to the restart loop so rapid UAC transitions recover in ~1 second while genuinely broken FFmpeg processes back off gradually.Changes:
Invoke-iKATRecording.ps1— Wraps the FFmpeg launch in a restart loop. When FFmpeg exits mid-session (e.g., due to a UAC secure desktop transition), the script detects the session is still active via anexplorer.exepresence check and starts a new recording segment automatically. Each segment shares a session timestamp and gets an incrementing part number (_part1.ts,_part2.ts, …).0(clean) — not a crash code — when the UAC secure desktop dismisses its handle. The original non-zero exit-code check incorrectly treated UAC exits as graceful logoffs. Fixed by checking forexplorer.exeinstead: if Explorer is still running, the session is active and FFmpeg is restarted regardless of exit code.Round(Ln(restartCount - 9) * 5)seconds (~3s at restart 11, ~20s at restart 60). Max restart count raised from 5 → 60, rolling window from 10 → 60 minutes.Tests/iKAT/— Renamed test folder fromiCat→iKATto match the script directory casing..github/copilot-instructions.md— Added iKAT recording project conventions section documenting critical constraints (MPEG-TS format, zerolatency, flush_packets, RunLevel Limited, restart loop, explorer.exe session detection) so future changes don't accidentally revert hard-won fixes.Why are we doing this?
When Windows shows a UAC elevation prompt, it switches from the user's normal desktop (
Winsta0\Default) to an isolated secure desktop (Winsta0\Winlogon). Thegdigrab -i desktophandle becomes invalid during this switch, causing FFmpeg to exit with code0(a clean exit — not a crash). Without the restart loop the recording ended at that point, potentially losing all footage of whatever happens after the elevation prompt — exactly what we're trying to diagnose.The logarithmic backoff ensures UAC-triggered restarts (which happen multiple times per session) resume recording with no noticeable gap, while a genuinely crashing FFmpeg process doesn't hammer the CPU in a tight loop.
Closes #88
How should this be tested?
KFWS6IKAT01.kikkoman.comasKFI\admin-jmaffiola_part1.tsfile appears inC:\Recordingsand is growing_part2.tsfile appears inC:\Recordingsand starts growing.tsfile is fully playable in VLC with no truncationC:\Recordings\debug.logfor"FFmpeg exited with code","Explorer still running", and"Launching ffmpeg"entries showing the restartPester tests: All 6 tests pass:
Any deployment notes?
Pull the fix on the server:
No Task Scheduler changes required — the tasks (
iKAT-Record-Dina,iKAT-Record-Joey-Test) do not need to be re-registered. All fixes are within the PowerShell script itself.Closes #88