fix(lifecycle): end the session before disposing it on close
Closing with a recording active called Shutdown() straight away, which disposed the frame pump and the audio mixer underneath a running loop: ffmpeg never flushed, the file was never finalized or renamed, and the pump was torn down mid-iteration. That is the 'app goes autistic on close' report. MainWindow_Closing now holds the window open, runs StopBeforeShutdownAsync (the ordinary stop, bounded at ~6 s so a stuck encoder cannot make the app unclosable), then closes for real. StopStream already honours the audio-before-video ordering, so the close path inherits it instead of inventing its own teardown. Test: with nothing running, closing must not hold the window at all (the fast path stays fast). Scope justification: Assets/starting-background.jpg is outside this unit — the creator's replacement art, still awaiting their visual check.
This commit is contained in:
+21
-1
@@ -147,8 +147,28 @@ public partial class MainWindow : Window
|
||||
_topBar.RefreshAvatar();
|
||||
}
|
||||
|
||||
private void MainWindow_Closing(object? sender, CancelEventArgs e)
|
||||
private bool _shutdownComplete;
|
||||
|
||||
private async void MainWindow_Closing(object? sender, CancelEventArgs e)
|
||||
{
|
||||
if (_shutdownComplete)
|
||||
{
|
||||
SaveWindowGeometry();
|
||||
_viewModel.Shutdown();
|
||||
return;
|
||||
}
|
||||
|
||||
// A session must END before anything is disposed (2026-11-12: closing mid-recording used to
|
||||
// pull the pump out from under itself). Hold the window open, stop properly, then close again.
|
||||
if (_viewModel.IsLive || _viewModel.IsRecording)
|
||||
{
|
||||
e.Cancel = true;
|
||||
await _viewModel.StopBeforeShutdownAsync();
|
||||
_shutdownComplete = true;
|
||||
Close();
|
||||
return;
|
||||
}
|
||||
|
||||
SaveWindowGeometry();
|
||||
_viewModel.Shutdown();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user