Bug 1297105 - Prevent crash when DX11 resources fail to be allocated for Oculus VR HMD presentation draft
authorKearwood (Kip) Gilbert <kgilbert@mozilla.com>
Tue, 30 Aug 2016 15:34:11 -0700
changeset 409334 bc60ba8d2bdee9a6ca704ebc0508763f68beaf78
parent 409041 d5f20820c80514476f596090292a5d77c4b41e3b
child 530321 f91cf43cb947d8fc55e30995b8575a857d7b67d3
push id28449
push userkgilbert@mozilla.com
push dateFri, 02 Sep 2016 17:40:34 +0000
bugs1297105
milestone51.0a1
Bug 1297105 - Prevent crash when DX11 resources fail to be allocated for Oculus VR HMD presentation MozReview-Commit-ID: 3KLGu3DJVbP
gfx/vr/gfxVROculus.cpp
--- a/gfx/vr/gfxVROculus.cpp
+++ b/gfx/vr/gfxVROculus.cpp
@@ -753,16 +753,27 @@ VRDisplayOculus::SubmitFrame(TextureSour
   const IntSize& aSize,
   const VRHMDSensorState& aSensorState,
   const gfx::Rect& aLeftEyeRect,
   const gfx::Rect& aRightEyeRect)
 {
   if (!mIsPresenting) {
     return;
   }
+  if (mRenderTargets.IsEmpty()) {
+    /**
+     * XXX - We should resolve fail the promise returned by
+     *       VRDisplay.requestPresent() when the DX11 resources fail allocation
+     *       in VRDisplayOculus::StartPresentation().
+     *       Bailing out here prevents the crash but content should be aware
+     *       that frames are not being presented.
+     *       See Bug 1299309.
+     **/
+    return;
+  }
   MOZ_ASSERT(mDevice);
   MOZ_ASSERT(mContext);
 
   RefPtr<CompositingRenderTargetD3D11> surface = GetNextRenderTarget();
 
   surface->BindRenderTarget(mContext);
 
   Matrix viewMatrix = Matrix::Translation(-1.0, 1.0);