Bug 1351547 - Part 2: Check canvas element is WebGL1/WebGL2 context for avoid crash; r=kip
authorDaosheng Mu <daoshengmu@gmail.com>
Wed, 26 Apr 2017 07:00:34 +0200
changeset 403167 1a95eef9b0b55b1f072a1cafe702b84bf8faa142
parent 403166 d30535c0bb622ba4efa4680f0400bff89bb8e96b
child 403168 e1eb2550cb111e242ded6a12d6e50731fcefcbf6
push id7391
push usermtabara@mozilla.com
push dateMon, 12 Jun 2017 13:08:53 +0000
treeherdermozilla-beta@2191d7f87e2e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskip
bugs1351547
milestone55.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 1351547 - Part 2: Check canvas element is WebGL1/WebGL2 context for avoid crash; r=kip MozReview-Commit-ID: En52uAD3yHO --- dom/html/HTMLCanvasElement.cpp | 5 +++++ 1 file changed, 5 insertions(+)
dom/html/HTMLCanvasElement.cpp
--- a/dom/html/HTMLCanvasElement.cpp
+++ b/dom/html/HTMLCanvasElement.cpp
@@ -1468,16 +1468,21 @@ HTMLCanvasElement::InvalidateFromAsyncCa
   }
 
   element->InvalidateCanvasContent(nullptr);
 }
 
 void
 HTMLCanvasElement::StartVRPresentation()
 {
+  if (GetCurrentContextType() != CanvasContextType::WebGL1 &&
+      GetCurrentContextType() != CanvasContextType::WebGL2) {
+    return;
+  }
+
   WebGLContext* webgl = static_cast<WebGLContext*>(GetContextAtIndex(0));
   if (!webgl) {
     return;
   }
 
   if (!webgl->StartVRPresentation()) {
     return;
   }