- Revision
- 226424
- Author
- timothy_hor...@apple.com
- Date
- 2018-01-04 14:54:09 -0800 (Thu, 04 Jan 2018)
Log Message
WKWebView loses minimum layout size overrides that happen while the process is terminated
https://bugs.webkit.org/show_bug.cgi?id=181306
<rdar://problem/34398288>
Reviewed by Dan Bernstein.
Source/WebKit:
* Shared/WebPageCreationParameters.cpp:
(WebKit::WebPageCreationParameters::encode const):
(WebKit::WebPageCreationParameters::decode):
* Shared/WebPageCreationParameters.h:
* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView _didRelaunchProcess]): Deleted.
* UIProcess/API/Cocoa/WKWebViewPrivate.h:
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::creationParameters):
* UIProcess/WebPageProxy.h:
* UIProcess/ios/PageClientImplIOS.mm:
(WebKit::PageClientImpl::didRelaunchProcess):
* UIProcess/ios/WebPageProxyIOS.mm:
(WebKit::WebPageProxy::setViewportConfigurationMinimumLayoutSize):
(WebKit::WebPageProxy::setForceAlwaysUserScalable):
(WebKit::WebPageProxy::setMaximumUnobscuredSize):
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::WebPage):
Pass the current viewport minimum layout size and maximum unobscured size
in the WebPageCreationParameters instead of re-sending them in _didRelaunchProcess.
The previous approach was problematic when _dispatchSetMinimumLayoutSize:
was changed to not re-send identical updates, because if the client calls
_overrideLayoutParametersWithMinimumLayoutSize before the Web Content process
is re-launched (after terminating), we would cache the size, attempt to send it,
fail silently (because the process is not launched), and then in _didRelaunchProcess
we would choose not to re-send (after the process is successfully relaunched)
because we think we already sent the new value.
Add isValid() checks to our message sends. Ideally send() would assert
if the process is not alive to avoid problems like this, but it doesn't (yet).
Get rid of WKWebView's _didRelaunchProcess, because it does nothing now.
Tools:
* TestWebKitAPI/Tests/WebKitCocoa/AnimatedResize.mm:
(TEST):
Add a test that calling _overrideLayoutParametersWithMinimumLayoutSize
while the process is terminated results in the page getting the correct
minimum layout size.
Modified Paths
Diff
Modified: trunk/Source/WebKit/ChangeLog (226423 => 226424)
--- trunk/Source/WebKit/ChangeLog 2018-01-04 22:33:01 UTC (rev 226423)
+++ trunk/Source/WebKit/ChangeLog 2018-01-04 22:54:09 UTC (rev 226424)
@@ -1,3 +1,45 @@
+2018-01-04 Tim Horton <timothy_hor...@apple.com>
+
+ WKWebView loses minimum layout size overrides that happen while the process is terminated
+ https://bugs.webkit.org/show_bug.cgi?id=181306
+ <rdar://problem/34398288>
+
+ Reviewed by Dan Bernstein.
+
+ * Shared/WebPageCreationParameters.cpp:
+ (WebKit::WebPageCreationParameters::encode const):
+ (WebKit::WebPageCreationParameters::decode):
+ * Shared/WebPageCreationParameters.h:
+ * UIProcess/API/Cocoa/WKWebView.mm:
+ (-[WKWebView _didRelaunchProcess]): Deleted.
+ * UIProcess/API/Cocoa/WKWebViewPrivate.h:
+ * UIProcess/WebPageProxy.cpp:
+ (WebKit::WebPageProxy::creationParameters):
+ * UIProcess/WebPageProxy.h:
+ * UIProcess/ios/PageClientImplIOS.mm:
+ (WebKit::PageClientImpl::didRelaunchProcess):
+ * UIProcess/ios/WebPageProxyIOS.mm:
+ (WebKit::WebPageProxy::setViewportConfigurationMinimumLayoutSize):
+ (WebKit::WebPageProxy::setForceAlwaysUserScalable):
+ (WebKit::WebPageProxy::setMaximumUnobscuredSize):
+ * WebProcess/WebPage/WebPage.cpp:
+ (WebKit::WebPage::WebPage):
+ Pass the current viewport minimum layout size and maximum unobscured size
+ in the WebPageCreationParameters instead of re-sending them in _didRelaunchProcess.
+
+ The previous approach was problematic when _dispatchSetMinimumLayoutSize:
+ was changed to not re-send identical updates, because if the client calls
+ _overrideLayoutParametersWithMinimumLayoutSize before the Web Content process
+ is re-launched (after terminating), we would cache the size, attempt to send it,
+ fail silently (because the process is not launched), and then in _didRelaunchProcess
+ we would choose not to re-send (after the process is successfully relaunched)
+ because we think we already sent the new value.
+
+ Add isValid() checks to our message sends. Ideally send() would assert
+ if the process is not alive to avoid problems like this, but it doesn't (yet).
+
+ Get rid of WKWebView's _didRelaunchProcess, because it does nothing now.
+
2018-01-04 Stephan Szabo <stephan.sz...@sony.com>
NetworkProcess cache files use functions from unistd.h without explicitly including it
Modified: trunk/Source/WebKit/Shared/WebPageCreationParameters.cpp (226423 => 226424)
--- trunk/Source/WebKit/Shared/WebPageCreationParameters.cpp 2018-01-04 22:33:01 UTC (rev 226423)
+++ trunk/Source/WebKit/Shared/WebPageCreationParameters.cpp 2018-01-04 22:54:09 UTC (rev 226424)
@@ -87,6 +87,8 @@
encoder << availableScreenSize;
encoder << textAutosizingWidth;
encoder << ignoresViewportScaleLimits;
+ encoder << viewportConfigurationMinimumLayoutSize;
+ encoder << maximumUnobscuredSize;
#endif
#if PLATFORM(COCOA)
encoder << smartInsertDeleteEnabled;
@@ -239,6 +241,10 @@
return std::nullopt;
if (!decoder.decode(parameters.ignoresViewportScaleLimits))
return std::nullopt;
+ if (!decoder.decode(parameters.viewportConfigurationMinimumLayoutSize))
+ return std::nullopt;
+ if (!decoder.decode(parameters.maximumUnobscuredSize))
+ return std::nullopt;
#endif
#if PLATFORM(COCOA)
Modified: trunk/Source/WebKit/Shared/WebPageCreationParameters.h (226423 => 226424)
--- trunk/Source/WebKit/Shared/WebPageCreationParameters.h 2018-01-04 22:33:01 UTC (rev 226423)
+++ trunk/Source/WebKit/Shared/WebPageCreationParameters.h 2018-01-04 22:54:09 UTC (rev 226424)
@@ -144,6 +144,8 @@
WebCore::FloatSize availableScreenSize;
float textAutosizingWidth;
bool ignoresViewportScaleLimits;
+ WebCore::FloatSize viewportConfigurationMinimumLayoutSize;
+ WebCore::FloatSize maximumUnobscuredSize;
#endif
#if PLATFORM(COCOA)
bool smartInsertDeleteEnabled;
Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm (226423 => 226424)
--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm 2018-01-04 22:33:01 UTC (rev 226423)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm 2018-01-04 22:54:09 UTC (rev 226424)
@@ -4155,15 +4155,6 @@
#endif
-- (void)_didRelaunchProcess
-{
-#if PLATFORM(IOS)
- CGRect bounds = self.bounds;
- [self _dispatchSetMinimumLayoutSize:activeMinimumLayoutSize(self, bounds)];
- [self _dispatchSetMaximumUnobscuredSize:activeMaximumUnobscuredSize(self, bounds)];
-#endif
-}
-
- (NSData *)_sessionStateData
{
WebKit::SessionState sessionState = _page->sessionState();
Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivate.h (226423 => 226424)
--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivate.h 2018-01-04 22:33:01 UTC (rev 226423)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivate.h 2018-01-04 22:54:09 UTC (rev 226424)
@@ -239,7 +239,6 @@
- (void)_setOverlaidAccessoryViewsInset:(CGSize)inset;
- (void)_killWebContentProcess;
-- (void)_didRelaunchProcess;
// Puts the view into a state where being taken out of the view hierarchy and resigning first responder
// will not count as becoming inactive and unfocused. The returned block must be called to exit the state.
Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.cpp (226423 => 226424)
--- trunk/Source/WebKit/UIProcess/WebPageProxy.cpp 2018-01-04 22:33:01 UTC (rev 226423)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.cpp 2018-01-04 22:54:09 UTC (rev 226424)
@@ -5813,6 +5813,8 @@
parameters.textAutosizingWidth = textAutosizingWidth();
parameters.mimeTypesWithCustomContentProviders = m_pageClient.mimeTypesWithCustomContentProviders();
parameters.ignoresViewportScaleLimits = m_forceAlwaysUserScalable;
+ parameters.viewportConfigurationMinimumLayoutSize = m_viewportConfigurationMinimumLayoutSize;
+ parameters.maximumUnobscuredSize = m_maximumUnobscuredSize;
#endif
#if PLATFORM(MAC)
Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.h (226423 => 226424)
--- trunk/Source/WebKit/UIProcess/WebPageProxy.h 2018-01-04 22:33:01 UTC (rev 226423)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.h 2018-01-04 22:54:09 UTC (rev 226424)
@@ -2064,6 +2064,8 @@
bool m_hasDeferredStartAssistingNode { false };
std::unique_ptr<NodeAssistanceArguments> m_deferredNodeAssistanceArguments;
bool m_forceAlwaysUserScalable { false };
+ WebCore::FloatSize m_viewportConfigurationMinimumLayoutSize;
+ WebCore::FloatSize m_maximumUnobscuredSize;
#endif
#if ENABLE(POINTER_LOCK)
Modified: trunk/Source/WebKit/UIProcess/ios/PageClientImplIOS.mm (226423 => 226424)
--- trunk/Source/WebKit/UIProcess/ios/PageClientImplIOS.mm 2018-01-04 22:33:01 UTC (rev 226423)
+++ trunk/Source/WebKit/UIProcess/ios/PageClientImplIOS.mm 2018-01-04 22:54:09 UTC (rev 226424)
@@ -211,7 +211,6 @@
void PageClientImpl::didRelaunchProcess()
{
[m_contentView _didRelaunchProcess];
- [m_webView _didRelaunchProcess];
}
void PageClientImpl::pageClosed()
Modified: trunk/Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm (226423 => 226424)
--- trunk/Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm 2018-01-04 22:33:01 UTC (rev 226423)
+++ trunk/Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm 2018-01-04 22:54:09 UTC (rev 226424)
@@ -333,7 +333,10 @@
void WebPageProxy::setViewportConfigurationMinimumLayoutSize(const WebCore::FloatSize& size)
{
- m_process->send(Messages::WebPage::SetViewportConfigurationMinimumLayoutSize(size), m_pageID);
+ m_viewportConfigurationMinimumLayoutSize = size;
+
+ if (isValid())
+ m_process->send(Messages::WebPage::SetViewportConfigurationMinimumLayoutSize(size), m_pageID);
}
void WebPageProxy::setForceAlwaysUserScalable(bool userScalable)
@@ -341,12 +344,17 @@
if (m_forceAlwaysUserScalable == userScalable)
return;
m_forceAlwaysUserScalable = userScalable;
- m_process->send(Messages::WebPage::SetForceAlwaysUserScalable(userScalable), m_pageID);
+
+ if (isValid())
+ m_process->send(Messages::WebPage::SetForceAlwaysUserScalable(userScalable), m_pageID);
}
void WebPageProxy::setMaximumUnobscuredSize(const WebCore::FloatSize& size)
{
- m_process->send(Messages::WebPage::SetMaximumUnobscuredSize(size), m_pageID);
+ m_maximumUnobscuredSize = size;
+
+ if (isValid())
+ m_process->send(Messages::WebPage::SetMaximumUnobscuredSize(size), m_pageID);
}
void WebPageProxy::setDeviceOrientation(int32_t deviceOrientation)
Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp (226423 => 226424)
--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp 2018-01-04 22:33:01 UTC (rev 226423)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp 2018-01-04 22:54:09 UTC (rev 226424)
@@ -583,6 +583,11 @@
#if ENABLE(CONTENT_EXTENSIONS)
m_userContentController->addContentRuleLists(parameters.contentRuleLists);
#endif
+
+#if PLATFORM(IOS)
+ setViewportConfigurationMinimumLayoutSize(parameters.viewportConfigurationMinimumLayoutSize);
+ setMaximumUnobscuredSize(parameters.maximumUnobscuredSize);
+#endif
}
#if ENABLE(WEB_RTC)
Modified: trunk/Tools/ChangeLog (226423 => 226424)
--- trunk/Tools/ChangeLog 2018-01-04 22:33:01 UTC (rev 226423)
+++ trunk/Tools/ChangeLog 2018-01-04 22:54:09 UTC (rev 226424)
@@ -1,3 +1,17 @@
+2018-01-04 Tim Horton <timothy_hor...@apple.com>
+
+ WKWebView loses minimum layout size overrides that happen while the process is terminated
+ https://bugs.webkit.org/show_bug.cgi?id=181306
+ <rdar://problem/34398288>
+
+ Reviewed by Dan Bernstein.
+
+ * TestWebKitAPI/Tests/WebKitCocoa/AnimatedResize.mm:
+ (TEST):
+ Add a test that calling _overrideLayoutParametersWithMinimumLayoutSize
+ while the process is terminated results in the page getting the correct
+ minimum layout size.
+
2018-01-04 Eric Carlson <eric.carl...@apple.com>
[MediaStream] Add Mock screen capture source
Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/AnimatedResize.mm (226423 => 226424)
--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/AnimatedResize.mm 2018-01-04 22:33:01 UTC (rev 226423)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/AnimatedResize.mm 2018-01-04 22:54:09 UTC (rev 226424)
@@ -249,4 +249,37 @@
TestWebKitAPI::Util::run(&didReadLayoutSize);
}
+TEST(WebKit, OverrideLayoutSizeIsRestoredAfterChangingDuringProcessRelaunch)
+{
+ auto webView = createAnimatedResizeWebView();
+ [webView setUIDelegate:webView.get()];
+
+ [webView _overrideLayoutParametersWithMinimumLayoutSize:CGSizeMake(100, 100) maximumUnobscuredSizeOverride:CGSizeMake(100, 100)];
+
+ [webView loadHTMLString:@"<head><meta name='viewport' content='initial-scale=1'></head>" baseURL:nil];
+ [webView _test_waitForDidFinishNavigation];
+
+ auto window = adoptNS([[UIWindow alloc] initWithFrame:CGRectMake(0, 0, 800, 600)]);
+ [window addSubview:webView.get()];
+ [window setHidden:NO];
+
+ [webView _killWebContentProcessAndResetState];
+ [webView _overrideLayoutParametersWithMinimumLayoutSize:CGSizeMake(200, 50) maximumUnobscuredSizeOverride:CGSizeMake(200, 50)];
+
+ [webView loadHTMLString:@"<head><meta name='viewport' content='initial-scale=1'></head>" baseURL:nil];
+ [webView _test_waitForDidFinishNavigation];
+
+ __block bool didReadLayoutSize = false;
+ [webView evaluateJavaScript:@"[window.innerWidth, window.innerHeight]" completionHandler:^(id value, NSError *error) {
+ CGFloat innerWidth = [[value objectAtIndex:0] floatValue];
+ CGFloat innerHeight = [[value objectAtIndex:1] floatValue];
+
+ EXPECT_EQ(innerWidth, 200);
+ EXPECT_EQ(innerHeight, 50);
+
+ didReadLayoutSize = true;
+ }];
+ TestWebKitAPI::Util::run(&didReadLayoutSize);
+}
+
#endif