Changeset 233561 in webkit


Ignore:
Timestamp:
Jul 5, 2018, 9:56:40 PM (7 years ago)
Author:
Simon Fraser
Message:

Address two possible causes of missing tiles in iOS Safari, and add logging to gather more data about other possible causes
https://bugs.webkit.org/show_bug.cgi?id=187376
rdar://problem/40941118

Reviewed by Tim Horton.

We have continual reports of users experiencing missing tiles in MobileSafari, where loading a page
shows the tiles at the top, but we don't render new tiles as the user scrolls down. This is consistent
with failing to dispatch visible content rect updates via -[WKWebView _updateVisibleContentRects].

This patch addresses two possible (but unlikely) causes. First, it resets _currentlyAdjustingScrollViewInsetsForKeyboard
after a web process crash. Second, it catches exceptions thrown by [webView _updateVisibleContentRects]
and resets _hasScheduledVisibleRectUpdate.

This patch also adds release logging that fires if over 1s has elapsed between scheduling
a visible content rect update and trying to re-schedule, and logging for all reasons that
-_updateVisibleContentRects returns early.

  • UIProcess/API/Cocoa/WKWebView.mm:

(-[WKWebView _initializeWithConfiguration:]):
(-[WKWebView _processDidExit]):
(-[WKWebView _addUpdateVisibleContentRectPreCommitHandler]):
(-[WKWebView _scheduleVisibleContentRectUpdateAfterScrollInView:]):
(-[WKWebView _updateVisibleContentRects]):

