Bug 1399501 - MakeCurrent again in InitAndValidateGL. r=kvark
authorJeff Gilbert <jgilbert@mozilla.com>
Thu, 18 Oct 2018 21:54:31 -0700
changeset 442845 5cb0aeccd4cc8d6417d9c92d04c2ee60ce244cbd
parent 442844 7b88a6284d31c87ee25d782d869c936cb0b7648d
child 442846 7f1abf24702dc68a85b6d4fdaec4c741565ebfd5
push id34925
push userrgurzau@mozilla.com
push dateWed, 24 Oct 2018 22:00:55 +0000
treeherdermozilla-central@ddadc29de671 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskvark
bugs1399501
milestone65.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 1399501 - MakeCurrent again in InitAndValidateGL. r=kvark Differential Revision: https://phabricator.services.mozilla.com/D9290
dom/canvas/WebGLContextValidate.cpp
dom/canvas/test/webgl-conf/generated-mochitest.ini
dom/canvas/test/webgl-conf/mochitest-errata.ini
--- a/dom/canvas/WebGLContextValidate.cpp
+++ b/dom/canvas/WebGLContextValidate.cpp
@@ -300,33 +300,32 @@ WebGLContext::ValidateUniformMatrixArray
     return true;
 }
 
 bool
 WebGLContext::InitAndValidateGL(FailureReason* const out_failReason)
 {
     MOZ_RELEASE_ASSERT(gl, "GFX: GL not initialized");
 
+    if (!gl->MakeCurrent(true)) {
+        MOZ_ASSERT(false);
+        *out_failReason = { "FEATURE_FAILURE_WEBGL_MAKECURRENT",
+                            "Failed to MakeCurrent for init." };
+        return false;
+    }
+
     // Unconditionally create a new format usage authority. This is
     // important when restoring contexts and extensions need to add
     // formats back into the authority.
     mFormatUsage = CreateFormatUsage(gl);
-    if (!mFormatUsage) {
-        *out_failReason = { "FEATURE_FAILURE_WEBGL_FORMAT",
-                            "Failed to create mFormatUsage." };
-        return false;
-    }
+    MOZ_RELEASE_ASSERT(mFormatUsage);
 
-    GLenum error = gl->fGetError();
-    if (error != LOCAL_GL_NO_ERROR) {
-        const nsPrintfCString reason("GL error 0x%x occurred during OpenGL context"
-                                     " initialization, before WebGL initialization!",
-                                     error);
-        *out_failReason = { "FEATURE_FAILURE_WEBGL_GLERR_1", reason };
-        return false;
+    {
+        const auto error = gl->fGetError();
+        MOZ_ALWAYS_TRUE(!error);
     }
 
     mDisableExtensions = gfxPrefs::WebGLDisableExtensions();
     mLoseContextOnMemoryPressure = gfxPrefs::WebGLLoseContextOnMemoryPressure();
     mCanLoseContextInForeground = gfxPrefs::WebGLCanLoseContextInForeground();
     mRestoreWhenVisible = gfxPrefs::WebGLRestoreWhenVisible();
 
     // These are the default values, see 6.2 State tables in the
@@ -599,23 +598,19 @@ WebGLContext::InitAndValidateGL(FailureR
     // Mesa can only be detected with the GL_VERSION string, of the form
     // "2.1 Mesa 7.11.0"
     const char* versionStr = (const char*)(gl->fGetString(LOCAL_GL_VERSION));
     mIsMesa = strstr(versionStr, "Mesa");
 
     // Notice that the point of calling fGetError here is not only to check for
     // errors, but also to reset the error flags so that a subsequent WebGL
     // getError call will give the correct result.
-    error = gl->fGetError();
-    if (error != LOCAL_GL_NO_ERROR) {
-        const nsPrintfCString reason("GL error 0x%x occurred during WebGL context"
-                                     " initialization!",
-                                     error);
-        *out_failReason = { "FEATURE_FAILURE_WEBGL_GLERR_2", reason };
-        return false;
+    {
+        const auto error = gl->fGetError();
+        MOZ_ALWAYS_TRUE(!error);
     }
 
     if (IsWebGL2() &&
         !InitWebGL2(out_failReason))
     {
         // Todo: Bug 898404: Only allow WebGL2 on GL>=3.0 on desktop GL.
         return false;
     }
--- a/dom/canvas/test/webgl-conf/generated-mochitest.ini
+++ b/dom/canvas/test/webgl-conf/generated-mochitest.ini
@@ -11406,17 +11406,17 @@ subsuite = webgl1-ext
 [generated/test_conformance__glsl__misc__empty-declaration.html]
 subsuite = webgl1-ext
 [generated/test_conformance__glsl__misc__empty_main.vert.html]
 subsuite = webgl1-ext
 [generated/test_conformance__glsl__misc__expression-list-in-declarator-initializer.html]
 subsuite = webgl1-ext
 [generated/test_conformance__glsl__misc__fragcolor-fragdata-invariant.html]
 subsuite = webgl1-ext
-fail-if = (os == 'mac')
+fail-if = (os == 'linux') || (os == 'mac')
 [generated/test_conformance__glsl__misc__gl_position_unset.vert.html]
 subsuite = webgl1-ext
 [generated/test_conformance__glsl__misc__global-variable-init.html]
 subsuite = webgl1-ext
 [generated/test_conformance__glsl__misc__glsl-function-nodes.html]
 subsuite = webgl1-ext
 [generated/test_conformance__glsl__misc__glsl-long-variable-names.html]
 subsuite = webgl1-ext
--- a/dom/canvas/test/webgl-conf/mochitest-errata.ini
+++ b/dom/canvas/test/webgl-conf/mochitest-errata.ini
@@ -353,17 +353,17 @@ fail-if = (os == 'mac') || (verify && de
 skip-if = (os == 'win')
 [generated/test_2_conformance__rendering__rendering-stencil-large-viewport.html]
 # same as webgl1 test
 fail-if = (os == 'mac')
 skip-if = (os == 'win')
 
 [generated/test_conformance__glsl__misc__fragcolor-fragdata-invariant.html]
 # [unexpected fragment shader compile status] (expected: true) Declaring both gl_FragColor and gl_FragData invariant should succeed.
-fail-if = (os == 'mac')
+fail-if = (os == 'linux') || (os == 'mac')
 
 ########################################################################
 # "tst-linux{32,64}-spot-NNN" Slaves:
 #   Android 2.3 and Linux.
 # Android: os == 'android'. (Not enough info to separate out 2.3)
 # Linux: os == 'linux'.
 [generated/test_conformance__glsl__bugs__temp-expressions-should-not-crash.html]
 # Coincidentally enough, crashes on Linux and Android 4.0.