Changeset 232356 in webkit


Ignore:
Timestamp:
May 31, 2018 10:55:43 AM (6 years ago)
Author:
Antti Koivisto
Message:

WebKit memory management: Safari jetsams on some websites when zooming and scrolling
https://bugs.webkit.org/show_bug.cgi?id=186091
<rdar://problem/36315010>

Reviewed by Geoff Garen.

When zooming a page rapidly the visible rect and the page zoom level may get momentarily out of sync.
When this happens we may generate tiles for a much larger area than needed and run out of memory
building the next layer tree transaction. Running out of memory is more likely if the page has lots of
tiled layers in addition to the main content layer.

We already have code for dealing with the scale mismatch for zoom-out case (where this would cause
visibly missing tiles). This patch enables the same exact adjustment for zoom-in case (where the
symptom is creating too many tiles).

  • WebProcess/WebPage/ios/WebPageIOS.mm:

(WebKit::adjustExposedRectForNewScale):

Do some renames to make it clear that this can both expand and contract the visible rect.
Bail out if there is nothing to do.

(WebKit::WebPage::updateVisibleContentRects):

Call adjustExposedRectForNewScale directly and unconditionally.

(WebKit::adjustExposedRectForBoundedScale): Deleted.

Location:
trunk/Source/WebKit
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r232337 r232356  
     12018-05-31  Antti Koivisto  <antti@apple.com>
     2
     3        WebKit memory management: Safari jetsams on some websites when zooming and scrolling
     4        https://bugs.webkit.org/show_bug.cgi?id=186091
     5        <rdar://problem/36315010>
     6
     7        Reviewed by Geoff Garen.
     8
     9        When zooming a page rapidly the visible rect and the page zoom level may get momentarily out of sync.
     10        When this happens we may generate tiles for a much larger area than needed and run out of memory
     11        building the next layer tree transaction. Running out of memory is more likely if the page has lots of
     12        tiled layers in addition to the main content layer.
     13
     14        We already have code for dealing with the scale mismatch for zoom-out case (where this would cause
     15        visibly missing tiles). This patch enables the same exact adjustment for zoom-in case (where the
     16        symptom is creating too many tiles).
     17
     18        * WebProcess/WebPage/ios/WebPageIOS.mm:
     19        (WebKit::adjustExposedRectForNewScale):
     20
     21        Do some renames to make it clear that this can both expand and contract the visible rect.
     22        Bail out if there is nothing to do.
     23
     24        (WebKit::WebPage::updateVisibleContentRects):
     25
     26        Call adjustExposedRectForNewScale directly and unconditionally.
     27
     28        (WebKit::adjustExposedRectForBoundedScale): Deleted.
     29
    1302018-05-30  Yusuke Suzuki  <utatane.tea@gmail.com>
    231
  • trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm

    r232201 r232356  
    300300static inline FloatRect adjustExposedRectForNewScale(const FloatRect& exposedRect, double exposedRectScale, double newScale)
    301301{
    302     double overscaledWidth = exposedRect.width();
    303     double missingHorizonalMargin = exposedRect.width() * exposedRectScale / newScale - overscaledWidth;
    304 
    305     double overscaledHeight = exposedRect.height();
    306     double missingVerticalMargin = exposedRect.height() * exposedRectScale / newScale - overscaledHeight;
    307 
    308     return FloatRect(exposedRect.x() - missingHorizonalMargin / 2, exposedRect.y() - missingVerticalMargin / 2, exposedRect.width() + missingHorizonalMargin, exposedRect.height() + missingVerticalMargin);
     302    if (exposedRectScale == newScale)
     303        return exposedRect;
     304
     305    float horizontalChange = exposedRect.width() * exposedRectScale / newScale - exposedRect.width();
     306    float verticalChange = exposedRect.height() * exposedRectScale / newScale - exposedRect.height();
     307
     308    auto adjustedRect = exposedRect;
     309    adjustedRect.inflate({ horizontalChange / 2, verticalChange / 2 });
     310    return adjustedRect;
    309311}
    310312
     
    28092811}
    28102812
    2811 static inline FloatRect adjustExposedRectForBoundedScale(const FloatRect& exposedRect, double exposedRectScale, double newScale)
    2812 {
    2813     if (exposedRectScale < newScale)
    2814         return exposedRect;
    2815 
    2816     return adjustExposedRectForNewScale(exposedRect, exposedRectScale, newScale);
    2817 }
    2818 
    28192813std::optional<float> WebPage::scaleFromUIProcess(const VisibleContentRectUpdateInfo& visibleContentRectUpdateInfo) const
    28202814{
     
    28872881    float scaleToUse = scaleFromUIProcess.value_or(m_page->pageScaleFactor());
    28882882    FloatRect exposedContentRect = visibleContentRectUpdateInfo.exposedContentRect();
    2889     FloatRect adjustedExposedContentRect = adjustExposedRectForBoundedScale(exposedContentRect, visibleContentRectUpdateInfo.scale(), scaleToUse);
     2883    FloatRect adjustedExposedContentRect = adjustExposedRectForNewScale(exposedContentRect, visibleContentRectUpdateInfo.scale(), scaleToUse);
    28902884    m_drawingArea->setExposedContentRect(adjustedExposedContentRect);
    28912885
Note: See TracChangeset for help on using the changeset viewer.