Record your screen, ship a demo. Free and open-source, GPU-accelerated, no watermarks, no subscriptions. Windows, macOS, Linux. Actively maintained.
TypeScript cross-platformelectronffmpegopen-sourceproduct-demorustscreen-capturescreen-recorderscreen-recordingscreen-studioscreencastspeech-to-texttypescriptvideo-editingvideo-editorwaylandwgpuwhisper
fix(wgc): stop the adapter report dereferencing what DXGI did not give it
Etienne Lescote032894e651e
diff --git a/electron/native/wgc-capture/src/main.cpp b/electron/native/wgc-capture/src/main.cppindex 3dc698cab..5f9638941 100644--- a/electron/native/wgc-capture/src/main.cpp+++ b/electron/native/wgc-capture/src/main.cpp@@ -239,14 +239,22 @@ void reportCaptureAdapters(ID3D11Device* device, HMONITOR targetMonitor) {std::wstring monitorAdapterName;bool monitorAdapterFound = false;bool sameAdapter = false;+ // Both loops end on FAILED(), not on DXGI_ERROR_NOT_FOUND specifically.+ // NOT_FOUND is itself a failure code, so one test covers the normal end of+ // the enumeration and every other way it can stop -- and the other ways are+ // what matter here. EnumOutputs returns DXGI_ERROR_NOT_CURRENTLY_AVAILABLE+ // to a process in session 0, and neither call fills its out-pointer when it+ // fails. Testing only for NOT_FOUND left a null ComPtr to be dereferenced on+ // the next line, which would take down a recording from inside the one+ // function in this file that promises never to.for (UINT adapterIndex = 0;; ++adapterIndex) {Microsoft::WRL::ComPtr<IDXGIAdapter1> adapter;- if (factory->EnumAdapters1(adapterIndex, &adapter) == DXGI_ERROR_NOT_FOUND) {+ if (FAILED(factory->EnumAdapters1(adapterIndex, &adapter)) || !adapter) {break;}for (UINT outputIndex = 0;; ++outputIndex) {Microsoft::WRL::ComPtr<IDXGIOutput> output;- if (adapter->EnumOutputs(outputIndex, &output) == DXGI_ERROR_NOT_FOUND) {+ if (FAILED(adapter->EnumOutputs(outputIndex, &output)) || !output) {break;}DXGI_OUTPUT_DESC outputDesc{};diff --git a/scripts/diagnostic-tool/README.md b/scripts/diagnostic-tool/README.mdindex 732e5134c..a817ca20e 100644--- a/scripts/diagnostic-tool/README.md+++ b/scripts/diagnostic-tool/README.md@@ -35,7 +35,8 @@ Flags:The audio flags matter for reproducing a stop hang. Audio and video writes takethe same sink-writer lock, so a run without audio has nothing to contend withand can pass on a machine where the app hangs every time. If you are reporting a-hang that happens in the app but not here, re-run with `--system-audio`.+hang that happens in the app but not here, re-run with whichever sources the+failing recording used: `--system-audio`, `--mic`, or both together.Or use the bundled launcher:- Windows: `diagnostic.bat`diff --git a/scripts/diagnostic-tool/diagnostic.mjs b/scripts/diagnostic-tool/diagnostic.mjsindex eb521b176..373c8f4b2 100644--- a/scripts/diagnostic-tool/diagnostic.mjs+++ b/scripts/diagnostic-tool/diagnostic.mjs@@ -101,7 +101,8 @@ Flags:The audio flags are off by default, which is why a plain run cannot reproduce ahang that only happens with audio: an audio write and a video write contend forthe same sink-writer lock, and with no audio there is nothing to contend with.-If a recording hangs in the app but not here, re-run with --system-audio.+If a recording hangs in the app but not here, re-run with whichever sources the+failing recording used -- --system-audio, --mic, or both.`);}