Changeset 245975 in webkit


Ignore:
Timestamp:
May 31, 2019 11:56:36 AM (5 years ago)
Author:
ap@apple.com
Message:

WebKitTestRunner sometimes freezes under -[NSWindow release]
https://bugs.webkit.org/show_bug.cgi?id=198422

Reviewed by Tim Horton.

The window remains key until it's out of the allWindows vector, and AppKit is not
happy about deallocating key windows. Fixed by updating allWindows in -close
instead of -release.

Added isMainFrame assertions in code that manipulates allWindows for a good measure.

  • WebKitTestRunner/mac/WebKitTestRunnerWindow.mm:

(+[WebKitTestRunnerWindow _WTR_keyWindow]):
(-[WebKitTestRunnerWindow initWithContentRect:styleMask:backing:defer:]):
(-[WebKitTestRunnerWindow close]):
(-[WebKitTestRunnerWindow dealloc]):

Location:
trunk/Tools
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Tools/ChangeLog

    r245972 r245975  
     12019-05-31  Alexey Proskuryakov  <ap@apple.com>
     2
     3        WebKitTestRunner sometimes freezes under -[NSWindow release]
     4        https://bugs.webkit.org/show_bug.cgi?id=198422
     5
     6        Reviewed by Tim Horton.
     7
     8        The window remains key until it's out of the allWindows vector, and AppKit is not
     9        happy about deallocating key windows. Fixed by updating allWindows in -close
     10        instead of -release.
     11
     12        Added isMainFrame assertions in code that manipulates allWindows for a good measure.
     13
     14        * WebKitTestRunner/mac/WebKitTestRunnerWindow.mm:
     15        (+[WebKitTestRunnerWindow _WTR_keyWindow]):
     16        (-[WebKitTestRunnerWindow initWithContentRect:styleMask:backing:defer:]):
     17        (-[WebKitTestRunnerWindow close]):
     18        (-[WebKitTestRunnerWindow dealloc]):
     19
    1202019-05-31  Geoffrey Garen  <ggaren@apple.com>
    221
  • trunk/Tools/WebKitTestRunner/mac/WebKitTestRunnerWindow.mm

    r235837 r245975  
    2828
    2929#import "PlatformWebView.h"
     30#import <wtf/MainThread.h>
    3031#import <wtf/Vector.h>
    3132
     
    3839+ (WebKitTestRunnerWindow *)_WTR_keyWindow
    3940{
     41    ASSERT(isMainThread());
    4042    for (auto window : allWindows) {
    4143        if ([window isKeyWindow])
     
    4749- (instancetype)initWithContentRect:(NSRect)contentRect styleMask:(NSUInteger)windowStyle backing:(NSBackingStoreType)bufferingType defer:(BOOL)deferCreation
    4850{
     51    ASSERT(isMainThread());
    4952    allWindows.append(self);
    5053    return [super initWithContentRect:contentRect styleMask:windowStyle backing:bufferingType defer:deferCreation];
    5154}
    5255
     56- (void)close
     57{
     58    ASSERT(isMainThread());
     59    ASSERT(allWindows.contains(self));
     60    allWindows.removeFirst(self);
     61    ASSERT(!allWindows.contains(self));
     62    [super close];
     63}
     64
    5365- (void)dealloc
    5466{
    55     allWindows.removeFirst(self);
    56     ASSERT(!allWindows.contains(self));
     67    ASSERT(isMainThread());
     68    ASSERT(!allWindows.contains(self)); // The window needs to stop being key before deallocation, otherwise AppKit spins waiting for this to happen (see <rdar://problem/50948871>).
    5769    [super dealloc];
    5870}
Note: See TracChangeset for help on using the changeset viewer.