Bug 1710486 - Fix InProcessWinCompositorWidget locking to always release the present lock. r=cmartin
authorEmilio Cobos Alvarez <emilio@crisal.io>
Mon, 10 May 2021 18:52:59 +0000
changeset 579268 655284ac7e4d839b428f70b42e4b8402da6dad3a
parent 579267 98b251a30b42e435eb73a448008eee724a4e97a8
child 579269 28a5d1a9fd5de4530cee7b377a4fdacf5bf6e183
push id38451
push userncsoregi@mozilla.com
push dateTue, 11 May 2021 02:09:31 +0000
treeherdermozilla-central@509cb523d4f7 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerscmartin
bugs1710486
milestone90.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1710486 - Fix InProcessWinCompositorWidget locking to always release the present lock. r=cmartin Otherwise we may hang when drawing transparent popups. Differential Revision: https://phabricator.services.mozilla.com/D114766
widget/windows/InProcessWinCompositorWidget.cpp
--- a/widget/windows/InProcessWinCompositorWidget.cpp
+++ b/widget/windows/InProcessWinCompositorWidget.cpp
@@ -61,21 +61,20 @@ InProcessWinCompositorWidget::InProcessW
   // mNotDeferEndRemoteDrawing is set on the main thread during init,
   // but is only accessed after on the compositor thread.
   mNotDeferEndRemoteDrawing =
       StaticPrefs::layers_offmainthreadcomposition_frame_rate() == 0 ||
       gfxPlatform::IsInLayoutAsapMode() || gfxPlatform::ForceSoftwareVsync();
 }
 
 void InProcessWinCompositorWidget::OnDestroyWindow() {
-  EnterPresentLock();
+  gfx::CriticalSectionAutoEnter presentLock(&mPresentLock);
   MutexAutoLock lock(mTransparentSurfaceLock);
   mTransparentSurface = nullptr;
   mMemoryDC = nullptr;
-  LeavePresentLock();
 }
 
 bool InProcessWinCompositorWidget::OnWindowResize(
     const LayoutDeviceIntSize& aSize) {
   return true;
 }
 
 void InProcessWinCompositorWidget::OnWindowModeChange(nsSizeMode aSizeMode) {}
@@ -261,43 +260,42 @@ void InProcessWinCompositorWidget::Creat
   RefPtr<gfxWindowsSurface> surface =
       new gfxWindowsSurface(aSize, SurfaceFormat::A8R8G8B8_UINT32);
   mTransparentSurface = surface;
   mMemoryDC = surface->GetDC();
 }
 
 void InProcessWinCompositorWidget::UpdateTransparency(
     nsTransparencyMode aMode) {
-  EnterPresentLock();
+  gfx::CriticalSectionAutoEnter presentLock(&mPresentLock);
   MutexAutoLock lock(mTransparentSurfaceLock);
   if (mTransparencyMode == aMode) {
     return;
   }
 
   mTransparencyMode = aMode;
   mTransparentSurface = nullptr;
   mMemoryDC = nullptr;
 
   if (mTransparencyMode == eTransparencyTransparent) {
     EnsureTransparentSurface();
   }
-  LeavePresentLock();
 }
 
 bool InProcessWinCompositorWidget::HasGlass() const {
   MOZ_ASSERT(layers::CompositorThreadHolder::IsInCompositorThread() ||
              wr::RenderThread::IsInRenderThread());
 
   nsTransparencyMode transparencyMode = mTransparencyMode;
   return transparencyMode == eTransparencyGlass ||
          transparencyMode == eTransparencyBorderlessGlass;
 }
 
 void InProcessWinCompositorWidget::ClearTransparentWindow() {
-  EnterPresentLock();
+  gfx::CriticalSectionAutoEnter presentLock(&mPresentLock);
   MutexAutoLock lock(mTransparentSurfaceLock);
   if (!mTransparentSurface) {
     return;
   }
 
   EnsureTransparentSurface();
 
   IntSize size = mTransparentSurface->GetSize();
@@ -305,17 +303,16 @@ void InProcessWinCompositorWidget::Clear
     RefPtr<DrawTarget> drawTarget =
         gfxPlatform::CreateDrawTargetForSurface(mTransparentSurface, size);
     if (!drawTarget) {
       return;
     }
     drawTarget->ClearRect(Rect(0, 0, size.width, size.height));
     RedrawTransparentWindow();
   }
-  LeavePresentLock();
 }
 
 bool InProcessWinCompositorWidget::RedrawTransparentWindow() {
   MOZ_ASSERT(mTransparencyMode == eTransparencyTransparent);
 
   LayoutDeviceIntSize size = GetClientSize();
 
   ::GdiFlush();