Bug 1462695 - Prevent crashing when context lost during WebVR presentation. r=jgilbert, a=RyanVM
authorKearwood Gilbert <kgilbert@mozilla.com>
Fri, 25 May 2018 14:10:47 -0700
changeset 473567 a448bc1954144c818ebe7efb04d83bca81cf9fea
parent 473566 f60772fd03c6e4fb5815796cbf65fad2f5f69982
child 473568 cab78187269bc4c65ac49cc336bbec4e8f6a58b9
push id1728
push userjlund@mozilla.com
push dateMon, 18 Jun 2018 21:12:27 +0000
treeherdermozilla-release@c296fde26f5f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjgilbert, RyanVM
bugs1462695
milestone61.0
Bug 1462695 - Prevent crashing when context lost during WebVR presentation. r=jgilbert, a=RyanVM
dom/canvas/WebGLContext.cpp
--- a/dom/canvas/WebGLContext.cpp
+++ b/dom/canvas/WebGLContext.cpp
@@ -2379,27 +2379,28 @@ WebGLContext::GetVRFrame()
   /**
    * Swap buffers as though composition has occurred.
    * We will then share the resulting front buffer to be submitted to the VR
    * compositor.
    */
   BeginComposition();
   EndComposition();
 
+  if (IsContextLost())
+      return nullptr;
+
   gl::GLScreenBuffer* screen = gl->Screen();
-  if (!screen) {
+  if (!screen)
       return nullptr;
-  }
 
   RefPtr<SharedSurfaceTextureClient> sharedSurface = screen->Front();
-  if (!sharedSurface) {
+  if (!sharedSurface)
       return nullptr;
-  }
-
-    return sharedSurface.forget();
+
+  return sharedSurface.forget();
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 
 static inline size_t
 SizeOfViewElem(const dom::ArrayBufferView& view)
 {
     const auto& elemType = view.Type();