Repository navigation
Await native video recording start acknowledgment - #3311
TheCodeTraveler merged 6 commits into
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
Critical teardown races remain on both platforms, and async tests lack timeout and cancellation safeguards.
Get a fresh assessment by requesting another Copilot review.
Review details
Suppressed comments (1)
src/CommunityToolkit.Maui.UnitTests/Views/CameraView/VideoRecordingStateTests.cs:17
- This test (and the other async tests in the new class) awaits a TaskCompletionSource directly without a test timeout or TestContext cancellation. If a transition regresses and the task remains pending, the test runner can hang instead of reporting a failure; add a short Fact timeout and use WaitAsync(TestContext.Current.CancellationToken), as in CameraViewTests.cs:80-91.
await recordingState.Started;
- Files reviewed: 4/4 changed files
- Comments generated: 2
- Review effort level: Lite
There was a problem hiding this comment.
🟡 Changes recommended
The tests cannot compile without internals access, and both platform stop paths ignore cancellation during copying and flushing.
Get a fresh assessment by requesting another Copilot review.
Review details
Suppressed comments (2)
src/CommunityToolkit.Maui.Camera/CameraManager.android.cs:534
StopVideoRecordingdocuments that its token cancels the stop operation, and the previous implementation passed that token into both the copy and flush. UsingCancellationToken.Nonehere means cancellation after native finalization is ignored while a potentially large recording is copied, so the stop task cannot be canceled during this phase. Passtokenthrough to preserve the documented behavior.
await inputStream.CopyToAsync(recordingStream, CancellationToken.None);
await recordingStream.FlushAsync(CancellationToken.None);
src/CommunityToolkit.Maui.Camera/CameraManager.macios.cs:434
StopVideoRecordingdocuments that its token cancels the stop operation, and the previous implementation passed that token into both the copy and flush. UsingCancellationToken.Nonehere means cancellation after native finalization is ignored while a potentially large recording is copied, so the stop task cannot be canceled during this phase. Passtokenthrough to preserve the documented behavior.
await inputStream.CopyToAsync(recordingStream, CancellationToken.None);
await recordingStream.FlushAsync(CancellationToken.None);
- Files reviewed: 4/4 changed files
- Comments generated: 1
- Review effort level: Lite
There was a problem hiding this comment.
🟡 Changes recommended
Unresolved recording lifecycle issues allow premature stops during startup, prevent cancellation of destination writes, and leave recording state occupied after export failures.
5 open issues
VideoRecordingStateisinternalin the separate Camera assembly, but… Overlapping starts return success before recording is acknowledged · New Stop can race pending startup and fault unhandled callers · New Stop cancellation is not propagated to destination export · New Export failures leave finalized recording state occupied · New
Review effort: Max
|
Thanks @austinbhale! Could you please take a look at CoPilot's recommendations and either apply them or respond + resolve them if they're not relevant? |
|
@austinbhale Please allow maintainers to edit this PR. I need to be able to update it from main and address CoPilot's reviews.
|
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Hi @TheCodeTraveler - I responded to the current round of Copilot comments and requested another one. Due to an issue with GitHub, I can't enable "Allow edits from maintainers" because this PR comes from a fork owned by an organization. I'll keep the branch up to date on my end instead. Let me know if you'd like anything else changed! |
No worries - thanks! Keep iterating over these CoPilot comments, then once its review comes back clean, we can merge. |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
🔵 Needs a closer look
Human assessment is needed because recording-start races can report success without native acknowledgment, while unbounded test waits can hang the serialized test run.
No open issues 🎉
2 resolved since last review
Review effort: Max
TheCodeTraveler
left a comment
There was a problem hiding this comment.
Thanks @austinbhale!! Approved.
The unit test that failed in the CI pipeline is on Popup, unrelated to this PR.
Conflicts in CameraManager.android.cs and CameraManager.macios.cs, resolved so that both sides keep their behavior (details in merge-decisions.md of the evidence folder): - #3311's VideoRecordingState (Started/Finalized/StopSemaphore) replaces videoRecordingFinalizeTcs; StartVideoRecording returns once the native start is acknowledged, StopVideoRecording returns Stream.Null when the start failed. - A start that arrives while another start waits for its acknowledgement waits for it (#3311); a start after a started recording replaces it (this branch). - A cancelled or failed start ends the native recording, releases the state once and returns to the photo session only if the session switched (this branch's cancellation, with #3311's CancelVideoRecordingStart). - The export's finally cleans up first and then restores the photo session, so a failing restore cannot leave the recording state behind. - Dispose cancels the state's pending tasks; a stop that waits wakes up and returns Stream.Null. - Existing device tests follow the renamed private seam (videoRecordingState) and the awaited start (iOS stubs acknowledge the start). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… the release of the recording state Covers #3311 on Android: StartVideoRecording returns once CameraX acknowledged the start, a concurrent start waits for it and starts no second recording, StopVideoRecording after a failed start returns Stream.Null, a stop whose photo session can not be restored still releases the recording so that the next start records, and a start after a cancelled stop records into its stream. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…d recording The merge of main (01ea1a4) dropped #3311's token.ThrowIfCancellationRequested() before the export in StopVideoRecording on both platforms. Without it, a stop whose token is cancelled once the recording finalized discards the recording in the export's finally, and a retried StopVideoRecording returns Stream.Null; with it, the finalized recording stays for the retry, as #3311 intended. Also: an Android comment now names the real risk of leftover recording state (a second export into the stream), and a new line uses `is VideoRecordingState` instead of the empty property pattern. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>


Description of Change
StartVideoRecordingnow completes only after the native recording pipeline acknowledges that recording has started:AVCaptureFileOutputRecordingDelegate.DidStartRecording.VideoRecordEvent.Start.Both platforms use the same internal start/finalize state transitions. A native finish event that arrives before start faults the start task, repeated callbacks complete exactly once, and cancellation stops and finalizes the pending native recording before operation-specific resources are cleaned up.
This is separate from #3309, which only fixed the Apple recording delegate lifetime. This branch is based on that merged commit and does not duplicate its delegate-retention change.
Physical iOS testing showed why the additional acknowledgment is needed: the previous API could return before
DidStartRecording, allowing a rapid stop roughly 22 ms later and producing an empty recording. A private package build with native start acknowledgment improved repeated rapid Record/Stop testing.Linked Issues
PR Checklist
approved(bug) orChampioned(feature/proposal) — [BUG] Problems with Some CameraView StopVideoRecording on IOS #3152 was closed by Fix iOS video recording delegate lifetime #3309; this is the remaining start-semantics fixmainat time of PRAdditional information
Validation: