Bug 1491798- Schedule repaint if WebRender is updated by tab move r=mattwoodrow
authorsotaro <sotaro.ikeda.g@gmail.com>
Mon, 01 Oct 2018 10:12:22 +0900
changeset 494667 94a87c720eee25ae57b47fba0b564de70c7b1741
parent 494663 06173200ede0eff3a9a9136968d99d9f7e29d1d1
child 494668 948d251c50ee0c25f30bb032a089a9e83434f756
push id9984
push userffxbld-merge
push dateMon, 15 Oct 2018 21:07:35 +0000
treeherdermozilla-beta@183d27ea8570 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmattwoodrow
bugs1491798
milestone64.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 1491798- Schedule repaint if WebRender is updated by tab move r=mattwoodrow
dom/ipc/TabChild.cpp
dom/ipc/TabChild.h
gfx/layers/wr/WebRenderLayerManager.cpp
--- a/dom/ipc/TabChild.cpp
+++ b/dom/ipc/TabChild.cpp
@@ -3206,16 +3206,35 @@ TabChild::InvalidateLayers()
   MOZ_ASSERT(mPuppetWidget);
   RefPtr<LayerManager> lm = mPuppetWidget->GetLayerManager();
   MOZ_ASSERT(lm);
 
   FrameLayerBuilder::InvalidateAllLayers(lm);
 }
 
 void
+TabChild::SchedulePaint()
+{
+  nsCOMPtr<nsIDocShell> docShell = do_GetInterface(WebNavigation());
+  if (!docShell) {
+    return;
+  }
+
+  // We don't use TabChildBase::GetPresShell() here because that would create
+  // a content viewer if one doesn't exist yet. Creating a content viewer can
+  // cause JS to run, which we want to avoid. nsIDocShell::GetPresShell
+  // returns null if no content viewer exists yet.
+  if (nsCOMPtr<nsIPresShell> presShell = docShell->GetPresShell()) {
+    if (nsIFrame* root = presShell->GetRootFrame()) {
+      root->SchedulePaint();
+    }
+  }
+}
+
+void
 TabChild::ReinitRendering()
 {
   MOZ_ASSERT(mLayersId.IsValid());
 
   // Before we establish a new PLayerTransaction, we must connect our layer tree
   // id, CompositorBridge, and the widget compositor all together again.
   // Normally this happens in TabParent before TabChild is given rendering
   // information.
--- a/dom/ipc/TabChild.h
+++ b/dom/ipc/TabChild.h
@@ -535,16 +535,17 @@ public:
                     const TimeStamp& aCompositeStart,
                     const TimeStamp& aCompositeEnd);
 
   void DidRequestComposite(const TimeStamp& aCompositeReqStart,
                            const TimeStamp& aCompositeReqEnd);
 
   void ClearCachedResources();
   void InvalidateLayers();
+  void SchedulePaint();
   void ReinitRendering();
   void ReinitRenderingForDeviceReset();
 
   static inline TabChild* GetFrom(nsIDOMWindow* aWindow)
   {
     nsCOMPtr<nsIWebNavigation> webNav = do_GetInterface(aWindow);
     nsCOMPtr<nsIDocShell> docShell = do_QueryInterface(webNav);
     return GetFrom(docShell);
--- a/gfx/layers/wr/WebRenderLayerManager.cpp
+++ b/gfx/layers/wr/WebRenderLayerManager.cpp
@@ -556,16 +556,22 @@ WebRenderLayerManager::ClearCachedResour
   WrBridge()->EndClearCachedResources();
 }
 
 void
 WebRenderLayerManager::WrUpdated()
 {
   mWebRenderCommandBuilder.ClearCachedResources();
   DiscardLocalImages();
+
+  if (mWidget) {
+    if (dom::TabChild* tabChild = mWidget->GetOwningTabChild()) {
+      tabChild->SchedulePaint();
+    }
+  }
 }
 
 dom::TabGroup*
 WebRenderLayerManager::GetTabGroup()
 {
   if (mWidget) {
     if (dom::TabChild* tabChild = mWidget->GetOwningTabChild()) {
       return tabChild->TabGroup();