Fix error handling in realtime session export#149
Open
ruccho wants to merge 1 commit into
Open
Conversation
- await both video and audio mux tasks even if one fails, so the muxer is not disposed while the other task is still pushing data to it; propagate all failures via AggregateException when both tasks fail - move pipeline completion wait inside try block so the session state transitions to Invalid when waiting for recording completion fails Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
hkmt-mmy
reviewed
Jul 3, 2026
| var video = MuxVideoAsync().AsTask(); | ||
| var audio = MuxAudioAsync().AsTask(); | ||
|
|
||
| var whenAll = Task.WhenAll(video, audio); |
There was a problem hiding this comment.
212行目ではWhenAll内でAsTaskしているのに、こちらは外でAsTaskしているのには何か理由がある?
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.
Summary
RealtimeInstantReplaySessionhad two error-handling defects in its export path.1.
MuxSegmentAsync— disposes the muxer while the video task is still running on audio failureThe code awaits in the order
var video = MuxVideoAsync(); var audio = MuxAudioAsync(); await audio; await video;. Ifawait audiothrows, thevideoValueTask is left unobserved whileusing var muxeris disposed. The still-runningMuxVideoAsyncthen issuesPushVideoDataAsync/FinishVideoAsyncon the disposed native muxer (worst case a native crash), and the exception is left unobserved.2.
StopAndExportAsync— State left in a half-finished value on pipeline-completion failureThe
Task.WhenAll(...CompleteAsync...)was outside the try/catch that setsState = Invalid. If it throws, State stays atWaitForRecordingComplete, leaving the session in a half-finished state.Fix
MuxVideoAsync()/MuxAudioAsync()to Tasks via.AsTask()and awaitTask.WhenAll. Even if one fails, both complete before the muxer is disposed. If both fail, all exceptions propagate viaAggregateException; a single failure propagates the original exception type as before (backward compatible).State = Invalid.Out of scope: the broader concurrency guard between Dispose and export (a larger state-machine change) is not addressed here.
Verification
Unity Play Mode: ~183s record → export completed with zero errors (confirmed no regression on the normal export path). The error-path changes are covered by static review.
🤖 Generated with Claude Code