Bug 223094 - Drop some unnecessary RunLoop::isMain() / IsMainRunLoop() checks
Summary: Drop some unnecessary RunLoop::isMain() / IsMainRunLoop() checks
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebCore Misc. (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Chris Dumez
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2021-03-11 14:55 PST by Chris Dumez
Modified: 2021-03-11 19:52 PST (History)
13 users (show)

See Also:


Attachments
Patch (5.89 KB, patch)
2021-03-11 14:56 PST, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (11.87 KB, patch)
2021-03-11 15:12 PST, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (11.87 KB, patch)
2021-03-11 15:57 PST, Chris Dumez
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Chris Dumez 2021-03-11 14:55:17 PST
Drop some unnecessary RunLoop::isMain() / IsMainRunLoop() checks. callOnMainThread() / ensureOnMainRunLoop() take care of calling their lambda synchronously when already on the main runloop.
Comment 1 Chris Dumez 2021-03-11 14:56:59 PST
Created attachment 422975 [details]
Patch
Comment 2 Chris Dumez 2021-03-11 15:00:24 PST
Found some more. Will update the patch.
Comment 3 Chris Dumez 2021-03-11 15:12:01 PST
Created attachment 422978 [details]
Patch
Comment 4 Darin Adler 2021-03-11 15:36:11 PST
Comment on attachment 422978 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=422978&action=review

> Source/WebKit/Platform/IPC/Connection.cpp:933
> +    ensureOnMainRunLoop([this, protectedThis = makeRef(*this), messageName]() mutable {

I slightly prefer the "only capture protectedThis" style, but I guess you like the "capture both" style?

> Source/WebKit/Shared/Plugins/NPObjectProxy.cpp:307
> +        NPObjectProxy* npObjectProxy = toNPObjectProxy(npObject);
> +        delete npObjectProxy;

Better as a one-liner:

    delete toNPObjectProxy(npObject);

> Source/WebKit/WebProcess/Storage/WebServiceWorkerFetchTaskClient.cpp:225
> +    ensureOnMainRunLoop([this, protectedThis = makeRef(*this)] {

Maybe we should just capture the three identifiers and not capture the object at all? Would be nice to not have to worry about reference counting at all.

> Source/WebKit/WebProcess/Storage/WebServiceWorkerFetchTaskClient.cpp:226
> +        if (auto* serviceWorkerThreadProxy = SWContextManager::singleton().serviceWorkerThreadProxy(m_serviceWorkerIdentifier))

Just call the local variable "proxy"?
Comment 5 Chris Dumez 2021-03-11 15:37:54 PST
Comment on attachment 422978 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=422978&action=review

>> Source/WebKit/Platform/IPC/Connection.cpp:933
>> +    ensureOnMainRunLoop([this, protectedThis = makeRef(*this), messageName]() mutable {
> 
> I slightly prefer the "only capture protectedThis" style, but I guess you like the "capture both" style?

Yes, I like capturing this because it makes the code more concise in the lambda.

>> Source/WebKit/Shared/Plugins/NPObjectProxy.cpp:307
>> +        delete npObjectProxy;
> 
> Better as a one-liner:
> 
>     delete toNPObjectProxy(npObject);

OK

>> Source/WebKit/WebProcess/Storage/WebServiceWorkerFetchTaskClient.cpp:225
>> +    ensureOnMainRunLoop([this, protectedThis = makeRef(*this)] {
> 
> Maybe we should just capture the three identifiers and not capture the object at all? Would be nice to not have to worry about reference counting at all.

Good idea, will do.

>> Source/WebKit/WebProcess/Storage/WebServiceWorkerFetchTaskClient.cpp:226
>> +        if (auto* serviceWorkerThreadProxy = SWContextManager::singleton().serviceWorkerThreadProxy(m_serviceWorkerIdentifier))
> 
> Just call the local variable "proxy"?

Ok.
Comment 6 Chris Dumez 2021-03-11 15:57:34 PST
Created attachment 422984 [details]
Patch
Comment 7 EWS 2021-03-11 19:51:33 PST
Committed r274322: <https://commits.webkit.org/r274322>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 422984 [details].
Comment 8 Radar WebKit Bug Importer 2021-03-11 19:52:16 PST
<rdar://problem/75345742>