Title: [251166] trunk/Source/WebKit
Revision
251166
Author
cdu...@apple.com
Date
2019-10-15 16:17:18 -0700 (Tue, 15 Oct 2019)

Log Message

Webview's drawing area may stay frozen on cross-site back/forward navigation
https://bugs.webkit.org/show_bug.cgi?id=203004

Reviewed by Tim Horton.

Whenever the UIScene becomes foreground / background, the WebPageProxy notifies its currently associated
WebPage in the committed WebProcess so that it can freeze / unfreeze its layer tree with the
BackgroundApplication reason. The issue is that if a WebPage gets suspended on cross-site navigation
(because the UIScene is in the background when the load commits), then the suspended WebPage kept its
a BackgroundApplication freeze. When the UIScene becomes foreground, the WebPage only notifies its
committed page so the suspended page keeps its BackgroundApplication freeze still. If the user now
navigates back, it will restore the suspended WebPage and the view will stay frozen.

To address the issue, we now have the WebPage drop its BackgroundApplication freeze reason, whenever
it transitions from committed to suspended.

* UIProcess/ios/WKApplicationStateTrackingView.mm:
(-[WKApplicationStateTrackingView didMoveToWindow]):
Fix logging, [self isBackground] needs to be called *after* _applicationStateTracker has been
initialized, or it will return YES unconditionally.

* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::setIsSuspended):

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (251165 => 251166)


--- trunk/Source/WebKit/ChangeLog	2019-10-15 22:54:20 UTC (rev 251165)
+++ trunk/Source/WebKit/ChangeLog	2019-10-15 23:17:18 UTC (rev 251166)
@@ -1,3 +1,29 @@
+2019-10-15  Chris Dumez  <cdu...@apple.com>
+
+        Webview's drawing area may stay frozen on cross-site back/forward navigation
+        https://bugs.webkit.org/show_bug.cgi?id=203004
+
+        Reviewed by Tim Horton.
+
+        Whenever the UIScene becomes foreground / background, the WebPageProxy notifies its currently associated
+        WebPage in the committed WebProcess so that it can freeze / unfreeze its layer tree with the
+        BackgroundApplication reason. The issue is that if a WebPage gets suspended on cross-site navigation
+        (because the UIScene is in the background when the load commits), then the suspended WebPage kept its
+        a BackgroundApplication freeze. When the UIScene becomes foreground, the WebPage only notifies its
+        committed page so the suspended page keeps its BackgroundApplication freeze still. If the user now
+        navigates back, it will restore the suspended WebPage and the view will stay frozen.
+
+        To address the issue, we now have the WebPage drop its BackgroundApplication freeze reason, whenever
+        it transitions from committed to suspended.
+
+        * UIProcess/ios/WKApplicationStateTrackingView.mm:
+        (-[WKApplicationStateTrackingView didMoveToWindow]):
+        Fix logging, [self isBackground] needs to be called *after* _applicationStateTracker has been
+        initialized, or it will return YES unconditionally.
+
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::setIsSuspended):
+
 2019-10-15  Peng Liu  <peng.l...@apple.com>
 
         [Picture-in-Picture Web API] Implement HTMLVideoElement.requestPictureInPicture() / Document.exitPictureInPicture()

Modified: trunk/Source/WebKit/UIProcess/ios/WKApplicationStateTrackingView.mm (251165 => 251166)


--- trunk/Source/WebKit/UIProcess/ios/WKApplicationStateTrackingView.mm	2019-10-15 22:54:20 UTC (rev 251165)
+++ trunk/Source/WebKit/UIProcess/ios/WKApplicationStateTrackingView.mm	2019-10-15 23:17:18 UTC (rev 251166)
@@ -69,9 +69,9 @@
         return;
 
     auto page = [_webViewToTrack _page];
+    _applicationStateTracker = makeUnique<WebKit::ApplicationStateTracker>(self, @selector(_applicationDidEnterBackground), @selector(_applicationDidFinishSnapshottingAfterEnteringBackground), @selector(_applicationWillEnterForeground));
     RELEASE_LOG(ViewState, "%p - WKApplicationStateTrackingView: View with page [%p, pageProxyID: %" PRIu64 "] was added to a window, _lastObservedStateWasBackground: %d, isNowBackground: %d", self, page, page ? page->identifier().toUInt64() : 0, _lastObservedStateWasBackground, [self isBackground]);
-    _applicationStateTracker = makeUnique<WebKit::ApplicationStateTracker>(self, @selector(_applicationDidEnterBackground), @selector(_applicationDidFinishSnapshottingAfterEnteringBackground), @selector(_applicationWillEnterForeground));
-    
+
     if (_lastObservedStateWasBackground && ![self isBackground])
         [self _applicationWillEnterForeground];
     else if (!_lastObservedStateWasBackground && [self isBackground])

Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp (251165 => 251166)


--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp	2019-10-15 22:54:20 UTC (rev 251165)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp	2019-10-15 23:17:18 UTC (rev 251166)
@@ -6499,6 +6499,10 @@
     // Unfrozen on drawing area reset.
     freezeLayerTree(LayerTreeFreezeReason::PageSuspended);
 
+    // Only the committed WebPage gets application visibility notifications from the UIProcess, so make sure
+    // we don't hold a BackgroundApplication freeze reason when transitioning from committed to suspended.
+    unfreezeLayerTree(LayerTreeFreezeReason::BackgroundApplication);
+
     WebProcess::singleton().sendPrewarmInformation(mainWebFrame()->url());
 
     suspendForProcessSwap();
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to