Skip to content

Commit

Permalink
Revert [257736@main] Mitigate crashes when removing KVO from NSWindow…
Browse files Browse the repository at this point in the history
… in -[WKWindowVisibilityObserver stopObserving:]

https://bugs.webkit.org/show_bug.cgi?id=249103
rdar://102360839

Unreviewed revert
This reverts because the new test addition landed as a consistent crash.

* Source/WebKit/UIProcess/mac/WebViewImpl.mm:
(-[WKWindowVisibilityObserver startObserving:]):
(-[WKWindowVisibilityObserver stopObserving:]):
* Tools/TestWebKitAPI/Tests/WebKitCocoa/PrepareForMoveToWindow.mm:

Canonical link: https://commits.webkit.org/257848@main
  • Loading branch information
karlrackler committed Dec 14, 2022
1 parent 83f96fe commit 703c07c
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 25 deletions.
8 changes: 0 additions & 8 deletions Source/WebKit/UIProcess/mac/WebViewImpl.mm
Expand Up @@ -332,10 +332,6 @@ - (void)startObserving:(NSWindow *)window
if (_shouldObserveFontPanel)
[self startObservingFontPanel];

if (objc_getAssociatedObject(window, _impl))
return;

objc_setAssociatedObject(window, _impl, @YES, OBJC_ASSOCIATION_COPY_NONATOMIC);
[window addObserver:self forKeyPath:@"contentLayoutRect" options:NSKeyValueObservingOptionInitial context:keyValueObservingContext];
[window addObserver:self forKeyPath:@"titlebarAppearsTransparent" options:NSKeyValueObservingOptionInitial context:keyValueObservingContext];
}
Expand Down Expand Up @@ -366,10 +362,6 @@ - (void)stopObserving:(NSWindow *)window
if (_shouldObserveFontPanel)
[[NSFontPanel sharedFontPanel] removeObserver:self forKeyPath:@"visible" context:keyValueObservingContext];

if (!objc_getAssociatedObject(window, _impl))
return;

objc_setAssociatedObject(window, _impl, nil, OBJC_ASSOCIATION_COPY_NONATOMIC);
[window removeObserver:self forKeyPath:@"contentLayoutRect" context:keyValueObservingContext];
[window removeObserver:self forKeyPath:@"titlebarAppearsTransparent" context:keyValueObservingContext];
}
Expand Down
17 changes: 0 additions & 17 deletions Tools/TestWebKitAPI/Tests/WebKitCocoa/PrepareForMoveToWindow.mm
Expand Up @@ -70,23 +70,6 @@
TestWebKitAPI::Util::run(&done);
}

TEST(WKWebView, PrepareForMoveToWindowShouldNotCrashWhenRemovingWindowObservers)
{
auto window = adoptNS([NSWindow new]);
auto webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600)]);
[webView synchronouslyLoadTestPageNamed:@"simple"];

[[window contentView] addSubview:webView.get()];
[webView _prepareForMoveToWindow:nil completionHandler:^{ }];
[webView _prepareForMoveToWindow:window.get() completionHandler:^{ }];

__block bool done = false;
[webView _prepareForMoveToWindow:nil completionHandler:^{
done = true;
}];
TestWebKitAPI::Util::run(&done);
}

TEST(WKWebView, PrepareForMoveToWindowThenClose)
{
auto webView = adoptNS([[WKWebView alloc] init]);
Expand Down

0 comments on commit 703c07c

Please sign in to comment.