Bug 233749

Summary: move shouldAutoActivateFontIfNeeded knownFamilies cache to FontCache
Product: WebKit Reporter: Cameron McCormack (:heycam) <heycam>
Component: Layout and RenderingAssignee: Cameron McCormack (:heycam) <heycam>
Status: RESOLVED FIXED    
Severity: Normal CC: bfulgham, cdumez, esprehn+autocc, ews-watchlist, glenn, gyuyoung.kim, hi, joepeck, kangil.han, macpherson, menard, mifenton, mmaxfield, pangle, simon.fraser, webkit-bug-importer, zalan
Priority: P2 Keywords: InRadar
Version: WebKit Local Build   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on: 233747    
Bug Blocks: 233488    
Attachments:
Description Flags
Patch with dependencies for EWS
none
Patch
mmaxfield: review+, ews-feeder: commit-queue-
[fast-cq] Patch for landing none

Description Cameron McCormack (:heycam) 2021-12-01 23:09:30 PST
With OffscreenCanvas, we can call shouldAutoActivateFontIfNeeded on a worker thread, and the knownFamilies HashSet is not thread safe. Also, the AtomStrings it stores are thread-specific. Move it to FontCache, so each thread has its own set.
Comment 1 Cameron McCormack (:heycam) 2021-12-01 23:10:38 PST
Created attachment 445675 [details]
Patch with dependencies for EWS
Comment 2 Cameron McCormack (:heycam) 2021-12-01 23:11:56 PST
Created attachment 445676 [details]
Patch
Comment 3 Myles C. Maxfield 2021-12-07 00:47:12 PST
Comment on attachment 445676 [details]
Patch

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

Good idea.

> Source/WebCore/platform/graphics/FontCache.h:378
> +#if PLATFORM(MAC)

I think generally our policy is to only ifdef function definitions, not declarations (just to reduce visual noise).
Comment 4 Myles C. Maxfield 2021-12-07 00:47:54 PST
It's probably worth investigating whether this cache actually saves us any perf at all.
Comment 5 Cameron McCormack (:heycam) 2021-12-07 13:16:15 PST
(In reply to Myles C. Maxfield from comment #3)
> I think generally our policy is to only ifdef function definitions, not
> declarations (just to reduce visual noise).

OK.  I guess it would need to be #ifdefed it were using some platform-specific type (and we didn't already have a typedef pointing to the platform-specific type we could use).

There is some benefit from the #ifdef, which is to point out to the reader that these are indeed only available on some platform/configuration, but maybe they can just discover that themselves when they try to call the function and it's not defined everywhere.
Comment 6 EWS 2021-12-07 17:09:46 PST
/Volumes/Data/worker/Commit-Queue/build/Source/WebCore/ChangeLog neither lists a valid reviewer nor contains the string "Unreviewed" or "Rubber stamp" (case insensitive).
Comment 7 Cameron McCormack (:heycam) 2021-12-07 17:18:58 PST
Created attachment 446261 [details]
[fast-cq] Patch for landing
Comment 8 EWS 2021-12-07 17:36:57 PST
Committed r286634 (?): <https://commits.webkit.org/r286634>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 446261 [details].
Comment 9 Radar WebKit Bug Importer 2021-12-07 17:38:41 PST
<rdar://problem/86185239>