Bug 213950

Summary: [macOS] Tests that show system menu popups may fail when run concurrently
Product: WebKit Reporter: Wenson Hsieh <wenson_hsieh>
Component: Tools / TestsAssignee: Wenson Hsieh <wenson_hsieh>
Status: RESOLVED FIXED    
Severity: Normal CC: darin, dino, hi, megan_gardner, thorton, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
For EWS
darin: review+
Remove NeverDestroyed. none

Description Wenson Hsieh 2020-07-03 20:16:28 PDT
<rdar://problem/64551566>
Comment 1 Wenson Hsieh 2020-07-03 20:34:22 PDT
Created attachment 403505 [details]
For EWS
Comment 2 Darin Adler 2020-07-03 21:14:58 PDT
Comment on attachment 403505 [details]
For EWS

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

> Tools/WebKitTestRunner/mac/TestControllerMac.mm:134
> +    static NeverDestroyed<InstanceMethodSwizzler> cancelTrackingSwizzler { NSMenu.class, @selector(cancelTracking), reinterpret_cast<IMP>(swizzledCancelTracking) };
> +    static NeverDestroyed<ClassMethodSwizzler> menuPopUpSwizzler { NSMenu.class, @selector(popUpContextMenu:withEvent:forView:), reinterpret_cast<IMP>(swizzledPopUpContextMenu) };
> +    static NeverDestroyed<InstanceMethodSwizzler> carbonMenuPopUpSwizzler {

Do these really need NeverDestroyed? Maybe they would with ARC, but I don’t see why they need it without ARC. Keep in mind that NeverDestroyed does not make something stay alive for the duration of execution: being a global makes that happen. NeverDestroyed simply prevents the destructor from being called, which is useful for such objects if they have destructors.
Comment 3 Wenson Hsieh 2020-07-03 21:54:00 PDT
Comment on attachment 403505 [details]
For EWS

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

>> Tools/WebKitTestRunner/mac/TestControllerMac.mm:134
>> +    static NeverDestroyed<InstanceMethodSwizzler> carbonMenuPopUpSwizzler {
> 
> Do these really need NeverDestroyed? Maybe they would with ARC, but I don’t see why they need it without ARC. Keep in mind that NeverDestroyed does not make something stay alive for the duration of execution: being a global makes that happen. NeverDestroyed simply prevents the destructor from being called, which is useful for such objects if they have destructors.

That's a good point — the `NeverDestroyed<>` doesn't add anything here.

I changed these into just `static InstanceMethodSwizzler …` and `static ClassMethodSwizzler …`.
Comment 4 Wenson Hsieh 2020-07-03 21:58:07 PDT
Created attachment 403507 [details]
Remove NeverDestroyed.
Comment 5 EWS 2020-07-03 23:38:57 PDT
Committed r263929: <https://trac.webkit.org/changeset/263929>

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