Browse Source

fix: Ensure DirectX capturer is supported (#13993)

* Merge PR #13543 from electron/ajm-win7-crash

Ensure DirectX capturer is supported.

* chore: remove unnecessary whitespace change

* refactor: update desktop capturer backport to old content namespace
Charles Kerr 6 years ago
parent
commit
9694cdc307

+ 8 - 1
atom/browser/api/atom_api_desktop_capturer.cc

@@ -19,6 +19,7 @@ using base::PlatformThreadRef;
 #include "third_party/webrtc/modules/desktop_capture/desktop_capturer.h"
 #if defined(OS_WIN)
 #include "third_party/webrtc/modules/desktop_capture/win/dxgi_duplicator_controller.h"
+#include "third_party/webrtc/modules/desktop_capture/win/screen_capturer_win_directx.h"
 #include "ui/display/win/display_info.h"
 #endif  // defined(OS_WIN)
 
@@ -62,7 +63,13 @@ void DesktopCapturer::StartHandling(bool capture_window,
   webrtc::DesktopCaptureOptions options =
     content::CreateDesktopCaptureOptions();
 #if defined(OS_WIN)
-  using_directx_capturer_ = options.allow_directx_capturer();
+  if (options.allow_directx_capturer()) {
+    // DxgiDuplicatorController should be alive in this scope according to
+    // screen_capturer_win.cc.
+    auto duplicator = webrtc::DxgiDuplicatorController::Instance();
+    using_directx_capturer_ =
+        webrtc::ScreenCapturerWinDirectx::IsSupported();
+  }
 #endif  // defined(OS_WIN)
 
   std::unique_ptr<webrtc::DesktopCapturer> screen_capturer(

+ 1 - 1
atom/browser/api/atom_api_desktop_capturer.h

@@ -49,7 +49,7 @@ class DesktopCapturer: public mate::EventEmitter<DesktopCapturer>,
  private:
   std::unique_ptr<DesktopMediaList> media_list_;
 #if defined(OS_WIN)
-  bool using_directx_capturer_;
+  bool using_directx_capturer_ = false;
 #endif  // defined(OS_WIN)
 
   DISALLOW_COPY_AND_ASSIGN(DesktopCapturer);