Title: [248541] trunk
Revision
248541
Author
wenson_hs...@apple.com
Date
2019-08-12 12:31:21 -0700 (Mon, 12 Aug 2019)

Log Message

[iPadOS] Web pages sometimes load at half width in Safari
https://bugs.webkit.org/show_bug.cgi?id=200624
<rdar://problem/52694257>

Reviewed by Simon Fraser.

Source/WebKit:

Whenever WKWebView's size changes, it normally notifies the web content process by calling into WebPageProxy::
setViewportConfigurationViewLayoutSize, which remembers this view layout size using a member variable,
m_viewportConfigurationViewLayoutSize. Later, m_viewportConfigurationViewLayoutSize is consulted as a part of
constructing the creation parameters used to set up a new page.

However, during animated resize, WKWebView avoids these calls to setViewportConfigurationViewLayoutSize via the
dynamic viewport update mode check in -[WKWebView _frameOrBoundsChanged]. Instead, the new view layout size is
pushed to the web process by calling WebPageProxy::dynamicViewportSizeUpdate.

Since dynamicViewportSizeUpdate doesn't update m_viewportConfigurationViewLayoutSize, the next
WebPageCreationParameters that are created with this WebPageProxy (e.g. after a process swap, or after
reloading, if the process was terminated) will use the size of the WKWebView prior to the most recent animated
resize.

To fix the bug, we simply make sure that m_viewportConfigurationViewLayoutSize is updated in the dynamic
viewport size update (i.e. animated resize) case as well.

Test: WebKit.CreateWebPageAfterAnimatedResize

* UIProcess/ios/WebPageProxyIOS.mm:
(WebKit::WebPageProxy::dynamicViewportSizeUpdate):

Tools:

Add an API test to verify that after performing an animated resize and killing the web process, the subsequent
web page is created using the post-animated-resize web view dimensions, rather than the original layout
dimensions.

* TestWebKitAPI/Tests/WebKitCocoa/AnimatedResize.mm:

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (248540 => 248541)


--- trunk/Source/WebKit/ChangeLog	2019-08-12 19:22:24 UTC (rev 248540)
+++ trunk/Source/WebKit/ChangeLog	2019-08-12 19:31:21 UTC (rev 248541)
@@ -1,3 +1,33 @@
+2019-08-12  Wenson Hsieh  <wenson_hs...@apple.com>
+
+        [iPadOS] Web pages sometimes load at half width in Safari
+        https://bugs.webkit.org/show_bug.cgi?id=200624
+        <rdar://problem/52694257>
+
+        Reviewed by Simon Fraser.
+
+        Whenever WKWebView's size changes, it normally notifies the web content process by calling into WebPageProxy::
+        setViewportConfigurationViewLayoutSize, which remembers this view layout size using a member variable,
+        m_viewportConfigurationViewLayoutSize. Later, m_viewportConfigurationViewLayoutSize is consulted as a part of
+        constructing the creation parameters used to set up a new page.
+
+        However, during animated resize, WKWebView avoids these calls to setViewportConfigurationViewLayoutSize via the
+        dynamic viewport update mode check in -[WKWebView _frameOrBoundsChanged]. Instead, the new view layout size is
+        pushed to the web process by calling WebPageProxy::dynamicViewportSizeUpdate.
+
+        Since dynamicViewportSizeUpdate doesn't update m_viewportConfigurationViewLayoutSize, the next
+        WebPageCreationParameters that are created with this WebPageProxy (e.g. after a process swap, or after
+        reloading, if the process was terminated) will use the size of the WKWebView prior to the most recent animated
+        resize.
+
+        To fix the bug, we simply make sure that m_viewportConfigurationViewLayoutSize is updated in the dynamic
+        viewport size update (i.e. animated resize) case as well.
+
+        Test: WebKit.CreateWebPageAfterAnimatedResize
+
+        * UIProcess/ios/WebPageProxyIOS.mm:
+        (WebKit::WebPageProxy::dynamicViewportSizeUpdate):
+
 2019-08-12  Chris Dumez  <cdu...@apple.com>
 
         Crash under NetworkResourceLoader::start()

