Skip to content

Commit

Permalink
Cherry-pick e2e4c39. rdar://125534586
Browse files Browse the repository at this point in the history
    Potential crash related to WKWindowVisibilityObserver
    https://bugs.webkit.org/show_bug.cgi?id=272559

    Reviewed by Wenson Hsieh.

    Be sure to always stop observing the window when destroying WebViewImpl.

    * Source/WebKit/UIProcess/mac/WebViewImpl.h:
    * Source/WebKit/UIProcess/mac/WebViewImpl.mm:
    (WebKit::WebViewImpl::~WebViewImpl):
    (WebKit::WebViewImpl::viewWillMoveToWindowImpl):

    Canonical link: https://commits.webkit.org/277414@main

Canonical link: https://commits.webkit.org/272448.913@safari-7618-branch
  • Loading branch information
rniwa authored and Dan Robson committed Apr 12, 2024
1 parent 031936e commit f25c7f4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
1 change: 1 addition & 0 deletions Source/WebKit/UIProcess/mac/WebViewImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -848,6 +848,7 @@ ALLOW_DEPRECATED_DECLARATIONS_END
bool m_shouldDeferViewInWindowChanges { false };
bool m_viewInWindowChangeWasDeferred { false };
bool m_isPreparingToUnparentView { false };
bool m_isObservingWindow { false };
RetainPtr<NSWindow> m_targetWindowForMovePreparation;

id m_flagsChangedEventMonitor { nullptr };
Expand Down
5 changes: 3 additions & 2 deletions Source/WebKit/UIProcess/mac/WebViewImpl.mm
Original file line number Diff line number Diff line change
Expand Up @@ -1283,8 +1283,8 @@ static bool isInRecoveryOS()
#endif
#endif

if (m_targetWindowForMovePreparation) {
[m_windowVisibilityObserver stopObserving:m_targetWindowForMovePreparation.get()];
if (m_isObservingWindow) {
[m_windowVisibilityObserver stopObserving:m_targetWindowForMovePreparation.get() ?: [m_view window]];
m_targetWindowForMovePreparation = nil;
}

Expand Down Expand Up @@ -2160,6 +2160,7 @@ static bool isInRecoveryOS()
NSWindow *stopObservingWindow = m_targetWindowForMovePreparation.get() ?: [m_view window];
[m_windowVisibilityObserver stopObserving:stopObservingWindow];
[m_windowVisibilityObserver startObserving:window];
m_isObservingWindow = true;
}

#if HAVE(NSSCROLLVIEW_SEPARATOR_TRACKING_ADAPTER)
Expand Down

0 comments on commit f25c7f4

Please sign in to comment.