Title: [245975] trunk/Tools
Revision
245975
Author
a...@apple.com
Date
2019-05-31 11:56:36 -0700 (Fri, 31 May 2019)

Log 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]):

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (245974 => 245975)


--- trunk/Tools/ChangeLog	2019-05-31 18:55:14 UTC (rev 245974)
+++ trunk/Tools/ChangeLog	2019-05-31 18:56:36 UTC (rev 245975)
@@ -1,3 +1,22 @@
+2019-05-31  Alexey Proskuryakov  <a...@apple.com>
+
+        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]):
+
 2019-05-31  Geoffrey Garen  <gga...@apple.com>
 
         Some WeakPtr cleanup

Modified: trunk/Tools/WebKitTestRunner/mac/WebKitTestRunnerWindow.mm (245974 => 245975)


--- trunk/Tools/WebKitTestRunner/mac/WebKitTestRunnerWindow.mm	2019-05-31 18:55:14 UTC (rev 245974)
+++ trunk/Tools/WebKitTestRunner/mac/WebKitTestRunnerWindow.mm	2019-05-31 18:56:36 UTC (rev 245975)
@@ -27,6 +27,7 @@
 #import "WebKitTestRunnerWindow.h"
 
 #import "PlatformWebView.h"
+#import <wtf/MainThread.h>
 #import <wtf/Vector.h>
 
 @implementation WebKitTestRunnerWindow
@@ -37,6 +38,7 @@
 
 + (WebKitTestRunnerWindow *)_WTR_keyWindow
 {
+    ASSERT(isMainThread());
     for (auto window : allWindows) {
         if ([window isKeyWindow])
             return window;
@@ -46,14 +48,24 @@
 
 - (instancetype)initWithContentRect:(NSRect)contentRect styleMask:(NSUInteger)windowStyle backing:(NSBackingStoreType)bufferingType defer:(BOOL)deferCreation
 {
+    ASSERT(isMainThread());
     allWindows.append(self);
     return [super initWithContentRect:contentRect styleMask:windowStyle backing:bufferingType defer:deferCreation];
 }
 
-- (void)dealloc
+- (void)close
 {
+    ASSERT(isMainThread());
+    ASSERT(allWindows.contains(self));
     allWindows.removeFirst(self);
     ASSERT(!allWindows.contains(self));
+    [super close];
+}
+
+- (void)dealloc
+{
+    ASSERT(isMainThread());
+    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>).
     [super dealloc];
 }
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to