fix(recording): fail cleanly on WGC resize errors

This commit is contained in:
wiiiii123
2026-05-09 07:49:54 +07:00
parent f3fcd4bfda
commit fe294b71d5
4 changed files with 18 additions and 5 deletions
@@ -5,10 +5,10 @@
"helpers": {
"wgc-capture": {
"binaryName": "wgc-capture.exe",
"binarySha256": "ee24c7ce2fcd86eb513663416ad0aca673ac2a9b90b73532bc457e021b7b78a6",
"binarySha256": "4f8873abbff58add37672114184c154dee838939ee8f2b7df45d658d078af28c",
"sourceDir": "electron/native/wgc-capture",
"sourceFingerprint": "c5a28a1999758f5b98dc79c247507eacb672a188d81d19aedc2dd656ee92a737",
"updatedAt": "2026-05-08T16:48:17.850Z"
"sourceFingerprint": "6f725fad6eb515d81b2d553ec45ddbf7c681d2725bba48f0c0722ce00166d967",
"updatedAt": "2026-05-09T00:49:28.306Z"
},
"cursor-monitor": {
"binaryName": "cursor-monitor.exe",
Binary file not shown.
+12
View File
@@ -420,6 +420,18 @@ int main(int argc, char* argv[]) {
std::cerr << "ERROR: WGC capture session failed during recording" << std::endl;
encoder.finalize();
DeleteFileW(outputPathW.c_str());
if (!config.audioOutputPath.empty()) {
const std::wstring audioPathW = utf8ToWide(config.audioOutputPath);
const std::wstring audioMetadataPathW = utf8ToWide(config.audioOutputPath + ".json");
DeleteFileW(audioPathW.c_str());
DeleteFileW(audioMetadataPathW.c_str());
}
if (!config.micOutputPath.empty()) {
const std::wstring micPathW = utf8ToWide(config.micOutputPath);
const std::wstring micMetadataPathW = utf8ToWide(config.micOutputPath + ".json");
DeleteFileW(micPathW.c_str());
DeleteFileW(micMetadataPathW.c_str());
}
return 1;
}
@@ -136,7 +136,7 @@ bool WgcSession::initializeWithItem(int fps) {
// IsBorderRequired is only available on Windows 11+ (build 22000). propagating an hresult_error results in Native Windows capture failure
try {
session_.IsBorderRequired(false);
} catch (winrt::hresult_error const& e) {
} catch (winrt::hresult_error const&) {
}
return true;
@@ -169,6 +169,7 @@ bool WgcSession::recreateFramePoolIfNeeded(
<< framePoolWidth_ << "x" << framePoolHeight_ << std::endl;
} catch (winrt::hresult_error const& e) {
fatalError_ = true;
capturing_ = false;
std::cerr << "ERROR: Failed to recreate WGC frame pool after resize: 0x"
<< std::hex << e.code() << std::dec << std::endl;
}
@@ -248,7 +249,7 @@ void WgcSession::onFrameArrived(
winrt::Windows::Graphics::Capture::Direct3D11CaptureFramePool const& sender,
winrt::Windows::Foundation::IInspectable const&) {
if (!capturing_) return;
if (!capturing_ || fatalError_) return;
auto frame = sender.TryGetNextFrame();
if (!frame) return;