Skip to content

Commit

Permalink
Fix closing full-screen videos with the X button on macOS 14.4 and ab…
Browse files Browse the repository at this point in the history
…ove (#2762)

Task/Issue URL: https://app.asana.com/0/72649045549333/1206959015087322/f

Description:
Partially revert a fix to #1618 on macOS 14.4 and above because the original issue seems to be gone
and that fix seemed to have started breaking full screen videos in macOS Sonoma 14.4 and above.
  • Loading branch information
ayoy authored May 9, 2024
1 parent 567c062 commit 30a663d
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions DuckDuckGo/Tab/View/WebViewContainerView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -141,21 +141,23 @@ final class WebViewContainerView: NSView {
}
.store(in: &cancellables)

fullScreenWindowWillCloseCancellable = NotificationCenter.default.publisher(for: NSWindow.willCloseNotification, object: fullScreenWindow)
.sink { [weak self] notification in
self?.fullScreenWindowWillCloseCancellable = nil
let fullScreenWindowController = (notification.object as? NSWindow)?.windowController
DispatchQueue.main.async { [weak fullScreenWindowController] in
guard let fullScreenWindowController else { return }
// just in case.
// if WKFullScreenWindowController receives `close()` the next time it‘s open it will crash because its _webView is nil
// https://errors.duckduckgo.com/organizations/ddg/issues/3411/?project=6&referrer=release-issue-stream
NSException.try {
fullScreenWindowController.setValue(NSView(), forKeyPath: #keyPath(webView))
// https://app.asana.com/0/72649045549333/1206959015087322/f
if #unavailable(macOS 14.4) {
fullScreenWindowWillCloseCancellable = NotificationCenter.default.publisher(for: NSWindow.willCloseNotification, object: fullScreenWindow)
.sink { [weak self] notification in
self?.fullScreenWindowWillCloseCancellable = nil
let fullScreenWindowController = (notification.object as? NSWindow)?.windowController
DispatchQueue.main.async { [weak fullScreenWindowController] in
guard let fullScreenWindowController else { return }
// just in case.
// if WKFullScreenWindowController receives `close()` the next time it‘s open it will crash because its _webView is nil
// https://errors.duckduckgo.com/organizations/ddg/issues/3411/?project=6&referrer=release-issue-stream
NSException.try {
fullScreenWindowController.setValue(NSView(), forKeyPath: #keyPath(webView))
}
}

}
}
}

}

Expand Down

0 comments on commit 30a663d

Please sign in to comment.