Changeset 258061 in webkit


Ignore:
Timestamp:
Mar 6, 2020 9:46:09 PM (4 years ago)
Author:
Simon Fraser
Message:

Flaky Test: editing/spelling/spellcheck-async.html
https://bugs.webkit.org/show_bug.cgi?id=160571

Reviewed by Ryosuke Niwa.

Second try to fix this crash; the WebEditorClient can go away before all the NSSpellChecker
callbacks are done (which happens off the main thread), so store a WeakPtr<WebEditorClient>.
We have to create the WeakPtr on the main thread, and it gets copied into the first block.

  • WebCoreSupport/WebEditorClient.mm:

(-[WebEditorSpellCheckResponder initWithClient:sequence:results:]):
(-[WebEditorSpellCheckResponder perform]):
(WebEditorClient::requestCheckingOfString):

Location:
trunk/Source/WebKitLegacy/mac
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKitLegacy/mac/ChangeLog

    r258048 r258061  
     12020-03-06  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Flaky Test: editing/spelling/spellcheck-async.html
     4        https://bugs.webkit.org/show_bug.cgi?id=160571
     5
     6        Reviewed by Ryosuke Niwa.
     7       
     8        Second try to fix this crash; the WebEditorClient can go away before all the NSSpellChecker
     9        callbacks are done (which happens off the main thread), so store a WeakPtr<WebEditorClient>.
     10        We have to create the WeakPtr on the main thread, and it gets copied into the first block.
     11
     12        * WebCoreSupport/WebEditorClient.mm:
     13        (-[WebEditorSpellCheckResponder initWithClient:sequence:results:]):
     14        (-[WebEditorSpellCheckResponder perform]):
     15        (WebEditorClient::requestCheckingOfString):
     16
    1172020-03-06  Simon Fraser  <simon.fraser@apple.com>
    218
  • trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebEditorClient.mm

    r258048 r258061  
    12121212@interface WebEditorSpellCheckResponder : NSObject
    12131213{
    1214     WebEditorClient* _client;
     1214    WeakPtr<WebEditorClient> _client;
    12151215    int _sequence;
    12161216    RetainPtr<NSArray> _results;
    12171217}
    1218 - (id)initWithClient:(WebEditorClient*)client sequence:(int)sequence results:(NSArray*)results;
     1218- (id)initWithClient:(WeakPtr<WebEditorClient>)client sequence:(int)sequence results:(NSArray*)results;
    12191219- (void)perform;
    12201220@end
    12211221
    12221222@implementation WebEditorSpellCheckResponder
    1223 - (id)initWithClient:(WebEditorClient*)client sequence:(int)sequence results:(NSArray*)results
     1223- (id)initWithClient:(WeakPtr<WebEditorClient>)client sequence:(int)sequence results:(NSArray*)results
    12241224{
    12251225    self = [super init];
     
    12341234- (void)perform
    12351235{
    1236     _client->didCheckSucceed(_sequence, _results.get());
     1236    if (_client)
     1237        _client->didCheckSucceed(_sequence, _results.get());
    12371238}
    12381239
     
    12571258    NSRange range = NSMakeRange(0, m_textCheckingRequest->data().text().length());
    12581259    NSRunLoop* currentLoop = [NSRunLoop currentRunLoop];
     1260    WeakPtr<WebEditorClient> weakThis = makeWeakPtr(*this);
    12591261    NSDictionary *options = @{ NSTextCheckingInsertionPointKey :  [NSNumber numberWithUnsignedInteger:insertionPointFromCurrentSelection(currentSelection)] };
    12601262    [[NSSpellChecker sharedSpellChecker] requestCheckingOfString:m_textCheckingRequest->data().text() range:range types:NSTextCheckingAllSystemTypes options:options inSpellDocumentWithTag:0 completionHandler:^(NSInteger, NSArray* results, NSOrthography*, NSInteger) {
    1261         RetainPtr<WebEditorSpellCheckResponder> responder = adoptNS([[WebEditorSpellCheckResponder alloc] initWithClient:this sequence:sequence results:results]);
     1263        RetainPtr<WebEditorSpellCheckResponder> responder = adoptNS([[WebEditorSpellCheckResponder alloc] initWithClient:weakThis sequence:sequence results:results]);
    12621264        [currentLoop performBlock:^{
    12631265            [responder perform];
Note: See TracChangeset for help on using the changeset viewer.