| Summary: | Adjust `platformResetStateToConsistentValues` to avoid grabbing the general pasteboard when possible | ||||||
|---|---|---|---|---|---|---|---|
| Product: | WebKit | Reporter: | Wenson Hsieh <wenson_hsieh> | ||||
| Component: | Tools / Tests | Assignee: | Wenson Hsieh <wenson_hsieh> | ||||
| Status: | RESOLVED FIXED | ||||||
| Severity: | Normal | CC: | akeerthi, bdakin, darin, megan_gardner, ryanhaddad, thorton, webkit-bot-watchers-bugzilla, webkit-bug-importer | ||||
| Priority: | P2 | Keywords: | InRadar | ||||
| Version: | WebKit Nightly Build | ||||||
| Hardware: | Unspecified | ||||||
| OS: | Unspecified | ||||||
| Attachments: |
|
||||||
|
Description
Wenson Hsieh
2022-02-05 20:46:40 PST
Created attachment 451024 [details]
Patch
Comment on attachment 451024 [details]
Patch
Thanks for the review!
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]. 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. (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 ``` |