Bug 1500520 - Always check graphics reset status in RenderThread::UpdateAndRender() r=nical
authorsotaro <sotaro.ikeda.g@gmail.com>
Tue, 23 Oct 2018 12:14:45 +0900
changeset 490736 a0fac96b947ef3dbcd50106e66d14b8ff4b5a7fa
parent 490735 99bd9a8c917c23dad65f2853a2c7a6c9be58957c
child 490737 bd15c0cbc18ab4fc6dcac68c8be86a88e1ee7e76
push id247
push userfmarier@mozilla.com
push dateSat, 27 Oct 2018 01:06:44 +0000
reviewersnical
bugs1500520
milestone65.0a1
Bug 1500520 - Always check graphics reset status in RenderThread::UpdateAndRender() r=nical
gfx/webrender_bindings/RenderThread.cpp
gfx/webrender_bindings/RendererOGL.cpp
gfx/webrender_bindings/RendererOGL.h
--- a/gfx/webrender_bindings/RenderThread.cpp
+++ b/gfx/webrender_bindings/RenderThread.cpp
@@ -371,16 +371,18 @@ RenderThread::UpdateAndRender(wr::Window
 
   auto& renderer = it->second;
 
   if (aRender) {
     renderer->UpdateAndRender(aReadbackSize, aReadbackBuffer);
   } else {
     renderer->Update();
   }
+  // Check graphics reset status even when rendering is skipped.
+  renderer->CheckGraphicsResetStatus();
 
   TimeStamp end = TimeStamp::Now();
 
   auto info = renderer->FlushPipelineInfo();
   RefPtr<layers::AsyncImagePipelineManager> pipelineMgr =
       renderer->GetCompositorBridge()->GetAsyncImagePipelineManager();
   // pipelineMgr should always be non-null here because it is only nulled out
   // after the WebRenderAPI instance for the CompositorBridgeParent is
--- a/gfx/webrender_bindings/RendererOGL.cpp
+++ b/gfx/webrender_bindings/RendererOGL.cpp
@@ -163,32 +163,40 @@ RendererOGL::UpdateAndRender(const Maybe
   if (mFrameStartTime) {
     uint32_t latencyMs = round((TimeStamp::Now() - mFrameStartTime).ToMilliseconds());
     printf_stderr("generate frame latencyMs latencyMs %d\n", latencyMs);
   }
   // Clear frame start time
   mFrameStartTime = TimeStamp();
 #endif
 
+  // TODO: Flush pending actions such as texture deletions/unlocks and
+  //       textureHosts recycling.
+
+  return true;
+}
+
+void
+RendererOGL::CheckGraphicsResetStatus()
+{
+  if (!mCompositor || !mCompositor->gl()) {
+    return;
+  }
+
   gl::GLContext* gl = mCompositor->gl();
   if (gl->IsSupported(gl::GLFeature::robustness)) {
     GLenum resetStatus = gl->fGetGraphicsResetStatus();
     if (resetStatus == LOCAL_GL_PURGED_CONTEXT_RESET_NV) {
       layers::CompositorThreadHolder::Loop()->PostTask(NewRunnableFunction(
         "DoNotifyWebRenderContextPurgeRunnable",
         &DoNotifyWebRenderContextPurge,
         mBridge
       ));
     }
   }
-
-  // TODO: Flush pending actions such as texture deletions/unlocks and
-  //       textureHosts recycling.
-
-  return true;
 }
 
 void
 RendererOGL::Pause()
 {
   mCompositor->Pause();
 }
 
--- a/gfx/webrender_bindings/RendererOGL.h
+++ b/gfx/webrender_bindings/RendererOGL.h
@@ -79,16 +79,19 @@ public:
               layers::CompositorBridgeParent* aBridge);
 
   /// This can be called on the render thread only.
   void Pause();
 
   /// This can be called on the render thread only.
   bool Resume();
 
+  /// This can be called on the render thread only.
+  void CheckGraphicsResetStatus();
+
   layers::SyncObjectHost* GetSyncObject() const;
 
   layers::CompositorBridgeParent* GetCompositorBridge() { return mBridge; }
 
   wr::WrPipelineInfo FlushPipelineInfo();
 
   RenderTextureHost* GetRenderTexture(wr::WrExternalImageId aExternalImageId);