Title: [283456] trunk/Source/WebKit
Revision
283456
Author
[email protected]
Date
2021-10-02 17:24:58 -0700 (Sat, 02 Oct 2021)

Log Message

REGRESSION (r275455): ASSERTION FAILED: process->hasOneRef() seen with TestWebKitAPI.WKProcessPool.WarmInitialProcess
https://bugs.webkit.org/show_bug.cgi?id=231106

Reviewed by Geoffrey Garen.

r275455 added a dispatch_async() which captures a Ref<> to a WebProcessProxy. This may cause the WebProcessProxy to
outlive its WebProcessPool (prewarmed WebProcessProxies to not ref their WebProcessPool), which is not supported.
We could fix the crash by also capturing a Ref<> to the WebProcessPool in the lambda. However, in this particular
instance, it does not seem useful to extend the lifetime of the WebProcessProxy / WebProcessPool so I opted to use
a WeakPtr.

No new tests, covered by existing API test crashing in debug.

* UIProcess/Cocoa/WebProcessProxyCocoa.mm:
(WebKit::WebProcessProxy::sendAudioComponentRegistrations):

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (283455 => 283456)


--- trunk/Source/WebKit/ChangeLog	2021-10-02 22:54:00 UTC (rev 283455)
+++ trunk/Source/WebKit/ChangeLog	2021-10-03 00:24:58 UTC (rev 283456)
@@ -1,3 +1,21 @@
+2021-10-02  Chris Dumez  <[email protected]>
+
+        REGRESSION (r275455): ASSERTION FAILED: process->hasOneRef() seen with TestWebKitAPI.WKProcessPool.WarmInitialProcess
+        https://bugs.webkit.org/show_bug.cgi?id=231106
+
+        Reviewed by Geoffrey Garen.
+
+        r275455 added a dispatch_async() which captures a Ref<> to a WebProcessProxy. This may cause the WebProcessProxy to
+        outlive its WebProcessPool (prewarmed WebProcessProxies to not ref their WebProcessPool), which is not supported.
+        We could fix the crash by also capturing a Ref<> to the WebProcessPool in the lambda. However, in this particular
+        instance, it does not seem useful to extend the lifetime of the WebProcessProxy / WebProcessPool so I opted to use
+        a WeakPtr.
+
+        No new tests, covered by existing API test crashing in debug.
+
+        * UIProcess/Cocoa/WebProcessProxyCocoa.mm:
+        (WebKit::WebProcessProxy::sendAudioComponentRegistrations):
+
 2021-10-01  Chris Dumez  <[email protected]>
 
         Drop support for macOS < 10.15

Modified: trunk/Source/WebKit/UIProcess/Cocoa/WebProcessProxyCocoa.mm (283455 => 283456)


--- trunk/Source/WebKit/UIProcess/Cocoa/WebProcessProxyCocoa.mm	2021-10-02 22:54:00 UTC (rev 283455)
+++ trunk/Source/WebKit/UIProcess/Cocoa/WebProcessProxyCocoa.mm	2021-10-03 00:24:58 UTC (rev 283456)
@@ -296,7 +296,7 @@
     if (!PAL::isAudioToolboxCoreFrameworkAvailable() || !PAL::canLoad_AudioToolboxCore_AudioComponentFetchServerRegistrations())
         return;
 
-    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), [protectedThis = Ref { *this }] () mutable {
+    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), [weakThis = makeWeakPtr(*this)] () mutable {
         CFDataRef registrations { nullptr };
 
         WebCore::registerOpusDecoderIfNeeded();
@@ -304,9 +304,12 @@
         if (noErr != AudioComponentFetchServerRegistrations(&registrations) || !registrations)
             return;
 
-        RunLoop::main().dispatch([protectedThis = WTFMove(protectedThis), registrations = adoptCF(registrations)] () mutable {
+        RunLoop::main().dispatch([weakThis = WTFMove(weakThis), registrations = adoptCF(registrations)] () mutable {
+            if (!weakThis)
+                return;
+
             auto registrationData = WebCore::SharedBuffer::create(registrations.get());
-            protectedThis->send(Messages::WebProcess::ConsumeAudioComponentRegistrations({ registrationData }), 0);
+            weakThis->send(Messages::WebProcess::ConsumeAudioComponentRegistrations({ registrationData }), 0);
         });
     });
 }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to