Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Better error detection when creating an XRWebGLLayer
  • Loading branch information
Alan Jeffrey committed Aug 29, 2019
1 parent 9fe3c4f commit b6cf6c0
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion components/script/dom/xrwebgllayer.rs
Expand Up @@ -129,12 +129,28 @@ impl XRWebGLLayer {
);

// Restore the WebGL state while complaining about global mutable state
let fb_status = context.CheckFramebufferStatus(constants::FRAMEBUFFER);
let gl_status = context.GetError();
context.BindTexture(constants::TEXTURE_2D, old_texture.as_ref().map(|t| &**t));
context.BindFramebuffer(constants::FRAMEBUFFER, old_fbo.as_ref().map(|f| &**f));

// Step 8.4: "If layer’s resources were unable to be created for any reason,
// throw an OperationError and abort these steps."
sc.or(Err(Error::Operation))?;
if let Err(err) = sc {
error!("TexImage2D error {:?} while creating XR context", err);
return Err(Error::Operation);
}
if fb_status != constants::FRAMEBUFFER_COMPLETE {
error!(
"Framebuffer error {:x} while creating XR context",
fb_status
);
return Err(Error::Operation);
}
if gl_status != constants::NO_ERROR {
error!("GL error {:x} while creating XR context", gl_status);
return Err(Error::Operation);
}

// Step 9. "Return layer."
Ok(XRWebGLLayer::new(
Expand Down

0 comments on commit b6cf6c0

Please sign in to comment.