Bug 203001 - [macOS] Simplify main thread initialization
Summary: [macOS] Simplify main thread initialization
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Template Framework (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Chris Dumez
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2019-10-15 12:18 PDT by Chris Dumez
Modified: 2019-10-15 16:35 PDT (History)
11 users (show)

See Also:


Attachments
Patch (27.85 KB, patch)
2019-10-15 12:31 PDT, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (27.19 KB, patch)
2019-10-15 12:36 PDT, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (27.42 KB, patch)
2019-10-15 14:54 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 2019-10-15 12:18:08 PDT
Simplify main thread initialization on macOS by always using pthread main as main thread.
Comment 1 Chris Dumez 2019-10-15 12:31:47 PDT
Created attachment 381011 [details]
Patch
Comment 2 Chris Dumez 2019-10-15 12:36:12 PDT
Created attachment 381012 [details]
Patch
Comment 3 Geoffrey Garen 2019-10-15 13:56:05 PDT
Comment on attachment 381012 [details]
Patch

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

r=me

> Source/WTF/ChangeLog:10
> +

Probably worth mentioning that this change also enables the new white box ASSERT that we don't initialize main thread to some other thread.

> Source/WebKitLegacy/mac/Misc/WebCache.mm:-68
>      JSC::initializeThreading();
> -    WTF::initializeMainThreadToProcessMainThread();

In cases like this, is it OK to call JSC::initializeThreading() and not WTF::initializeMainThreadToProcessMainThread
Comment 4 Geoffrey Garen 2019-10-15 14:07:43 PDT
> > Source/WebKitLegacy/mac/Misc/WebCache.mm:-68
> >      JSC::initializeThreading();
> > -    WTF::initializeMainThreadToProcessMainThread();
> 
> In cases like this, is it OK to call JSC::initializeThreading() and not
> WTF::initializeMainThreadToProcessMainThread

I verified that JSC::initializeThreading(); calls WTF::initializeThreading(), so it's OK.
Comment 5 Chris Dumez 2019-10-15 14:51:32 PDT
Comment on attachment 381012 [details]
Patch

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

>> Source/WTF/ChangeLog:10
>> +
> 
> Probably worth mentioning that this change also enables the new white box ASSERT that we don't initialize main thread to some other thread.

Will add.

>> Source/WebKitLegacy/mac/Misc/WebCache.mm:-68
>> -    WTF::initializeMainThreadToProcessMainThread();
> 
> In cases like this, is it OK to call JSC::initializeThreading() and not WTF::initializeMainThreadToProcessMainThread

I dropped it because RunLoop::initializeMainRunLoop() below calls WTF::initializeMainThread(); With my change, WTF::initializeMainThread() became identical to WTF::initializeMainThreadToProcessMainThread() so I dropped the latter.
Comment 6 Chris Dumez 2019-10-15 14:54:55 PDT
Created attachment 381026 [details]
Patch
Comment 7 WebKit Commit Bot 2019-10-15 15:44:03 PDT
Comment on attachment 381026 [details]
Patch

Clearing flags on attachment: 381026

Committed r251164: <https://trac.webkit.org/changeset/251164>
Comment 8 WebKit Commit Bot 2019-10-15 15:44:05 PDT
All reviewed patches have been landed.  Closing bug.
Comment 9 Ryosuke Niwa 2019-10-15 16:05:33 PDT
This patch broke builds:

ld: warning: directory not found for option '-F/Volumes/Data/slave/highsierra-debug/build/Tools/TestWebKitAPI/../../WebKitLibraries/WebKitPrivateFrameworkStubs/Mac/101300'
Undefined symbols for architecture x86_64:
  "WTF::isMainThreadIfInitialized()", referenced from:
      WTF::RefCountedBase::applyRefDerefThreadingCheck() const in libTestWebKitAPI.a(EnvironmentUtilitiesTest.o)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Not sure why EWS didn't catch it.
Comment 10 Ryosuke Niwa 2019-10-15 16:07:44 PDT
Hm... I wonder if we just need a clean build?
Comment 11 Chris Dumez 2019-10-15 16:16:52 PDT
(In reply to Ryosuke Niwa from comment #10)
> Hm... I wonder if we just need a clean build?

Sounds likely.
Comment 12 Ryosuke Niwa 2019-10-15 16:34:51 PDT
(In reply to Chris Dumez from comment #11)
> (In reply to Ryosuke Niwa from comment #10)
> > Hm... I wonder if we just need a clean build?
> 
> Sounds likely.

Indeed, clean build fixed the issue for me.
Comment 13 Radar WebKit Bug Importer 2019-10-15 16:35:04 PDT
<rdar://problem/56313281>