Bug 1351384 - Stop using the CompositorOptions to check if WebRender is enabled. r?dvander draft
authorKartikaya Gupta <kgupta@mozilla.com>
Tue, 28 Mar 2017 16:40:24 -0400
changeset 552692 5a12bbd83f5e95daf9fa04303bd4a75340006302
parent 552691 272ce6c2572164f5f6a9fba2a980ba9ccf50770c
child 621875 404c52f9905cbfe855c9f6aa8af3762a23d94b94
push id51420
push userkgupta@mozilla.com
push dateTue, 28 Mar 2017 20:40:47 +0000
reviewersdvander
bugs1351384
milestone55.0a1
Bug 1351384 - Stop using the CompositorOptions to check if WebRender is enabled. r?dvander I suspect that the PuppetWidget is trying to create the layer manager after it has been connected to a TabChild but before the TabChild has populated the CompositorOptions. This results in the PuppetWidget effectively getting an uninitialized value for the CompositorOptions, and so it sometimes randomly creates a WebRenderLayerManager, later resulting in a crash. It seems like exposing the potentially-uninitialized CompositorOptions from TabChild like this is a bad idea, so I'm removing that API and using the more reliable gfxVars in PuppetWidget. This is fine for WebRender purposes because we no longer care to allow having WR compositors co-exist with non-WR compositors. We may eventually want to remove the CompositorOptions entirely, but for now the rest of the usage of it seems fine. MozReview-Commit-ID: 6ekG8j1PskK
dom/ipc/TabChild.cpp
dom/ipc/TabChild.h
widget/PuppetWidget.cpp
--- a/dom/ipc/TabChild.cpp
+++ b/dom/ipc/TabChild.cpp
@@ -426,24 +426,16 @@ TabChild::TabChild(nsIContentChild* aMan
     }
   }
 
   for (uint32_t idx = 0; idx < NUMBER_OF_AUDIO_CHANNELS; idx++) {
     mAudioChannelsActive.AppendElement(false);
   }
 }
 
-const CompositorOptions&
-TabChild::GetCompositorOptions() const
-{
-  // If you're calling this before mCompositorOptions is set, well.. don't.
-  MOZ_ASSERT(mCompositorOptions);
-  return mCompositorOptions.ref();
-}
-
 bool
 TabChild::AsyncPanZoomEnabled() const
 {
   // By the time anybody calls this, we must have had InitRenderingState called
   // already, and so mCompositorOptions should be populated.
   MOZ_RELEASE_ASSERT(mCompositorOptions);
   return mCompositorOptions->UseAPZ();
 }
--- a/dom/ipc/TabChild.h
+++ b/dom/ipc/TabChild.h
@@ -615,17 +615,16 @@ public:
 
   bool IPCOpen() const { return mIPCOpen; }
 
   bool ParentIsActive() const
   {
     return mParentIsActive;
   }
 
-  const mozilla::layers::CompositorOptions& GetCompositorOptions() const;
   bool AsyncPanZoomEnabled() const;
 
   virtual ScreenIntSize GetInnerSize() override;
 
   // Call RecvShow(nsIntSize(0, 0)) and block future calls to RecvShow().
   void DoFakeShow(const TextureFactoryIdentifier& aTextureFactoryIdentifier,
                   const uint64_t& aLayersId,
                   PRenderFrameChild* aRenderFrame,
--- a/widget/PuppetWidget.cpp
+++ b/widget/PuppetWidget.cpp
@@ -602,20 +602,17 @@ PuppetWidget::GetLayerManager(PLayerTran
     if (XRE_IsParentProcess()) {
       // On the parent process there is no CompositorBridgeChild which confuses
       // some layers code, so we use basic layers instead. Note that we create
       // a non-retaining layer manager since we don't care about performance.
       mLayerManager = new BasicLayerManager(BasicLayerManager::BLM_OFFSCREEN);
       return mLayerManager;
     }
 
-    bool useWebRender = mTabChild
-        ? mTabChild->GetCompositorOptions().UseWebRender()
-        : gfxVars::UseWebRender();
-    if (useWebRender) {
+    if (gfxVars::UseWebRender()) {
       mLayerManager = new WebRenderLayerManager(this);
     } else {
       mLayerManager = new ClientLayerManager(this);
     }
   }
 
   // Attach a shadow forwarder if none exists.
   ShadowLayerForwarder* lf = mLayerManager->AsShadowForwarder();
@@ -629,17 +626,17 @@ PuppetWidget::GetLayerManager(PLayerTran
 LayerManager*
 PuppetWidget::RecreateLayerManager(PLayerTransactionChild* aShadowManager)
 {
   // Force the old LM to self destruct, otherwise if the reference dangles we
   // could fail to revoke the most recent transaction.
   DestroyLayerManager();
 
   MOZ_ASSERT(mTabChild);
-  if (mTabChild->GetCompositorOptions().UseWebRender()) {
+  if (gfxVars::UseWebRender()) {
     mLayerManager = new WebRenderLayerManager(this);
   } else {
     mLayerManager = new ClientLayerManager(this);
   }
   if (ShadowLayerForwarder* lf = mLayerManager->AsShadowForwarder()) {
     lf->SetShadowManager(aShadowManager);
   }
   return mLayerManager;