Modified: trunk/Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm (248540 => 248541)


--- trunk/Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm	2019-08-12 19:22:24 UTC (rev 248540)
+++ trunk/Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm	2019-08-12 19:31:21 UTC (rev 248541)
@@ -300,6 +300,7 @@
 
     hideValidationMessage();
 
+    m_viewportConfigurationViewLayoutSize = viewLayoutSize;
     m_process->send(Messages::WebPage::DynamicViewportSizeUpdate(viewLayoutSize,
         maximumUnobscuredSize, targetExposedContentRect, targetUnobscuredRect,
         targetUnobscuredRectInScrollViewCoordinates, unobscuredSafeAreaInsets,

Modified: trunk/Tools/ChangeLog (248540 => 248541)


--- trunk/Tools/ChangeLog	2019-08-12 19:22:24 UTC (rev 248540)
+++ trunk/Tools/ChangeLog	2019-08-12 19:31:21 UTC (rev 248541)
@@ -1,3 +1,17 @@
+2019-08-12  Wenson Hsieh  <wenson_hs...@apple.com>
+
+        [iPadOS] Web pages sometimes load at half width in Safari
+        https://bugs.webkit.org/show_bug.cgi?id=200624
+        <rdar://problem/52694257>
+
+        Reviewed by Simon Fraser.
+
+        Add an API test to verify that after performing an animated resize and killing the web process, the subsequent
+        web page is created using the post-animated-resize web view dimensions, rather than the original layout
+        dimensions.
+
+        * TestWebKitAPI/Tests/WebKitCocoa/AnimatedResize.mm:
+
 2019-08-12  Daniel Bates  <daba...@apple.com>
 
         Add a test to ensure that we dispatch keydown and keyup events when multiple keys are pressed at the same time

Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/AnimatedResize.mm (248540 => 248541)


--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/AnimatedResize.mm	2019-08-12 19:22:24 UTC (rev 248540)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/AnimatedResize.mm	2019-08-12 19:31:21 UTC (rev 248541)
@@ -28,6 +28,7 @@
 #import "PlatformUtilities.h"
 #import "Test.h"
 #import "TestNavigationDelegate.h"
+#import "TestWKWebView.h"
 #import <WebKit/WKPreferences.h>
 #import <WebKit/WKProcessPoolPrivate.h>
 #import <WebKit/WKWebView.h>
@@ -428,4 +429,32 @@
     TestWebKitAPI::Util::run(&didGetCommitAfterEndAnimatedResize);
 }
 
+TEST(WebKit, CreateWebPageAfterAnimatedResize)
+{
+    auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, 1024, 768)]);
+    [webView synchronouslyLoadTestPageNamed:@"large-red-square-image"];
+
+    [webView _beginAnimatedResizeWithUpdates:^{
+        [webView setFrame:CGRectMake(0, 0, 768, 1024)];
+    }];
+
+    __block bool doneWaitingForPresentationUpdate = false;
+    [webView _doAfterNextPresentationUpdate:^{
+        doneWaitingForPresentationUpdate = true;
+    }];
+
+    [webView _doAfterNextPresentationUpdateWithoutWaitingForAnimatedResizeForTesting:^{
+        [webView _endAnimatedResize];
+    }];
+
+    TestWebKitAPI::Util::run(&doneWaitingForPresentationUpdate);
+
+    [webView _killWebContentProcessAndResetState];
+    [webView synchronouslyLoadTestPageNamed:@"large-red-square-image"];
+
+    NSArray<NSNumber *> *dimensions = [webView objectByEvaluatingJavaScript:@"[innerWidth, innerHeight]"];
+    EXPECT_EQ(768, dimensions.firstObject.intValue);
+    EXPECT_EQ(1024, dimensions.lastObject.intValue);
+}
+
 #endif
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to