Bug 1562847 - for beta - Disable double buffering with compositor when device reset happens r=nical, bas a=RyanVM
authorsotaro <sotaro.ikeda.g@gmail.com>
Fri, 26 Jul 2019 22:40:08 +0300
changeset 544755 f4ff6dfe4a354e7314be414f09b3c72388b5946e
parent 544754 4d7e8d12749d7b99a7f2bd613193fa93b4eace49
child 544756 2e5cb51c62af4511c247739494c67028f76b3dc2
push id2131
push userffxbld-merge
push dateMon, 26 Aug 2019 18:30:20 +0000
treeherdermozilla-release@b19ffb3ca153 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnical, bas, RyanVM
bugs1562847
milestone69.0
Bug 1562847 - for beta - Disable double buffering with compositor when device reset happens r=nical, bas a=RyanVM
gfx/config/gfxVars.h
gfx/ipc/GPUParent.cpp
gfx/ipc/GPUProcessManager.cpp
gfx/layers/d3d11/CompositorD3D11.cpp
gfx/layers/d3d11/MLGDeviceD3D11.cpp
gfx/layers/ipc/CompositorBridgeParent.cpp
gfx/thebes/gfxPlatform.cpp
--- a/gfx/config/gfxVars.h
+++ b/gfx/config/gfxVars.h
@@ -46,17 +46,18 @@ class gfxVarReceiver;
   _(WebRenderDebugFlags, int32_t, 0)                               \
   _(ScreenDepth, int32_t, 0)                                       \
   _(GREDirectory, nsString, nsString())                            \
   _(ProfDirectory, nsString, nsString())                           \
   _(UseOMTP, bool, false)                                          \
   _(AllowD3D11KeyedMutex, bool, false)                             \
   _(SystemTextQuality, int32_t, 5 /* CLEARTYPE_QUALITY */)         \
   _(LayersWindowRecordingPath, nsCString, nsCString())             \
-  _(RemoteCanvasEnabled, bool, false)
+  _(RemoteCanvasEnabled, bool, false)                              \
+  _(UseDoubleBufferingWithCompositor, bool, false)
 
 /* Add new entries above this line. */
 
 // Some graphics settings are computed on the UI process and must be
 // communicated to content and GPU processes. gfxVars helps facilitate
 // this. Its function is similar to StaticPrefs, except rather than hold
 // user preferences, it holds dynamically computed values.
 //
