Title: [291983] trunk/Source/WebCore
Revision
291983
Author
[email protected]
Date
2022-03-28 12:40:01 -0700 (Mon, 28 Mar 2022)

Log Message

Accessing WebGL content crashes in macOS Recovery OS, workaround 2
https://bugs.webkit.org/show_bug.cgi?id=238448

Patch by Kimmo Kinnunen <[email protected]> on 2022-03-28
Reviewed by Dean Jackson.

Add a two new quick workarounds to try fix a recovery OS crash when
WebKit tries to use ANGLE that is not present in the OS image.
Compare explicitly against NULL as instructed in weak linking documentation.
Check for the EGL_GetPlatformDisplayEXT, this is nullptr in the
recovery OS.

Remove the previous workaround. The environment variable is
not available in WP or GPUP. The Metal symbol is not the problem.

* platform/graphics/cocoa/GraphicsContextGLCocoa.mm:
(WebCore::platformSupportsMetal):
(WebCore::initializeEGLDisplay):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (291982 => 291983)


--- trunk/Source/WebCore/ChangeLog	2022-03-28 19:33:54 UTC (rev 291982)
+++ trunk/Source/WebCore/ChangeLog	2022-03-28 19:40:01 UTC (rev 291983)
@@ -1,3 +1,23 @@
+2022-03-28  Kimmo Kinnunen  <[email protected]>
+
+        Accessing WebGL content crashes in macOS Recovery OS, workaround 2
+        https://bugs.webkit.org/show_bug.cgi?id=238448
+
+        Reviewed by Dean Jackson.
+
+        Add a two new quick workarounds to try fix a recovery OS crash when
+        WebKit tries to use ANGLE that is not present in the OS image.
+        Compare explicitly against NULL as instructed in weak linking documentation.
+        Check for the EGL_GetPlatformDisplayEXT, this is nullptr in the
+        recovery OS.
+
+        Remove the previous workaround. The environment variable is
+        not available in WP or GPUP. The Metal symbol is not the problem.
+
+        * platform/graphics/cocoa/GraphicsContextGLCocoa.mm:
+        (WebCore::platformSupportsMetal):
+        (WebCore::initializeEGLDisplay):
+
 2022-03-28  Chris Dumez  <[email protected]>
 
         Speed up Element::removedFromAncestor()

Modified: trunk/Source/WebCore/platform/graphics/cocoa/ANGLEUtilitiesCocoa.cpp (291982 => 291983)


--- trunk/Source/WebCore/platform/graphics/cocoa/ANGLEUtilitiesCocoa.cpp	2022-03-28 19:33:54 UTC (rev 291982)
+++ trunk/Source/WebCore/platform/graphics/cocoa/ANGLEUtilitiesCocoa.cpp	2022-03-28 19:40:01 UTC (rev 291983)
@@ -40,7 +40,7 @@
 {
     // The ANGLE is weak linked in full, and the EGL_Initialize is explicitly weak linked above
     // so that we can detect the case where ANGLE is not present.
-    return !!EGL_Initialize;
+    return EGL_Initialize != NULL; // NOLINT
 }
 
 void* createPbufferAndAttachIOSurface(GCGLDisplay display, GCGLConfig config, GCGLenum target, GCGLint usageHint, GCGLenum internalFormat, GCGLsizei width, GCGLsizei height, GCGLenum type, IOSurfaceRef surface, GCGLuint plane)

Modified: trunk/Source/WebCore/platform/graphics/cocoa/GraphicsContextGLCocoa.mm (291982 => 291983)


--- trunk/Source/WebCore/platform/graphics/cocoa/GraphicsContextGLCocoa.mm	2022-03-28 19:33:54 UTC (rev 291982)
+++ trunk/Source/WebCore/platform/graphics/cocoa/GraphicsContextGLCocoa.mm	2022-03-28 19:40:01 UTC (rev 291983)
@@ -58,8 +58,8 @@
 #import "ImageRotationSessionVT.h"
 #endif
 
-// Metal may not be available, for example in recovery OS.
-WTF_WEAK_LINK_FORCE_IMPORT(MTLCreateSystemDefaultDevice);
+// FIXME: Checking for EGL_Initialize does not seem to be robust in recovery OS.
+WTF_WEAK_LINK_FORCE_IMPORT(EGL_GetPlatformDisplayEXT);
 
 namespace WebCore {
 
@@ -100,22 +100,6 @@
 
 static bool platformSupportsMetal(bool isWebGL2)
 {
-    // FIXME: Figure out why WebKit runs in recovery system using -framework Metal, but seemingly cannot call into Metal.
-    // The hunk about runnningInRecoverySystem should be removed once it is clear how WebKit can link strongly to Metal
-    // but run without Metal.
-    static bool runningInRecoverySystem = [] {
-        if (getenv("__OSINSTALL_ENVIRONMENT")) {
-            WTFLogAlways("WebGL: Running in recovery. Has access to Metal: %s", !MTLCreateSystemDefaultDevice ? "no" : "yes");
-            return true;
-        }
-        return false;
-    }();
-    if (runningInRecoverySystem)
-        return false;
-
-    if (!MTLCreateSystemDefaultDevice)
-        return false;
-
     auto device = adoptNS(MTLCreateSystemDefaultDevice());
 
     if (device) {
@@ -139,6 +123,12 @@
         WTFLogAlways("Failed to load ANGLE shared library.");
         return EGL_NO_DISPLAY;
     }
+    // FIXME(http://webkit.org/b/238448): Why is checking EGL_Initialize not robust in recovery OS?
+    if (EGL_GetPlatformDisplayEXT == NULL) { // NOLINT
+        WTFLogAlways("Inconsistent weak linking for ANGLE shared library.");
+        return EGL_NO_DISPLAY;
+    }
+
 #if ASSERT_ENABLED
     const char* clientExtensions = EGL_QueryString(EGL_NO_DISPLAY, EGL_EXTENSIONS);
     ASSERT(clientExtensions);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to