Bug 233967 - Add a version of ThreadAssertions that treats UI and Web thread as the same
Summary: Add a version of ThreadAssertions that treats UI and Web thread as the same
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Template Framework (show other bugs)
Version: WebKit Local Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Cameron McCormack (:heycam)
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2021-12-07 18:55 PST by Cameron McCormack (:heycam)
Modified: 2021-12-14 18:56 PST (History)
8 users (show)

See Also:


Attachments
Patch (2.22 KB, patch)
2021-12-07 18:56 PST, Cameron McCormack (:heycam)
no flags Details | Formatted Diff | Diff
Patch (4.00 KB, patch)
2021-12-07 20:14 PST, Cameron McCormack (:heycam)
kkinnunen: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Cameron McCormack (:heycam) 2021-12-07 18:55:32 PST
ThreadAssertions has so far been used exclusively within WebCore.  Since WebCore rarely needs to distinguish between the UI thread and the Web thread, make ThreadAssertions treat them the same so that it can be used in situations where objects are interacted with in both.
Comment 1 Cameron McCormack (:heycam) 2021-12-07 18:56:24 PST
Created attachment 446277 [details]
Patch
Comment 2 Cameron McCormack (:heycam) 2021-12-07 18:59:10 PST
(In reply to Cameron McCormack (:heycam) from comment #0)
> ThreadAssertions has so far been used exclusively within WebCore.

That is completely false; it's been used exclusively within WebKit.  Perhaps ThreadAssertions needs an option to choose whether to use isMainThread() for main thread checking.
Comment 3 Cameron McCormack (:heycam) 2021-12-07 20:13:32 PST
I thought I'd templatize ThreadAssertion with a parameter that indicates whether to use isMainThread() to check for main-threadedness, but that seemed to confuse clang into thinking the relevant capability was not acquired.

Forthcoming patch just duplicates the ThreadAssertion class with this different behavior.  Comments on a better name welcome.
Comment 4 Cameron McCormack (:heycam) 2021-12-07 20:14:02 PST
Created attachment 446283 [details]
Patch
Comment 5 Kimmo Kinnunen 2021-12-07 22:23:05 PST
Comment on attachment 446283 [details]
Patch

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

> Source/WTF/wtf/ThreadAssertions.h:130
>  

would mainThread named assertion work for you instead?
example in ThreadAssertionsTest.cpp
Comment 6 Kimmo Kinnunen 2021-12-07 22:35:35 PST
Comment on attachment 446283 [details]
Patch

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

> Source/WTF/wtf/ThreadAssertions.h:76
> +class WTF_CAPABILITY_LOCK MainOrOtherThreadAssertion {

Could you name it as "SequenceAssertion".
E.g. a "sequence" is a ..sequence.. where actions happen serially. (As implemented by a work queue, or gcd queue)
Comment 7 Radar WebKit Bug Importer 2021-12-14 18:56:15 PST
<rdar://problem/86501473>