--- a/gfx/ipc/GPUParent.cpp
+++ b/gfx/ipc/GPUParent.cpp
@@ -259,18 +259,17 @@ mozilla::ipc::IPCResult GPUParent::RecvI
 
   // Make sure to do this *after* we update gfxVars above.
   if (gfxVars::UseWebRender()) {
     wr::RenderThread::Start();
     image::ImageMemoryReporter::InitForWebRender();
   }
 #ifdef XP_WIN
   else {
-    if (StaticPrefs::gfx_direct3d11_use_double_buffering() &&
-        IsWin10OrLater()) {
+    if (gfxVars::UseDoubleBufferingWithCompositor()) {
       // This is needed to avoid freezing the window on a device crash on double
       // buffering, see bug 1549674.
       widget::WinCompositorWindowThread::Start();
     }
   }
 #endif
 
   VRManager::ManagerInit();
--- a/gfx/ipc/GPUProcessManager.cpp
+++ b/gfx/ipc/GPUProcessManager.cpp
@@ -480,16 +480,21 @@ void GPUProcessManager::OnInProcessDevic
   NotifyListenersOnCompositeDeviceReset();
 }
 
 void GPUProcessManager::OnRemoteProcessDeviceReset(GPUProcessHost* aHost) {
   // Detect whether the device is resetting too quickly or too much
   // indicating that we should give up and use software
   mDeviceResetCount++;
 
+  // Disable double buffering when device reset happens.
+  if (!gfxVars::UseWebRender() && gfxVars::UseDoubleBufferingWithCompositor()) {
+    gfxVars::SetUseDoubleBufferingWithCompositor(false);
+  }
+
   auto newTime = TimeStamp::Now();
   auto delta = (int32_t)(newTime - mDeviceResetLastTime).ToMilliseconds();
   mDeviceResetLastTime = newTime;
 
   if (ShouldLimitDeviceResets(mDeviceResetCount, delta)) {
     DestroyProcess();
     DisableGPUProcess("GPU processed experienced too many device resets");
     HandleProcessLost();
--- a/gfx/layers/d3d11/CompositorD3D11.cpp
+++ b/gfx/layers/d3d11/CompositorD3D11.cpp
@@ -196,18 +196,18 @@ bool CompositorD3D11::Initialize(nsCStri
     RefPtr<IDXGIFactory> dxgiFactory;
     dxgiAdapter->GetParent(IID_PPV_ARGS(dxgiFactory.StartAssignment()));
 
     RefPtr<IDXGIFactory2> dxgiFactory2;
     hr = dxgiFactory->QueryInterface(
         (IDXGIFactory2**)getter_AddRefs(dxgiFactory2));
 
 #if (_WIN32_WINDOWS_MAXVER >= 0x0A00)
-    if (StaticPrefs::gfx_direct3d11_use_double_buffering() && SUCCEEDED(hr) &&
-        dxgiFactory2 && IsWindows10OrGreater()) {
+    if (gfxVars::UseDoubleBufferingWithCompositor() && SUCCEEDED(hr) &&
+        dxgiFactory2) {
       // DXGI_SCALING_NONE is not available on Windows 7 with Platform Update.
       // This looks awful for things like the awesome bar and browser window
       // resizing so we don't use a flip buffer chain here. When using
       // EFFECT_SEQUENTIAL it looks like windows doesn't stretch the surface
       // when resizing. We chose not to run this before Windows 10 because it
       // appears sometimes this breaks our ability to test ASAP compositing.
       RefPtr<IDXGISwapChain1> swapChain;
 
--- a/gfx/layers/d3d11/MLGDeviceD3D11.cpp
+++ b/gfx/layers/d3d11/MLGDeviceD3D11.cpp
@@ -229,19 +229,19 @@ bool MLGSwapChainD3D11::Initialize(Compo
   {
     RefPtr<IDXGIAdapter> adapter;
     dxgiDevice->GetAdapter(getter_AddRefs(adapter));
 
     adapter->GetParent(IID_PPV_ARGS(dxgiFactory.StartAssignment()));
   }
 
   RefPtr<IDXGIFactory2> dxgiFactory2;
-  if (StaticPrefs::gfx_direct3d11_use_double_buffering() &&
+  if (gfxVars::UseDoubleBufferingWithCompositor() &&
       SUCCEEDED(dxgiFactory->QueryInterface(dxgiFactory2.StartAssignment())) &&
-      dxgiFactory2 && IsWin10OrLater() && XRE_IsGPUProcess()) {
+      dxgiFactory2 && XRE_IsGPUProcess()) {
     // DXGI_SCALING_NONE is not available on Windows 7 with the Platform Update:
     // This looks awful for things like the awesome bar and browser window
     // resizing, so we don't use a flip buffer chain here. (Note when using
     // EFFECT_SEQUENTIAL Windows doesn't stretch the surface when resizing).
     //
     // We choose not to run this on platforms earlier than Windows 10 because
     // it appears sometimes this breaks our ability to test ASAP compositing,
     // which breaks Talos.
--- a/gfx/layers/ipc/CompositorBridgeParent.cpp
+++ b/gfx/layers/ipc/CompositorBridgeParent.cpp
@@ -1548,18 +1548,17 @@ RefPtr<Compositor> CompositorBridgeParen
 
 PLayerTransactionParent* CompositorBridgeParent::AllocPLayerTransactionParent(
     const nsTArray<LayersBackend>& aBackendHints, const LayersId& aId) {
   MOZ_ASSERT(!aId.IsValid());
 
 #ifdef XP_WIN
   // This is needed to avoid freezing the window on a device crash on double
   // buffering, see bug 1549674.
-  if (StaticPrefs::gfx_direct3d11_use_double_buffering() && IsWin10OrLater() &&
-      XRE_IsGPUProcess()) {
+  if (gfxVars::UseDoubleBufferingWithCompositor() && XRE_IsGPUProcess()) {
     mWidget->AsWindows()->EnsureCompositorWindow();
   }
 #endif
 
   InitializeLayerManager(aBackendHints);
 
   if (!mLayerManager) {
     NS_WARNING("Failed to initialise Compositor");
--- a/gfx/thebes/gfxPlatform.cpp
+++ b/gfx/thebes/gfxPlatform.cpp
@@ -2410,16 +2410,20 @@ void gfxPlatform::InitAcceleration() {
                                       discardFailureId, &status))) {
       gfxVars::SetAllowD3D11KeyedMutex(status == nsIGfxInfo::FEATURE_STATUS_OK);
     } else {
       // If we couldn't properly evaluate the status, err on the side
       // of caution and give this functionality to the user.
       gfxCriticalNote << "Cannot evaluate keyed mutex feature status";
       gfxVars::SetAllowD3D11KeyedMutex(true);
     }
+    if (StaticPrefs::gfx_direct3d11_use_double_buffering() &&
+        IsWin10OrLater()) {
+      gfxVars::SetUseDoubleBufferingWithCompositor(true);
+    }
 #endif
   }
 
   if (Preferences::GetBool("media.hardware-video-decoding.enabled", false) &&
 #ifdef XP_WIN
       Preferences::GetBool("media.wmf.dxva.enabled", true) &&
 #endif
       NS_SUCCEEDED(