WebKit Bugzilla
Attachment 357898 Details for
Bug 192821
: <rdar://problem/46194315> macOS: WebKit1 does not handle occlusion changes
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-192821-20181220162225.patch (text/plain), 12.08 KB, created by
Benjamin Poulain
on 2018-12-20 16:22:25 PST
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Benjamin Poulain
Created:
2018-12-20 16:22:25 PST
Size:
12.08 KB
patch
obsolete
>Subversion Revision: 239465 >diff --git a/Source/WebKitLegacy/mac/ChangeLog b/Source/WebKitLegacy/mac/ChangeLog >index 115f7f60196ea1c589026e3952882b7e4a2a7a9f..25f94974d5353901a6f5b9fec2949b4c2ccd71a6 100644 >--- a/Source/WebKitLegacy/mac/ChangeLog >+++ b/Source/WebKitLegacy/mac/ChangeLog >@@ -1,3 +1,25 @@ >+2018-12-20 Benjamin Poulain <benjamin@webkit.org> >+ >+ <rdar://problem/46194315> macOS: WebKit1 does not handle occlusion changes >+ https://bugs.webkit.org/show_bug.cgi?id=192821 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ When a window becomes occluded, the window server informs the application. >+ This should be used to suspend any work that is not visible by the user. >+ >+ WebKit2 handles it just fine, but WebKit1 did not handle the notification. >+ In some cases, that lead to performance impact (see radar). >+ >+ This patch adds an observer for the occlusion notification. I tried to stick >+ with the same names used by WebKit2. >+ >+ * WebView/WebView.mm: >+ (-[WebView _isViewVisible]): >+ (-[WebView addWindowObserversForWindow:]): >+ (-[WebView removeWindowObservers]): >+ (-[WebView _windowDidChangeOcclusionState:]): >+ > 2018-12-20 Chris Dumez <cdumez@apple.com> > > Use Optional::valueOr() instead of Optional::value_or() >diff --git a/Source/WebKitLegacy/mac/WebView/WebView.mm b/Source/WebKitLegacy/mac/WebView/WebView.mm >index 0110bbd61625b54ccc5069c579b02b0065d4a768..2f73283befb6fb50517244425be24f4fa935d9ae 100644 >--- a/Source/WebKitLegacy/mac/WebView/WebView.mm >+++ b/Source/WebKitLegacy/mac/WebView/WebView.mm >@@ -4671,15 +4671,21 @@ IGNORE_WARNINGS_END > > - (BOOL)_isViewVisible > { >- if (![self window]) >+ NSWindow *window = [self window]; >+ if (!window) > return false; > >- if (![[self window] isVisible]) >+ if (![window isVisible]) > return false; > > if ([self isHiddenOrHasHiddenAncestor]) > return false; > >+#if !PLATFORM(IOS_FAMILY) >+ if (_private->windowOcclusionDetectionEnabled && (window.occlusionState & NSWindowOcclusionStateVisible) != NSWindowOcclusionStateVisible) >+ return false; >+#endif >+ > return true; > } > >@@ -5068,6 +5074,18 @@ static Vector<String> toStringVector(NSArray* patterns) > } > } > >+#if !PLATFORM(IOS_FAMILY) >+- (BOOL)windowOcclusionDetectionEnabled >+{ >+ return _private->windowOcclusionDetectionEnabled; >+} >+ >+- (void)setWindowOcclusionDetectionEnabled:(BOOL)flag >+{ >+ _private->windowOcclusionDetectionEnabled = flag; >+} >+#endif >+ > - (void)_setPaginationBehavesLikeColumns:(BOOL)behavesLikeColumns > { > Page* page = core(self); >@@ -6003,22 +6021,26 @@ static NSString * const backingPropertyOldScaleFactorKey = @"NSBackingPropertyOl > - (void)addWindowObserversForWindow:(NSWindow *)window > { > if (window) { >- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(windowKeyStateChanged:) >+ NSNotificationCenter *defaultNotificationCenter = [NSNotificationCenter defaultCenter]; >+ >+ [defaultNotificationCenter addObserver:self selector:@selector(windowKeyStateChanged:) > name:NSWindowDidBecomeKeyNotification object:window]; >- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(windowKeyStateChanged:) >+ [defaultNotificationCenter addObserver:self selector:@selector(windowKeyStateChanged:) > name:NSWindowDidResignKeyNotification object:window]; >- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_windowWillOrderOnScreen:) >+ [defaultNotificationCenter addObserver:self selector:@selector(_windowWillOrderOnScreen:) > name:NSWindowWillOrderOnScreenNotification object:window]; >- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_windowWillOrderOffScreen:) >+ [defaultNotificationCenter addObserver:self selector:@selector(_windowWillOrderOffScreen:) > name:NSWindowWillOrderOffScreenNotification object:window]; >- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_windowDidChangeBackingProperties:) >+ [defaultNotificationCenter addObserver:self selector:@selector(_windowDidChangeBackingProperties:) > name:windowDidChangeBackingPropertiesNotification object:window]; >- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_windowDidChangeScreen:) >+ [defaultNotificationCenter addObserver:self selector:@selector(_windowDidChangeScreen:) > name:NSWindowDidChangeScreenNotification object:window]; >- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_windowVisibilityChanged:) >+ [defaultNotificationCenter addObserver:self selector:@selector(_windowVisibilityChanged:) > name:NSWindowDidMiniaturizeNotification object:window]; >- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_windowVisibilityChanged:) >+ [defaultNotificationCenter addObserver:self selector:@selector(_windowVisibilityChanged:) > name:NSWindowDidDeminiaturizeNotification object:window]; >+ [defaultNotificationCenter addObserver:self selector:@selector(_windowDidChangeOcclusionState:) >+ name:NSWindowDidChangeOcclusionStateNotification object:window]; > [_private->windowVisibilityObserver startObserving:window]; > } > } >@@ -6027,22 +6049,26 @@ static NSString * const backingPropertyOldScaleFactorKey = @"NSBackingPropertyOl > { > NSWindow *window = [self window]; > if (window) { >- [[NSNotificationCenter defaultCenter] removeObserver:self >+ NSNotificationCenter *defaultNotificationCenter = [NSNotificationCenter defaultCenter]; >+ >+ [defaultNotificationCenter removeObserver:self > name:NSWindowDidBecomeKeyNotification object:window]; >- [[NSNotificationCenter defaultCenter] removeObserver:self >+ [defaultNotificationCenter removeObserver:self > name:NSWindowDidResignKeyNotification object:window]; >- [[NSNotificationCenter defaultCenter] removeObserver:self >+ [defaultNotificationCenter removeObserver:self > name:NSWindowWillOrderOnScreenNotification object:window]; >- [[NSNotificationCenter defaultCenter] removeObserver:self >+ [defaultNotificationCenter removeObserver:self > name:NSWindowWillOrderOffScreenNotification object:window]; >- [[NSNotificationCenter defaultCenter] removeObserver:self >+ [defaultNotificationCenter removeObserver:self > name:windowDidChangeBackingPropertiesNotification object:window]; >- [[NSNotificationCenter defaultCenter] removeObserver:self >+ [defaultNotificationCenter removeObserver:self > name:NSWindowDidChangeScreenNotification object:window]; >- [[NSNotificationCenter defaultCenter] removeObserver:self >+ [defaultNotificationCenter removeObserver:self > name:NSWindowDidMiniaturizeNotification object:window]; >- [[NSNotificationCenter defaultCenter] removeObserver:self >+ [defaultNotificationCenter removeObserver:self > name:NSWindowDidDeminiaturizeNotification object:window]; >+ [defaultNotificationCenter removeObserver:self >+ name:NSWindowDidChangeOcclusionStateNotification object:window]; > [_private->windowVisibilityObserver stopObserving:window]; > } > } >@@ -6193,6 +6219,12 @@ static NSString * const backingPropertyOldScaleFactorKey = @"NSBackingPropertyOl > > _private->page->setDeviceScaleFactor(newBackingScaleFactor); > } >+ >+- (void)_windowDidChangeOcclusionState:(NSNotification *)notification >+{ >+ [self _updateVisibilityState]; >+} >+ > #else > - (void)_wakWindowScreenScaleChanged:(NSNotification *)notification > { >diff --git a/Source/WebKitLegacy/mac/WebView/WebViewData.h b/Source/WebKitLegacy/mac/WebView/WebViewData.h >index da555b9ca504c9e8c4615f08638a810b6dc1ad7a..c77f6ed15b0b7cdf76887441ed864e55715293de 100644 >--- a/Source/WebKitLegacy/mac/WebView/WebViewData.h >+++ b/Source/WebKitLegacy/mac/WebView/WebViewData.h >@@ -211,6 +211,7 @@ private: > std::unique_ptr<WebCore::TextIndicatorWindow> textIndicatorWindow; > BOOL hasInitializedLookupObserver; > RetainPtr<WebWindowVisibilityObserver> windowVisibilityObserver; >+ BOOL windowOcclusionDetectionEnabled; > RetainPtr<NSEvent> pressureEvent; > #endif // PLATFORM(MAC) > >diff --git a/Source/WebKitLegacy/mac/WebView/WebViewData.mm b/Source/WebKitLegacy/mac/WebView/WebViewData.mm >index a74834abb0b8f8263ed5adcf682543618f2d6a5c..8b49782b6bce18dcdb57355bbee4434b68895dec 100644 >--- a/Source/WebKitLegacy/mac/WebView/WebViewData.mm >+++ b/Source/WebKitLegacy/mac/WebView/WebViewData.mm >@@ -183,6 +183,10 @@ void WebViewLayerFlushScheduler::layerFlushCallback() > usesPageCache = YES; > shouldUpdateWhileOffscreen = YES; > >+#if !PLATFORM(IOS_FAMILY) >+ windowOcclusionDetectionEnabled = YES; >+#endif >+ > zoomMultiplier = 1; > zoomsTextOnly = NO; > >diff --git a/Source/WebKitLegacy/mac/WebView/WebViewPrivate.h b/Source/WebKitLegacy/mac/WebView/WebViewPrivate.h >index a8be2f6d360996cc52594c438e3b9b0d24dbec5f..299fe677f2a7a6bdb3632e3b55f8f46cccfac9c8 100644 >--- a/Source/WebKitLegacy/mac/WebView/WebViewPrivate.h >+++ b/Source/WebKitLegacy/mac/WebView/WebViewPrivate.h >@@ -852,6 +852,11 @@ Could be worth adding to the API. > - (WebPageVisibilityState)_visibilityState; > - (void)_setVisibilityState:(WebPageVisibilityState)visibilityState isInitialState:(BOOL)isInitialState; > >+#if !TARGET_OS_IPHONE >+- (BOOL)windowOcclusionDetectionEnabled; >+- (void)setWindowOcclusionDetectionEnabled:(BOOL)flag; >+#endif >+ > // Whether the column-break-{before,after} properties are respected instead of the > // page-break-{before,after} properties. > - (void)_setPaginationBehavesLikeColumns:(BOOL)behavesLikeColumns; >diff --git a/Tools/ChangeLog b/Tools/ChangeLog >index 368db4c37415566bb085bdf814ac52a2de38aff2..1bd3c9c79ee1cc30ed9a30446c97a6a4457bf69b 100644 >--- a/Tools/ChangeLog >+++ b/Tools/ChangeLog >@@ -1,3 +1,14 @@ >+2018-12-20 Benjamin Poulain <benjamin@webkit.org> >+ >+ <rdar://problem/46194315> macOS: WebKit1 does not handle occlusion changes >+ https://bugs.webkit.org/show_bug.cgi?id=192821 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * DumpRenderTree/mac/DumpRenderTree.mm: >+ (createWebViewAndOffscreenWindow): >+ * TestWebKitAPI/mac/WebKitAgnosticTest.mm: >+ > 2018-12-20 Jonathan Bedard <jbedard@apple.com> > > webkitpy: Autoinstall package URLs have changed >diff --git a/Tools/DumpRenderTree/mac/DumpRenderTree.mm b/Tools/DumpRenderTree/mac/DumpRenderTree.mm >index ae4b2134f1d2e7ffa127af2b21bbac8102f100f6..721d92c736e60036e07973232016a62755054152 100644 >--- a/Tools/DumpRenderTree/mac/DumpRenderTree.mm >+++ b/Tools/DumpRenderTree/mac/DumpRenderTree.mm >@@ -724,6 +724,7 @@ WebView *createWebViewAndOffscreenWindow() > [WebView registerURLSchemeAsLocal:@"feedsearch"]; > > #if PLATFORM(MAC) >+ [webView setWindowOcclusionDetectionEnabled:NO]; > [WebView _setFontWhitelist:fontWhitelist()]; > #endif > >diff --git a/Tools/TestWebKitAPI/mac/WebKitAgnosticTest.mm b/Tools/TestWebKitAPI/mac/WebKitAgnosticTest.mm >index 30a1f2cf7fa29968409bab795177c7f82be0a983..406289301506ab5e4bb5f499e8a5d126f4311be9 100644 >--- a/Tools/TestWebKitAPI/mac/WebKitAgnosticTest.mm >+++ b/Tools/TestWebKitAPI/mac/WebKitAgnosticTest.mm >@@ -28,6 +28,7 @@ > > #include <WebKit/WKURLCF.h> > #include <WebKit/WKViewPrivate.h> >+#include <WebKit/WebViewPrivate.h> > #include <wtf/RetainPtr.h> > > @interface FrameLoadDelegate : NSObject <WebFrameLoadDelegate> { >@@ -85,6 +86,12 @@ WebKitAgnosticTest::WebKitAgnosticTest() > void WebKitAgnosticTest::runWebKit1Test() > { > RetainPtr<WebView> webView = adoptNS([[WebView alloc] initWithFrame:viewFrame]); >+#if !TARGET_OS_IPHONE >+ // The tests can be run concurrently. In that case, window can occlude each other and change visibility results. >+ // Occlusion problems also happen from other windows unrelated to WebKit testing. >+ [webView setWindowOcclusionDetectionEnabled:NO]; >+#endif >+ > RetainPtr<FrameLoadDelegate> delegate = adoptNS([[FrameLoadDelegate alloc] initWithDidFinishLoadBoolean:&didFinishLoad]); > [webView.get() setFrameLoadDelegate:delegate.get()]; > initializeView(webView.get());
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 192821
:
357595
|
357598
|
357601
|
357613
|
357619
|
357626
|
357633
|
357645
|
357649
|
357746
| 357898