Bug 213689 - Fix thread-safety issue in webProcessPoolHighDynamicRangeDidChangeCallback()
Summary: Fix thread-safety issue in webProcessPoolHighDynamicRangeDidChangeCallback()
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit2 (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Chris Dumez
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2020-06-27 17:47 PDT by Chris Dumez
Modified: 2020-06-28 14:34 PDT (History)
5 users (show)

See Also:


Attachments
Patch (2.17 KB, patch)
2020-06-27 17:50 PDT, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (2.13 KB, patch)
2020-06-28 13:47 PDT, 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 2020-06-27 17:47:59 PDT
Fix thread-safety issue in webProcessPoolHighDynamicRangeDidChangeCallback().
Comment 1 Chris Dumez 2020-06-27 17:48:15 PDT
<rdar://problem/64443996>
Comment 2 Chris Dumez 2020-06-27 17:50:30 PDT
Created attachment 402976 [details]
Patch
Comment 3 Darin Adler 2020-06-28 13:23:51 PDT
Comment on attachment 402976 [details]
Patch

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

> Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm:906
> +    dispatch_async(dispatch_get_main_queue(), ^{

Just curious: why did you select dispatch to the main queue over other techniques for running on the main thread?

> Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm:907
> +        auto screenProperties = WebCore::collectScreenProperties();

In a small function/tight context like this, I like just using one word names, like "properties" here.

> Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm:908
> +        for (auto& processPool : WebProcessPool::allProcessPools())

And "pool" here.
Comment 4 Chris Dumez 2020-06-28 13:28:22 PDT
(In reply to Darin Adler from comment #3)
> Comment on attachment 402976 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=402976&action=review
> 
> > Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm:906
> > +    dispatch_async(dispatch_get_main_queue(), ^{
> 
> Just curious: why did you select dispatch to the main queue over other
> techniques for running on the main thread?

I am in a .mm file so I can use dispatch_async(). Dispatch_async() has the benefit of not requiring any “main thread / run loop initialization” and work always. I recently tried to fix a similar bug with RunLoop dispatch and it caused crashes in the api tests because the main runloop was not initialized yet.

> > Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm:907
> > +        auto screenProperties = WebCore::collectScreenProperties();
> 
> In a small function/tight context like this, I like just using one word
> names, like "properties" here.
> 
> > Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm:908
> > +        for (auto& processPool : WebProcessPool::allProcessPools())
> 
> And "pool" here.
Comment 5 Chris Dumez 2020-06-28 13:47:13 PDT
Created attachment 403008 [details]
Patch
Comment 6 EWS 2020-06-28 14:34:25 PDT
Committed r263636: <https://trac.webkit.org/changeset/263636>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 403008 [details].