Bug 236196 - Adjust `platformResetStateToConsistentValues` to avoid grabbing the general pasteboard when possible
Summary: Adjust `platformResetStateToConsistentValues` to avoid grabbing the general p...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Tools / Tests (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Wenson Hsieh
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2022-02-05 20:46 PST by Wenson Hsieh
Modified: 2022-02-06 11:46 PST (History)
8 users (show)

See Also:


Attachments
Patch (15.38 KB, patch)
2022-02-05 21:06 PST, Wenson Hsieh
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Wenson Hsieh 2022-02-05 20:46:40 PST
Make it possible to work around rdar://86327357 by skipping layout tests that time out.
Comment 1 Wenson Hsieh 2022-02-05 21:06:36 PST
Created attachment 451024 [details]
Patch
Comment 2 Wenson Hsieh 2022-02-06 07:39:41 PST
Comment on attachment 451024 [details]
Patch

Thanks for the review!
Comment 3 EWS 2022-02-06 08:15:19 PST
Committed r289169 (246865@main): <https://commits.webkit.org/246865@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 451024 [details].
Comment 4 Radar WebKit Bug Importer 2022-02-06 08:16:17 PST
<rdar://problem/88544615>
Comment 5 Alexey Proskuryakov 2022-02-06 11:40:54 PST
It's great to limit the damage like this.

Are the pasteboardChanged notifications synchronous? A little concerned if this adds more races to the execution.
Comment 6 Wenson Hsieh 2022-02-06 11:46:13 PST
(In reply to Alexey Proskuryakov from comment #5)
> It's great to limit the damage like this.
> 
> Are the pasteboardChanged notifications synchronous? A little concerned if
> this adds more races to the execution.

Indeed they are! (I verified this in a separate test app that calls `-[UIPasteboard setItemProviders:]` and listens for this notification, with logging statements):

```
- (void)viewDidLoad
{
    [super viewDidLoad];

    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(pasteboardChanged:) name:UIPasteboardChangedNotification object:nil];

    __auto_type pasteboard = [UIPasteboard generalPasteboard];
    __auto_type string = [[NSAttributedString alloc] initWithString:@"hello world"];
    __auto_type itemProvider = [[NSItemProvider alloc] initWithObject:string];

    NSLog(@"%@ change count before: %tu", pasteboard, pasteboard.changeCount);
    [pasteboard setItemProviders:@[ itemProvider ]];
    NSLog(@"%@ change count after: %tu", pasteboard, pasteboard.changeCount);
}

- (void)pasteboardChanged:(NSNotification *)notification
{
    NSLog(@"Pasteboard changed!");
}
```

with output:

```
UIPasteboardTest[25500:1935953] <_UIConcretePasteboard: 0x6000026604c0> change count before: 20398
UIPasteboardTest[25500:1935953] Pasteboard changed!
UIPasteboardTest[25500:1935953] <_UIConcretePasteboard: 0x6000026604c0> change count after: 20399
```