Title: [271486] trunk/Source/WebKit
Revision
271486
Author
[email protected]
Date
2021-01-14 09:17:32 -0800 (Thu, 14 Jan 2021)

Log Message

Use callOnMainRunLoop in MediaPermissionUtilities
https://bugs.webkit.org/show_bug.cgi?id=220616
<rdar://problem/73002655>

Reviewed by Chris Dumez.

This ensures that we are in main thread and not in web thread.

* UIProcess/Cocoa/MediaPermissionUtilities.mm:
(WebKit::requestAVCaptureAccessForType):
(WebKit::requestSpeechRecognitionAccess):

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (271485 => 271486)


--- trunk/Source/WebKit/ChangeLog	2021-01-14 17:15:03 UTC (rev 271485)
+++ trunk/Source/WebKit/ChangeLog	2021-01-14 17:17:32 UTC (rev 271486)
@@ -1,3 +1,17 @@
+2021-01-14  Youenn Fablet  <[email protected]>
+
+        Use callOnMainRunLoop in MediaPermissionUtilities
+        https://bugs.webkit.org/show_bug.cgi?id=220616
+        <rdar://problem/73002655>
+
+        Reviewed by Chris Dumez.
+
+        This ensures that we are in main thread and not in web thread.
+
+        * UIProcess/Cocoa/MediaPermissionUtilities.mm:
+        (WebKit::requestAVCaptureAccessForType):
+        (WebKit::requestSpeechRecognitionAccess):
+
 2021-01-14  Sihui Liu  <[email protected]>
 
         Update buttons of media permission prompt on macOS

Modified: trunk/Source/WebKit/UIProcess/Cocoa/MediaPermissionUtilities.mm (271485 => 271486)


--- trunk/Source/WebKit/UIProcess/Cocoa/MediaPermissionUtilities.mm	2021-01-14 17:15:03 UTC (rev 271485)
+++ trunk/Source/WebKit/UIProcess/Cocoa/MediaPermissionUtilities.mm	2021-01-14 17:17:32 UTC (rev 271486)
@@ -216,13 +216,8 @@
 
     AVMediaType mediaType = type == MediaPermissionType::Audio ? AVMediaTypeAudio : AVMediaTypeVideo;
     auto decisionHandler = makeBlockPtr([completionHandler = WTFMove(completionHandler)](BOOL authorized) mutable {
-        if (isMainThread()) {
+        callOnMainRunLoop([completionHandler = WTFMove(completionHandler), authorized]() mutable {
             completionHandler(authorized);
-            return;
-        }
-
-        callOnMainThread([completionHandler = WTFMove(completionHandler), authorized]() mutable {
-            completionHandler(authorized);
         });
     });
     [PAL::getAVCaptureDeviceClass() requestAccessForMediaType:mediaType completionHandler:decisionHandler.get()];
@@ -249,13 +244,9 @@
 
     auto decisionHandler = makeBlockPtr([completionHandler = WTFMove(completionHandler)](SFSpeechRecognizerAuthorizationStatus status) mutable {
         bool authorized = status == SFSpeechRecognizerAuthorizationStatusAuthorized;
-        if (!isMainThread()) {
-            callOnMainThread([completionHandler = WTFMove(completionHandler), authorized]() mutable {
-                completionHandler(authorized);
-            });
-            return;
-        }
-        completionHandler(authorized);
+        callOnMainRunLoop([completionHandler = WTFMove(completionHandler), authorized]() mutable {
+            completionHandler(authorized);
+        });
     });
     [PAL::getSFSpeechRecognizerClass() requestAuthorization:decisionHandler.get()];
 }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to