Location:
trunk/Source/WebKit
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r233553 r233561  
     12018-07-05  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Address two possible causes of missing tiles in iOS Safari, and add logging to gather more data about other possible causes
     4        https://bugs.webkit.org/show_bug.cgi?id=187376
     5        rdar://problem/40941118
     6
     7        Reviewed by Tim Horton.
     8       
     9        We have continual reports of users experiencing missing tiles in MobileSafari, where loading a page
     10        shows the tiles at the top, but we don't render new tiles as the user scrolls down. This is consistent
     11        with failing to dispatch visible content rect updates via -[WKWebView _updateVisibleContentRects].
     12       
     13        This patch addresses two possible (but unlikely) causes. First, it resets _currentlyAdjustingScrollViewInsetsForKeyboard
     14        after a web process crash. Second, it catches exceptions thrown by [webView _updateVisibleContentRects]
     15        and resets _hasScheduledVisibleRectUpdate.
     16       
     17        This patch also adds release logging that fires if over 1s has elapsed between scheduling
     18        a visible content rect update and trying to re-schedule, and logging for all reasons that
     19        -_updateVisibleContentRects returns early.
     20
     21        * UIProcess/API/Cocoa/WKWebView.mm:
     22        (-[WKWebView _initializeWithConfiguration:]):
     23        (-[WKWebView _processDidExit]):
     24        (-[WKWebView _addUpdateVisibleContentRectPreCommitHandler]):
     25        (-[WKWebView _scheduleVisibleContentRectUpdateAfterScrollInView:]):
     26        (-[WKWebView _updateVisibleContentRects]):
     27
    1282018-07-05  Olivia Barnett  <obarnett@apple.com>
    229
  • trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm

    r233552 r233561  
    182182#if PLATFORM(IOS)
    183183static const uint32_t firstSDKVersionWithLinkPreviewEnabledByDefault = 0xA0000;
     184static const Seconds delayBeforeNoVisibleContentsRectsLogging = 1_s;
    184185#endif
    185186
     
    357358
    358359    _WKDragInteractionPolicy _dragInteractionPolicy;
     360
     361    // For release-logging for <rdar://problem/39281269>.
     362    MonotonicTime _timeOfRequestForVisibleContentRectUpdate;
     363    MonotonicTime _timeOfLastVisibleContentRectUpdate;
    359364#endif
    360365#if PLATFORM(MAC)
     
    727732#if PLATFORM(IOS)
    728733    _dragInteractionPolicy = _WKDragInteractionPolicyDefault;
     734
     735    _timeOfRequestForVisibleContentRectUpdate = MonotonicTime::now();
     736    _timeOfLastVisibleContentRectUpdate = MonotonicTime::now();
    729737#if PLATFORM(WATCHOS)
    730738    _allowsViewportShrinkToFit = YES;
     
    16931701    _delayUpdateVisibleContentRects = NO;
    16941702    _hadDelayedUpdateVisibleContentRects = NO;
     1703    _currentlyAdjustingScrollViewInsetsForKeyboard = NO;
    16951704    _lastSentViewLayoutSize = std::nullopt;
    16961705    _lastSentMaximumUnobscuredSize = std::nullopt;
     
    27122721    [CATransaction addCommitHandler:[retainedSelf] {
    27132722        WKWebView *webView = retainedSelf.get();
    2714         if (![webView _isValid])
     2723        if (![webView _isValid]) {
     2724            RELEASE_LOG_IF(webView._page && webView._page->isAlwaysOnLoggingAllowed(), ViewState, "In CATransaction preCommitHandler, WKWebView %p is invalid", webView);
    27152725            return;
    2716         [webView _updateVisibleContentRects];
     2726        }
     2727
     2728        @try {
     2729            [webView _updateVisibleContentRects];
     2730        } @catch (NSException *exception) {
     2731            RELEASE_LOG_IF(webView._page && webView._page->isAlwaysOnLoggingAllowed(), ViewState, "In CATransaction preCommitHandler, -[WKWebView %p _updateVisibleContentRects] threw an exception", webView);
     2732        }
    27172733        webView->_hasScheduledVisibleRectUpdate = NO;
    27182734    } forPhase:kCATransactionPhasePreCommit];
     
    27212737- (void)_scheduleVisibleContentRectUpdateAfterScrollInView:(UIScrollView *)scrollView
    27222738{
     2739    RELEASE_ASSERT(isMainThread());
     2740
    27232741    _visibleContentRectUpdateScheduledFromScrollViewInStableState = [self _scrollViewIsInStableState:scrollView];
    27242742
    2725     if (_hasScheduledVisibleRectUpdate)
     2743    if (_hasScheduledVisibleRectUpdate) {
     2744        auto timeNow = MonotonicTime::now();
     2745        if ((timeNow - _timeOfRequestForVisibleContentRectUpdate) > delayBeforeNoVisibleContentsRectsLogging) {
     2746            RELEASE_LOG_IF_ALLOWED("-[WKWebView %p _scheduleVisibleContentRectUpdateAfterScrollInView]: _hasScheduledVisibleRectUpdate is true but haven't updated visible content rects for %.2fs (last update was %.2fs ago)",
     2747                self, (timeNow - _timeOfRequestForVisibleContentRectUpdate).value(), (timeNow - _timeOfLastVisibleContentRectUpdate).value());
     2748        }
    27262749        return;
     2750    }
    27272751
    27282752    _hasScheduledVisibleRectUpdate = YES;
     2753    _timeOfRequestForVisibleContentRectUpdate = MonotonicTime::now();
    27292754
    27302755    CATransactionPhase transactionPhase = [CATransaction currentPhase];
     
    27872812        [_passwordView setFrame:self.bounds];
    27882813        [_customContentView web_computedContentInsetDidChange];
     2814        RELEASE_LOG_IF_ALLOWED("%p -[WKWebView _updateVisibleContentRects:] - usesStandardContentView is NO, bailing", self);
    27892815        return;
    27902816    }
     
    27922818    if (_delayUpdateVisibleContentRects) {
    27932819        _hadDelayedUpdateVisibleContentRects = YES;
     2820        RELEASE_LOG_IF_ALLOWED("%p -[WKWebView _updateVisibleContentRects:] - _delayUpdateVisibleContentRects is YES, bailing", self);
    27942821        return;
    27952822    }
     
    27982825        || (_needsResetViewStateAfterCommitLoadForMainFrame && ![_contentView sizeChangedSinceLastVisibleContentRectUpdate])
    27992826        || [_scrollView isZoomBouncing]
    2800         || _currentlyAdjustingScrollViewInsetsForKeyboard)
     2827        || _currentlyAdjustingScrollViewInsetsForKeyboard) {
     2828        RELEASE_LOG_IF_ALLOWED("%p -[WKWebView _updateVisibleContentRects:] - scroll view state is non-stable, bailing (_dynamicViewportUpdateMode %d, _needsResetViewStateAfterCommitLoadForMainFrame %d, sizeChangedSinceLastVisibleContentRectUpdate %d, [_scrollView isZoomBouncing] %d, _currentlyAdjustingScrollViewInsetsForKeyboard %d)",
     2829            self, _dynamicViewportUpdateMode, _needsResetViewStateAfterCommitLoadForMainFrame, [_contentView sizeChangedSinceLastVisibleContentRectUpdate], [_scrollView isZoomBouncing], _currentlyAdjustingScrollViewInsetsForKeyboard);
    28012830        return;
     2831    }
    28022832
    28032833    CGRect visibleRectInContentCoordinates = [self _visibleContentRect];
     
    28452875        callback();
    28462876    }
     2877   
     2878    auto timeNow = MonotonicTime::now();
     2879    if ((timeNow - _timeOfRequestForVisibleContentRectUpdate) > delayBeforeNoVisibleContentsRectsLogging)
     2880        RELEASE_LOG_IF_ALLOWED("%p -[WKWebView _updateVisibleContentRects:] finally ran %.2fs after begin scheduled", self, (timeNow - _timeOfRequestForVisibleContentRectUpdate).value());
     2881
     2882    _timeOfLastVisibleContentRectUpdate = timeNow;
    28472883}
    28482884
Note: See TracChangeset for help on using the changeset viewer.