Changeset 248541 in webkit


Ignore:
Timestamp:
Aug 12, 2019 12:31:21 PM (5 years ago)
Author:
Wenson Hsieh
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:
Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r248540 r248541  
     12019-08-12  Wenson Hsieh  <wenson_hsieh@apple.com>
     2
     3        [iPadOS] Web pages sometimes load at half width in Safari
     4        https://bugs.webkit.org/show_bug.cgi?id=200624
     5        <rdar://problem/52694257>
     6
     7        Reviewed by Simon Fraser.
     8
     9        Whenever WKWebView's size changes, it normally notifies the web content process by calling into WebPageProxy::
     10        setViewportConfigurationViewLayoutSize, which remembers this view layout size using a member variable,
     11        m_viewportConfigurationViewLayoutSize. Later, m_viewportConfigurationViewLayoutSize is consulted as a part of
     12        constructing the creation parameters used to set up a new page.
     13
     14        However, during animated resize, WKWebView avoids these calls to setViewportConfigurationViewLayoutSize via the
     15        dynamic viewport update mode check in -[WKWebView _frameOrBoundsChanged]. Instead, the new view layout size is
     16        pushed to the web process by calling WebPageProxy::dynamicViewportSizeUpdate.
     17
     18        Since dynamicViewportSizeUpdate doesn't update m_viewportConfigurationViewLayoutSize, the next
     19        WebPageCreationParameters that are created with this WebPageProxy (e.g. after a process swap, or after
     20        reloading, if the process was terminated) will use the size of the WKWebView prior to the most recent animated
     21        resize.
     22
     23        To fix the bug, we simply make sure that m_viewportConfigurationViewLayoutSize is updated in the dynamic
     24        viewport size update (i.e. animated resize) case as well.
     25
     26        Test: WebKit.CreateWebPageAfterAnimatedResize
     27
     28        * UIProcess/ios/WebPageProxyIOS.mm:
     29        (WebKit::WebPageProxy::dynamicViewportSizeUpdate):
     30
    1312019-08-12  Chris Dumez  <cdumez@apple.com>
    232
  • trunk/Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm

    r248502 r248541  
    301301    hideValidationMessage();
    302302
     303    m_viewportConfigurationViewLayoutSize = viewLayoutSize;
    303304    m_process->send(Messages::WebPage::DynamicViewportSizeUpdate(viewLayoutSize,
    304305        maximumUnobscuredSize, targetExposedContentRect, targetUnobscuredRect,
  • trunk/Tools/ChangeLog

    r248531 r248541  
     12019-08-12  Wenson Hsieh  <wenson_hsieh@apple.com>
     2
     3        [iPadOS] Web pages sometimes load at half width in Safari
     4        https://bugs.webkit.org/show_bug.cgi?id=200624
     5        <rdar://problem/52694257>
     6
     7        Reviewed by Simon Fraser.
     8
     9        Add an API test to verify that after performing an animated resize and killing the web process, the subsequent
     10        web page is created using the post-animated-resize web view dimensions, rather than the original layout
     11        dimensions.
     12
     13        * TestWebKitAPI/Tests/WebKitCocoa/AnimatedResize.mm:
     14
    1152019-08-12  Daniel Bates  <dabates@apple.com>
    216
  • trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/AnimatedResize.mm

    r242339 r248541  
    2929#import "Test.h"
    3030#import "TestNavigationDelegate.h"
     31#import "TestWKWebView.h"
    3132#import <WebKit/WKPreferences.h>
    3233#import <WebKit/WKProcessPoolPrivate.h>
     
    429430}
    430431
     432TEST(WebKit, CreateWebPageAfterAnimatedResize)
     433{
     434    auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, 1024, 768)]);
     435    [webView synchronouslyLoadTestPageNamed:@"large-red-square-image"];
     436
     437    [webView _beginAnimatedResizeWithUpdates:^{
     438        [webView setFrame:CGRectMake(0, 0, 768, 1024)];
     439    }];
     440
     441    __block bool doneWaitingForPresentationUpdate = false;
     442    [webView _doAfterNextPresentationUpdate:^{
     443        doneWaitingForPresentationUpdate = true;
     444    }];
     445
     446    [webView _doAfterNextPresentationUpdateWithoutWaitingForAnimatedResizeForTesting:^{
     447        [webView _endAnimatedResize];
     448    }];
     449
     450    TestWebKitAPI::Util::run(&doneWaitingForPresentationUpdate);
     451
     452    [webView _killWebContentProcessAndResetState];
     453    [webView synchronouslyLoadTestPageNamed:@"large-red-square-image"];
     454
     455    NSArray<NSNumber *> *dimensions = [webView objectByEvaluatingJavaScript:@"[innerWidth, innerHeight]"];
     456    EXPECT_EQ(768, dimensions.firstObject.intValue);
     457    EXPECT_EQ(1024, dimensions.lastObject.intValue);
     458}
     459
    431460#endif
Note: See TracChangeset for help on using the changeset viewer.