- Revision
- 241075
- Author
- [email protected]
- Date
- 2019-02-06 14:17:13 -0800 (Wed, 06 Feb 2019)
Log Message
Cherry-pick r240818. rdar://problem/47774549
Page zoom level is lost after a process swap or a crash
https://bugs.webkit.org/show_bug.cgi?id=194105
<rdar://problem/47610781>
Reviewed by Alex Christensen.
Source/WebKit:
Previously, when the client would call setPageAndTextZoomFactors() on the WebPageProxy,
we would update the WebPageProxy's corresponding data members and send an IPC to the
WebProcess to apply the zoom factors.
The issue is that on process crash or process-swap, we never communicate those zoom factors
to the new WebProcess. Even if the client were to call setPageAndTextZoomFactors() with
the same factors again, it would be a no-op since the WebPageProxy's data members already
reflect the expected values.
To address the issue, pass both the page zoom and the text zoom factors to the WebProcess
via WebPageCreationParameters. This way, there is no need to send an extra IPC and we're
sure the WebPageProxy's factors are properly applied to the WebPage on WebContent process
side upon creation (whether after a crash or a process swap).
* Shared/WebPageCreationParameters.cpp:
(WebKit::WebPageCreationParameters::encode const):
(WebKit::WebPageCreationParameters::decode):
* Shared/WebPageCreationParameters.h:
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::creationParameters):
* WebProcess/WebPage/WebPage.cpp:
Tools:
Add API test coverage.
* TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm:
(-[PSONNavigationDelegate webView:didCommitNavigation:]):
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@240818 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Modified Paths
Diff
Modified: branches/safari-607-branch/Source/WebKit/ChangeLog (241074 => 241075)
--- branches/safari-607-branch/Source/WebKit/ChangeLog 2019-02-06 22:17:10 UTC (rev 241074)
+++ branches/safari-607-branch/Source/WebKit/ChangeLog 2019-02-06 22:17:13 UTC (rev 241075)
@@ -1,5 +1,78 @@
2019-02-05 Alan Coon <[email protected]>
+ Cherry-pick r240818. rdar://problem/47774549
+
+ Page zoom level is lost after a process swap or a crash
+ https://bugs.webkit.org/show_bug.cgi?id=194105
+ <rdar://problem/47610781>
+
+ Reviewed by Alex Christensen.
+
+ Source/WebKit:
+
+ Previously, when the client would call setPageAndTextZoomFactors() on the WebPageProxy,
+ we would update the WebPageProxy's corresponding data members and send an IPC to the
+ WebProcess to apply the zoom factors.
+
+ The issue is that on process crash or process-swap, we never communicate those zoom factors
+ to the new WebProcess. Even if the client were to call setPageAndTextZoomFactors() with
+ the same factors again, it would be a no-op since the WebPageProxy's data members already
+ reflect the expected values.
+
+ To address the issue, pass both the page zoom and the text zoom factors to the WebProcess
+ via WebPageCreationParameters. This way, there is no need to send an extra IPC and we're
+ sure the WebPageProxy's factors are properly applied to the WebPage on WebContent process
+ side upon creation (whether after a crash or a process swap).
+
+ * Shared/WebPageCreationParameters.cpp:
+ (WebKit::WebPageCreationParameters::encode const):
+ (WebKit::WebPageCreationParameters::decode):
+ * Shared/WebPageCreationParameters.h:
+ * UIProcess/WebPageProxy.cpp:
+ (WebKit::WebPageProxy::creationParameters):
+ * WebProcess/WebPage/WebPage.cpp:
+
+ Tools:
+
+ Add API test coverage.
+
+ * TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm:
+ (-[PSONNavigationDelegate webView:didCommitNavigation:]):
+
+ git-svn-id: https://svn.webkit.org/repository/webkit/trunk@240818 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+ 2019-01-31 Chris Dumez <[email protected]>
+
+ Page zoom level is lost after a process swap or a crash
+ https://bugs.webkit.org/show_bug.cgi?id=194105
+ <rdar://problem/47610781>
+
+ Reviewed by Alex Christensen.
+
+ Previously, when the client would call setPageAndTextZoomFactors() on the WebPageProxy,
+ we would update the WebPageProxy's corresponding data members and send an IPC to the
+ WebProcess to apply the zoom factors.
+
+ The issue is that on process crash or process-swap, we never communicate those zoom factors
+ to the new WebProcess. Even if the client were to call setPageAndTextZoomFactors() with
+ the same factors again, it would be a no-op since the WebPageProxy's data members already
+ reflect the expected values.
+
+ To address the issue, pass both the page zoom and the text zoom factors to the WebProcess
+ via WebPageCreationParameters. This way, there is no need to send an extra IPC and we're
+ sure the WebPageProxy's factors are properly applied to the WebPage on WebContent process
+ side upon creation (whether after a crash or a process swap).
+
+ * Shared/WebPageCreationParameters.cpp:
+ (WebKit::WebPageCreationParameters::encode const):
+ (WebKit::WebPageCreationParameters::decode):
+ * Shared/WebPageCreationParameters.h:
+ * UIProcess/WebPageProxy.cpp:
+ (WebKit::WebPageProxy::creationParameters):
+ * WebProcess/WebPage/WebPage.cpp:
+
+2019-02-05 Alan Coon <[email protected]>
+
Cherry-pick r240803. rdar://problem/47774506
Regression(PSON) Crash under WebProcessProxy::canTerminateChildProcess()
Modified: branches/safari-607-branch/Source/WebKit/Shared/WebPageCreationParameters.cpp (241074 => 241075)
--- branches/safari-607-branch/Source/WebKit/Shared/WebPageCreationParameters.cpp 2019-02-06 22:17:10 UTC (rev 241074)
+++ branches/safari-607-branch/Source/WebKit/Shared/WebPageCreationParameters.cpp 2019-02-06 22:17:13 UTC (rev 241075)
@@ -60,6 +60,8 @@
encoder << canRunModal;
encoder << deviceScaleFactor;
encoder << viewScaleFactor;
+ encoder << textZoomFactor;
+ encoder << pageZoomFactor;
encoder << topContentInset;
encoder << mediaVolume;
encoder << muted;
@@ -196,6 +198,10 @@
return WTF::nullopt;
if (!decoder.decode(parameters.viewScaleFactor))
return WTF::nullopt;
+ if (!decoder.decode(parameters.textZoomFactor))
+ return WTF::nullopt;
+ if (!decoder.decode(parameters.pageZoomFactor))
+ return WTF::nullopt;
if (!decoder.decode(parameters.topContentInset))
return WTF::nullopt;
if (!decoder.decode(parameters.mediaVolume))
Modified: branches/safari-607-branch/Source/WebKit/Shared/WebPageCreationParameters.h (241074 => 241075)
--- branches/safari-607-branch/Source/WebKit/Shared/WebPageCreationParameters.h 2019-02-06 22:17:10 UTC (rev 241074)
+++ branches/safari-607-branch/Source/WebKit/Shared/WebPageCreationParameters.h 2019-02-06 22:17:13 UTC (rev 241075)
@@ -106,6 +106,9 @@
float deviceScaleFactor;
float viewScaleFactor;
+ double textZoomFactor { 1 };
+ double pageZoomFactor { 1 };
+
float topContentInset;
float mediaVolume;
Modified: branches/safari-607-branch/Source/WebKit/UIProcess/WebPageProxy.cpp (241074 => 241075)
--- branches/safari-607-branch/Source/WebKit/UIProcess/WebPageProxy.cpp 2019-02-06 22:17:10 UTC (rev 241074)
+++ branches/safari-607-branch/Source/WebKit/UIProcess/WebPageProxy.cpp 2019-02-06 22:17:13 UTC (rev 241075)
@@ -6733,6 +6733,8 @@
parameters.canRunModal = m_canRunModal;
parameters.deviceScaleFactor = deviceScaleFactor();
parameters.viewScaleFactor = m_viewScaleFactor;
+ parameters.textZoomFactor = m_textZoomFactor;
+ parameters.pageZoomFactor = m_pageZoomFactor;
parameters.topContentInset = m_topContentInset;
parameters.mediaVolume = m_mediaVolume;
parameters.muted = m_mutedState;
Modified: branches/safari-607-branch/Source/WebKit/WebProcess/WebPage/WebPage.cpp (241074 => 241075)
--- branches/safari-607-branch/Source/WebKit/WebProcess/WebPage/WebPage.cpp 2019-02-06 22:17:10 UTC (rev 241074)
+++ branches/safari-607-branch/Source/WebKit/WebProcess/WebPage/WebPage.cpp 2019-02-06 22:17:13 UTC (rev 241075)
@@ -482,6 +482,7 @@
m_drawingArea->updatePreferences(parameters.store);
setBackgroundExtendsBeyondPage(parameters.backgroundExtendsBeyondPage);
+ setPageAndTextZoomFactors(parameters.pageZoomFactor, parameters.textZoomFactor);
#if ENABLE(GEOLOCATION)
WebCore::provideGeolocationTo(m_page.get(), *new WebGeolocationClient(*this));
Modified: branches/safari-607-branch/Tools/ChangeLog (241074 => 241075)
--- branches/safari-607-branch/Tools/ChangeLog 2019-02-06 22:17:10 UTC (rev 241074)
+++ branches/safari-607-branch/Tools/ChangeLog 2019-02-06 22:17:13 UTC (rev 241075)
@@ -1,5 +1,61 @@
2019-02-05 Alan Coon <[email protected]>
+ Cherry-pick r240818. rdar://problem/47774549
+
+ Page zoom level is lost after a process swap or a crash
+ https://bugs.webkit.org/show_bug.cgi?id=194105
+ <rdar://problem/47610781>
+
+ Reviewed by Alex Christensen.
+
+ Source/WebKit:
+
+ Previously, when the client would call setPageAndTextZoomFactors() on the WebPageProxy,
+ we would update the WebPageProxy's corresponding data members and send an IPC to the
+ WebProcess to apply the zoom factors.
+
+ The issue is that on process crash or process-swap, we never communicate those zoom factors
+ to the new WebProcess. Even if the client were to call setPageAndTextZoomFactors() with
+ the same factors again, it would be a no-op since the WebPageProxy's data members already
+ reflect the expected values.
+
+ To address the issue, pass both the page zoom and the text zoom factors to the WebProcess
+ via WebPageCreationParameters. This way, there is no need to send an extra IPC and we're
+ sure the WebPageProxy's factors are properly applied to the WebPage on WebContent process
+ side upon creation (whether after a crash or a process swap).
+
+ * Shared/WebPageCreationParameters.cpp:
+ (WebKit::WebPageCreationParameters::encode const):
+ (WebKit::WebPageCreationParameters::decode):
+ * Shared/WebPageCreationParameters.h:
+ * UIProcess/WebPageProxy.cpp:
+ (WebKit::WebPageProxy::creationParameters):
+ * WebProcess/WebPage/WebPage.cpp:
+
+ Tools:
+
+ Add API test coverage.
+
+ * TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm:
+ (-[PSONNavigationDelegate webView:didCommitNavigation:]):
+
+ git-svn-id: https://svn.webkit.org/repository/webkit/trunk@240818 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+ 2019-01-31 Chris Dumez <[email protected]>
+
+ Page zoom level is lost after a process swap or a crash
+ https://bugs.webkit.org/show_bug.cgi?id=194105
+ <rdar://problem/47610781>
+
+ Reviewed by Alex Christensen.
+
+ Add API test coverage.
+
+ * TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm:
+ (-[PSONNavigationDelegate webView:didCommitNavigation:]):
+
+2019-02-05 Alan Coon <[email protected]>
+
Cherry-pick r240725. rdar://problem/47774554
Regression(PSON) Load hang can occur on history navigation
Modified: branches/safari-607-branch/Tools/TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm (241074 => 241075)
--- branches/safari-607-branch/Tools/TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm 2019-02-06 22:17:10 UTC (rev 241074)
+++ branches/safari-607-branch/Tools/TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm 2019-02-06 22:17:13 UTC (rev 241075)
@@ -97,6 +97,7 @@
@interface PSONNavigationDelegate : NSObject <WKNavigationDelegate> {
@public void (^decidePolicyForNavigationAction)(WKNavigationAction *, void (^)(WKNavigationActionPolicy));
+ @public void (^didCommitNavigationHandler)();
}
@end
@@ -125,6 +126,12 @@
didStartProvisionalLoad = true;
}
+- (void)webView:(WKWebView *)webView didCommitNavigation:(null_unspecified WKNavigation *)navigation
+{
+ if (didCommitNavigationHandler)
+ didCommitNavigationHandler();
+}
+
- (void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigationAction *)navigationAction decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandler
{
++numberOfDecidePolicyCalls;
@@ -2491,6 +2498,83 @@
EXPECT_EQ(1u, seenPIDs.size());
}
+#if PLATFORM(MAC)
+
+static const char* sendBodyClientWidth = R"PSONRESOURCE(
+<body>
+TEST
+<script>
+_onload_ = () => {
+ document.body.offsetTop; // force layout
+ setTimeout(() => {
+ window.webkit.messageHandlers.pson.postMessage("" + document.body.clientWidth);
+ });
+}
+</script>
+</body>
+)PSONRESOURCE";
+
+TEST(ProcessSwap, PageZoomLevelAfterSwap)
+{
+ auto processPoolConfiguration = adoptNS([[_WKProcessPoolConfiguration alloc] init]);
+ [processPoolConfiguration setProcessSwapsOnNavigation:YES];
+ auto processPool = adoptNS([[WKProcessPool alloc] _initWithConfiguration:processPoolConfiguration.get()]);
+
+ auto webViewConfiguration = adoptNS([[WKWebViewConfiguration alloc] init]);
+ [webViewConfiguration setProcessPool:processPool.get()];
+ auto handler = adoptNS([[PSONScheme alloc] init]);
+ [handler addMappingFromURLString:@"pson://www.webkit.org/main.html" toData:sendBodyClientWidth];
+ [handler addMappingFromURLString:@"pson://www.apple.com/main.html" toData:sendBodyClientWidth];
+ [webViewConfiguration setURLSchemeHandler:handler.get() forURLScheme:@"PSON"];
+
+ auto messageHandler = adoptNS([[PSONMessageHandler alloc] init]);
+ [[webViewConfiguration userContentController] addScriptMessageHandler:messageHandler.get() name:@"pson"];
+
+ auto webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:webViewConfiguration.get()]);
+ auto delegate = adoptNS([[PSONNavigationDelegate alloc] init]);
+ [webView setNavigationDelegate:delegate.get()];
+
+ delegate->didCommitNavigationHandler = ^ {
+ [webView _setPageZoomFactor:2.0];
+ delegate->didCommitNavigationHandler = nil;
+ };
+
+ NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"pson://www.webkit.org/main.html"]];
+ [webView loadRequest:request];
+
+ TestWebKitAPI::Util::run(&receivedMessage);
+ receivedMessage = false;
+
+ EXPECT_WK_STREQ(@"400", receivedMessages.get()[0]);
+
+ TestWebKitAPI::Util::run(&done);
+ done = false;
+
+ request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"pson://www.apple.com/main.html"]];
+ [webView loadRequest:request];
+
+ TestWebKitAPI::Util::run(&receivedMessage);
+ receivedMessage = false;
+
+ EXPECT_WK_STREQ(@"400", receivedMessages.get()[1]);
+
+ TestWebKitAPI::Util::run(&done);
+ done = false;
+
+ // Kill the WebProcess, the page should reload automatically and the page zoom level should be maintained.
+ kill([webView _webProcessIdentifier], 9);
+
+ TestWebKitAPI::Util::run(&receivedMessage);
+ receivedMessage = false;
+
+ EXPECT_WK_STREQ(@"400", receivedMessages.get()[2]);
+
+ TestWebKitAPI::Util::run(&done);
+ done = false;
+}
+
+#endif // PLATFORM(MAC)
+
TEST(ProcessSwap, DoSameSiteNavigationAfterCrossSiteProvisionalLoadStarted)
{
auto processPoolConfiguration = adoptNS([[_WKProcessPoolConfiguration alloc] init]);