⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 283456 in webkit


Ignore:
Timestamp:
Oct 2, 2021, 5:24:58 PM (5 years ago)
Author:
Chris Dumez
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):

Location:
trunk/Source/WebKit
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r283431 r283456  
     12021-10-02  Chris Dumez  <cdumez@apple.com>
     2
     3        REGRESSION (r275455): ASSERTION FAILED: process->hasOneRef() seen with TestWebKitAPI.WKProcessPool.WarmInitialProcess
     4        https://bugs.webkit.org/show_bug.cgi?id=231106
     5
     6        Reviewed by Geoffrey Garen.
     7
     8        r275455 added a dispatch_async() which captures a Ref<> to a WebProcessProxy. This may cause the WebProcessProxy to
     9        outlive its WebProcessPool (prewarmed WebProcessProxies to not ref their WebProcessPool), which is not supported.
     10        We could fix the crash by also capturing a Ref<> to the WebProcessPool in the lambda. However, in this particular
     11        instance, it does not seem useful to extend the lifetime of the WebProcessProxy / WebProcessPool so I opted to use
     12        a WeakPtr.
     13
     14        No new tests, covered by existing API test crashing in debug.
     15
     16        * UIProcess/Cocoa/WebProcessProxyCocoa.mm:
     17        (WebKit::WebProcessProxy::sendAudioComponentRegistrations):
     18
    1192021-10-01  Chris Dumez  <cdumez@apple.com>
    220
  • trunk/Source/WebKit/UIProcess/Cocoa/WebProcessProxyCocoa.mm

    r282889 r283456  
    297297        return;
    298298
    299     dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), [protectedThis = Ref { *this }] () mutable {
     299    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), [weakThis = makeWeakPtr(*this)] () mutable {
    300300        CFDataRef registrations { nullptr };
    301301
     
    305305            return;
    306306
    307         RunLoop::main().dispatch([protectedThis = WTFMove(protectedThis), registrations = adoptCF(registrations)] () mutable {
     307        RunLoop::main().dispatch([weakThis = WTFMove(weakThis), registrations = adoptCF(registrations)] () mutable {
     308            if (!weakThis)
     309                return;
     310
    308311            auto registrationData = WebCore::SharedBuffer::create(registrations.get());
    309             protectedThis->send(Messages::WebProcess::ConsumeAudioComponentRegistrations({ registrationData }), 0);
     312            weakThis->send(Messages::WebProcess::ConsumeAudioComponentRegistrations({ registrationData }), 0);
    310313        });
    311314    });
Note: See TracChangeset for help on using the changeset viewer.