Changeset 233432 in webkit


Ignore:
Timestamp:
Jul 2, 2018 1:52:18 PM (6 years ago)
Author:
beidson@apple.com
Message:

Crash notifying observers of responsiveness state change
<rdar://problem/41267796> and https://bugs.webkit.org/show_bug.cgi?id=187262

Reviewed by Tim Horton.

Source/WebKit:

  • UIProcess/PageLoadState.cpp:

(WebKit::PageLoadState::callObserverCallback): Copy the container ahead of time.

Tools:

  • TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
  • TestWebKitAPI/Tests/WebKit/ResponsivenessTimerCrash.mm: Added.

(-[RTObserver observeValueForKeyPath:ofObject:change:context:]):
(TestWebKitAPI::TEST):

  • TestWebKitAPI/cocoa/TestWKWebView.h:
  • TestWebKitAPI/cocoa/TestWKWebView.mm:

(-[TestWKWebView typeCharacter:]):
(-[TestWKWebView hostWindow]):

Location:
trunk
Files:
1 added
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r233431 r233432  
     12018-07-02  Brady Eidson  <beidson@apple.com>
     2
     3        Crash notifying observers of responsiveness state change
     4        <rdar://problem/41267796> and https://bugs.webkit.org/show_bug.cgi?id=187262
     5
     6        Reviewed by Tim Horton.
     7
     8        * UIProcess/PageLoadState.cpp:
     9        (WebKit::PageLoadState::callObserverCallback): Copy the container ahead of time.
     10
    1112018-07-02  Sihui Liu  <sihui_liu@apple.com>
    212
  • trunk/Source/WebKit/UIProcess/PageLoadState.cpp

    r216132 r233432  
    420420void PageLoadState::callObserverCallback(void (Observer::*callback)())
    421421{
    422     for (auto* observer : m_observers)
     422    auto protectedPage = makeRef(m_webPageProxy);
     423
     424    auto observerCopy = m_observers;
     425    for (auto* observer : observerCopy) {
     426        // This appears potentially inefficient on the surface (searching in a Vector)
     427        // but in practice - using only API - there will only ever be (1) observer.
     428        if (!m_observers.contains(observer))
     429            continue;
     430
    423431        (observer->*callback)();
     432    }
    424433}
    425434
  • trunk/Tools/ChangeLog

    r233428 r233432  
     12018-07-02  Brady Eidson  <beidson@apple.com>
     2
     3        Crash notifying observers of responsiveness state change
     4        <rdar://problem/41267796> and https://bugs.webkit.org/show_bug.cgi?id=187262
     5
     6        Reviewed by Tim Horton.
     7
     8        * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
     9        * TestWebKitAPI/Tests/WebKit/ResponsivenessTimerCrash.mm: Added.
     10        (-[RTObserver observeValueForKeyPath:ofObject:change:context:]):
     11        (TestWebKitAPI::TEST):
     12        * TestWebKitAPI/cocoa/TestWKWebView.h:
     13        * TestWebKitAPI/cocoa/TestWKWebView.mm:
     14        (-[TestWKWebView typeCharacter:]):
     15        (-[TestWKWebView hostWindow]):
     16
    1172018-07-02  Michael Catanzaro  <mcatanzaro@igalia.com>
    218
  • trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj

    r233374 r233432  
    178178                5120C83D1E6751290025B250 /* WebsiteDataStoreCustomPaths.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5120C83C1E6750790025B250 /* WebsiteDataStoreCustomPaths.mm */; };
    179179                5120C83E1E67678F0025B250 /* WebsiteDataStoreCustomPaths.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 5120C83B1E674E350025B250 /* WebsiteDataStoreCustomPaths.html */; };
     180                512C4C9E20EAA40D004945EA /* ResponsivenessTimerCrash.mm in Sources */ = {isa = PBXBuildFile; fileRef = 512C4C9D20EAA405004945EA /* ResponsivenessTimerCrash.mm */; };
    180181                51393E221523952D005F39C5 /* DOMWindowExtensionBasic_Bundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 51393E1D1523944A005F39C5 /* DOMWindowExtensionBasic_Bundle.cpp */; };
    181182                5142B2731517C8C800C32B19 /* ContextMenuCanCopyURL.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 5142B2721517C89100C32B19 /* ContextMenuCanCopyURL.html */; };
     
    14021403                5120C83B1E674E350025B250 /* WebsiteDataStoreCustomPaths.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = WebsiteDataStoreCustomPaths.html; sourceTree = "<group>"; };
    14031404                5120C83C1E6750790025B250 /* WebsiteDataStoreCustomPaths.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebsiteDataStoreCustomPaths.mm; sourceTree = "<group>"; };
     1405                512C4C9D20EAA405004945EA /* ResponsivenessTimerCrash.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ResponsivenessTimerCrash.mm; sourceTree = "<group>"; };
    14041406                51393E1D1523944A005F39C5 /* DOMWindowExtensionBasic_Bundle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DOMWindowExtensionBasic_Bundle.cpp; sourceTree = "<group>"; };
    14051407                51393E1E1523944A005F39C5 /* DOMWindowExtensionBasic.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DOMWindowExtensionBasic.cpp; sourceTree = "<group>"; };
     
    28052807                                8A2C750D16CED9550024F352 /* ResizeWindowAfterCrash.cpp */,
    28062808                                83DE134C1EF1C4FE00C1B355 /* ResponsivenessTimer.cpp */,
     2809                                512C4C9D20EAA405004945EA /* ResponsivenessTimerCrash.mm */,
    28072810                                C0BD669C131D3CF700E18F2A /* ResponsivenessTimerDoesntFireEarly.cpp */,
    28082811                                C0BD669E131D3CFF00E18F2A /* ResponsivenessTimerDoesntFireEarly_Bundle.cpp */,
     
    36943697                                7CCE7EDF1A411A9200447C4C /* LayoutUnit.cpp in Sources */,
    36953698                                7A66BDB61EAF14EF00CCC924 /* LimitTitleSize.cpp in Sources */,
     3699                                512C4C9E20EAA40D004945EA /* ResponsivenessTimerCrash.mm in Sources */,
    36963700                                7A7B0E7F1EAFE4C3006AB8AE /* LimitTitleSize.mm in Sources */,
    36973701                                C25CCA061E51380B0026CB8A /* LineBreaking.mm in Sources */,
  • trunk/Tools/TestWebKitAPI/cocoa/TestWKWebView.h

    r229542 r233432  
    5858- (void)performAfterLoading:(dispatch_block_t)actions;
    5959- (void)waitForNextPresentationUpdate;
     60- (void)typeCharacter:(char)character;
    6061@end
    6162
     
    7576- (void)mouseMoveToPoint:(NSPoint)point withFlags:(NSEventModifierFlags)flags;
    7677- (void)sendClicksAtPoint:(NSPoint)point numberOfClicks:(NSUInteger)numberOfClicks;
    77 - (void)typeCharacter:(char)character;
    7878- (NSWindow *)hostWindow;
    7979@end
  • trunk/Tools/TestWebKitAPI/cocoa/TestWKWebView.mm

    r231663 r233432  
    312312}
    313313
    314 @end
    315 
    316 #if PLATFORM(IOS)
    317 
    318 @implementation TestWKWebView (IOSOnly)
    319 
    320 - (UIView <UITextInput> *)textInputContentView
    321 {
    322     return (UIView <UITextInput> *)[self valueForKey:@"_currentContentView"];
    323 }
    324 
    325 - (RetainPtr<NSArray>)selectionRectsAfterPresentationUpdate
    326 {
    327     RetainPtr<TestWKWebView> retainedSelf = self;
    328 
    329     __block bool isDone = false;
    330     __block RetainPtr<NSArray> selectionRects;
    331     [self _doAfterNextPresentationUpdate:^() {
    332         selectionRects = adoptNS([[retainedSelf _uiTextSelectionRects] retain]);
    333         isDone = true;
    334     }];
    335 
    336     TestWebKitAPI::Util::run(&isDone);
    337     return selectionRects;
    338 }
    339 
    340 - (_WKActivatedElementInfo *)activatedElementAtPosition:(CGPoint)position
    341 {
    342     __block RetainPtr<_WKActivatedElementInfo> info;
    343     __block bool finished = false;
    344     [self _requestActivatedElementAtPosition:position completionBlock:^(_WKActivatedElementInfo *elementInfo) {
    345         info = elementInfo;
    346         finished = true;
    347     }];
    348 
    349     TestWebKitAPI::Util::run(&finished);
    350     return info.autorelease();
    351 }
    352 
    353 @end
    354 
    355 #endif
    356 
    357 #if PLATFORM(MAC)
    358 @implementation TestWKWebView (MacOnly)
    359 - (void)mouseDownAtPoint:(NSPoint)point simulatePressure:(BOOL)simulatePressure
    360 {
    361     [_hostWindow _mouseDownAtPoint:point simulatePressure:simulatePressure clickCount:1];
    362 }
    363 
    364 - (void)mouseUpAtPoint:(NSPoint)point
    365 {
    366     [_hostWindow _mouseUpAtPoint:point clickCount:1];
    367 }
    368 
    369 - (void)mouseMoveToPoint:(NSPoint)point withFlags:(NSEventModifierFlags)flags
    370 {
    371     [self mouseMoved:[NSEvent mouseEventWithType:NSEventTypeMouseMoved location:point modifierFlags:flags timestamp:GetCurrentEventTime() windowNumber:[_hostWindow windowNumber] context:[NSGraphicsContext currentContext] eventNumber:++gEventNumber clickCount:0 pressure:0]];
    372 }
    373 
    374 - (void)sendClicksAtPoint:(NSPoint)point numberOfClicks:(NSUInteger)numberOfClicks
    375 {
    376     for (NSUInteger clickCount = 1; clickCount <= numberOfClicks; ++clickCount) {
    377         [_hostWindow _mouseDownAtPoint:point simulatePressure:NO clickCount:clickCount];
    378         [_hostWindow _mouseUpAtPoint:point clickCount:clickCount];
    379     }
    380 }
    381 
    382 - (NSWindow *)hostWindow
    383 {
    384     return _hostWindow.get();
    385 }
    386 
    387314- (void)typeCharacter:(char)character {
    388315    NSString *characterAsString = [NSString stringWithFormat:@"%c" , character];
     
    392319    [self keyUp:[NSEvent keyEventWithType:keyUpEventType location:NSZeroPoint modifierFlags:0 timestamp:GetCurrentEventTime() windowNumber:[_hostWindow windowNumber] context:nil characters:characterAsString charactersIgnoringModifiers:characterAsString isARepeat:NO keyCode:character]];
    393320}
     321
     322@end
     323
     324#if PLATFORM(IOS)
     325
     326@implementation TestWKWebView (IOSOnly)
     327
     328- (UIView <UITextInput> *)textInputContentView
     329{
     330    return (UIView <UITextInput> *)[self valueForKey:@"_currentContentView"];
     331}
     332
     333- (RetainPtr<NSArray>)selectionRectsAfterPresentationUpdate
     334{
     335    RetainPtr<TestWKWebView> retainedSelf = self;
     336
     337    __block bool isDone = false;
     338    __block RetainPtr<NSArray> selectionRects;
     339    [self _doAfterNextPresentationUpdate:^() {
     340        selectionRects = adoptNS([[retainedSelf _uiTextSelectionRects] retain]);
     341        isDone = true;
     342    }];
     343
     344    TestWebKitAPI::Util::run(&isDone);
     345    return selectionRects;
     346}
     347
     348- (_WKActivatedElementInfo *)activatedElementAtPosition:(CGPoint)position
     349{
     350    __block RetainPtr<_WKActivatedElementInfo> info;
     351    __block bool finished = false;
     352    [self _requestActivatedElementAtPosition:position completionBlock:^(_WKActivatedElementInfo *elementInfo) {
     353        info = elementInfo;
     354        finished = true;
     355    }];
     356
     357    TestWebKitAPI::Util::run(&finished);
     358    return info.autorelease();
     359}
     360
     361@end
     362
     363#endif
     364
     365#if PLATFORM(MAC)
     366@implementation TestWKWebView (MacOnly)
     367- (void)mouseDownAtPoint:(NSPoint)point simulatePressure:(BOOL)simulatePressure
     368{
     369    [_hostWindow _mouseDownAtPoint:point simulatePressure:simulatePressure clickCount:1];
     370}
     371
     372- (void)mouseUpAtPoint:(NSPoint)point
     373{
     374    [_hostWindow _mouseUpAtPoint:point clickCount:1];
     375}
     376
     377- (void)mouseMoveToPoint:(NSPoint)point withFlags:(NSEventModifierFlags)flags
     378{
     379    [self mouseMoved:[NSEvent mouseEventWithType:NSEventTypeMouseMoved location:point modifierFlags:flags timestamp:GetCurrentEventTime() windowNumber:[_hostWindow windowNumber] context:[NSGraphicsContext currentContext] eventNumber:++gEventNumber clickCount:0 pressure:0]];
     380}
     381
     382- (void)sendClicksAtPoint:(NSPoint)point numberOfClicks:(NSUInteger)numberOfClicks
     383{
     384    for (NSUInteger clickCount = 1; clickCount <= numberOfClicks; ++clickCount) {
     385        [_hostWindow _mouseDownAtPoint:point simulatePressure:NO clickCount:clickCount];
     386        [_hostWindow _mouseUpAtPoint:point clickCount:clickCount];
     387    }
     388}
     389
     390- (NSWindow *)hostWindow
     391{
     392    return _hostWindow.get();
     393}
    394394@end
    395395#endif
Note: See TracChangeset for help on using the changeset viewer.