Title: [291566] trunk/Source/WebCore
Revision
291566
Author
[email protected]
Date
2022-03-21 10:53:58 -0700 (Mon, 21 Mar 2022)

Log Message

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

Patch by Kimmo Kinnunen <[email protected]> on 2022-03-21
Reviewed by Antti Koivisto.

Add a quick fix trying to circumvent a Recovery OS crash.
Parts of this will be reverted once the true source is found.

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

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (291565 => 291566)


--- trunk/Source/WebCore/ChangeLog	2022-03-21 17:47:37 UTC (rev 291565)
+++ trunk/Source/WebCore/ChangeLog	2022-03-21 17:53:58 UTC (rev 291566)
@@ -1,3 +1,16 @@
+2022-03-21  Kimmo Kinnunen  <[email protected]>
+
+        Accessing WebGL content crashes in macOS Recovery OS
+        https://bugs.webkit.org/show_bug.cgi?id=238139
+
+        Reviewed by Antti Koivisto.
+
+        Add a quick fix trying to circumvent a Recovery OS crash.
+        Parts of this will be reverted once the true source is found.
+
+        * platform/graphics/cocoa/GraphicsContextGLCocoa.mm:
+        (WebCore::platformSupportsMetal):
+
 2022-03-21  Tim Horton  <[email protected]>
 
         Add an addition point for system background color

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


--- trunk/Source/WebCore/platform/graphics/cocoa/GraphicsContextGLCocoa.mm	2022-03-21 17:47:37 UTC (rev 291565)
+++ trunk/Source/WebCore/platform/graphics/cocoa/GraphicsContextGLCocoa.mm	2022-03-21 17:53:58 UTC (rev 291566)
@@ -41,6 +41,7 @@
 #import <Metal/Metal.h>
 #import <pal/spi/cocoa/MetalSPI.h>
 #import <wtf/BlockObjCExceptions.h>
+#import <wtf/darwin/WeakLinking.h>
 #import <wtf/text/CString.h>
 
 #if PLATFORM(IOS_FAMILY)
@@ -57,6 +58,9 @@
 #import "ImageRotationSessionVT.h"
 #endif
 
+// Metal may not be available, for example in recovery OS.
+WTF_WEAK_LINK_FORCE_IMPORT(MTLCreateSystemDefaultDevice);
+
 namespace WebCore {
 
 // In isCurrentContextPredictable() == true case this variable is accessed in single-threaded manner.
@@ -96,6 +100,22 @@
 
 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) {
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to