Changeset 274941 in webkit


Ignore:
Timestamp:
Mar 24, 2021, 9:45:11 AM (4 years ago)
Author:
commit-queue@webkit.org
Message:

Ignore middle commits during animated resize
https://bugs.webkit.org/show_bug.cgi?id=223530

Patch by Sihui Liu <sihui_liu@appe.com> on 2021-03-24
Reviewed by Tim Horton.

For animated resize, UI process sets layer transform to fit new size until web process picks up size change and
paints. It is possible that UI process receives a commit during animated resize and the commit is not for the
animated resize (web process commits before animated resize). In this case, our current implementation is: if
SPI client species there will be no other update (!_waitingForEndAnimatedResize), we change layer transform to
reflect change of the middle commit.

However, that commit does not mean web process issues new paint, so the adjustment can be wrong. We find the
handling of middle commits causes issues in SPI client's use case (rdar://47623140). Also by manual testing,
it's not clear how the code can benefit current SPI clients. It seems to cause the same trouble sometimes. So
let's just remove it.

  • UIProcess/API/ios/WKWebViewIOS.mm:

(-[WKWebView _didCommitLayerTreeDuringAnimatedResize:]):

Location:
trunk/Source/WebKit
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r274938 r274941  
     12021-03-24  Sihui Liu  <sihui_liu@appe.com>
     2
     3        Ignore middle commits during animated resize
     4        https://bugs.webkit.org/show_bug.cgi?id=223530
     5
     6        Reviewed by Tim Horton.
     7
     8        For animated resize, UI process sets layer transform to fit new size until web process picks up size change and
     9        paints. It is possible that UI process receives a commit during animated resize and the commit is not for the
     10        animated resize (web process commits before animated resize). In this case, our current implementation is: if
     11        SPI client species there will be no other update (!_waitingForEndAnimatedResize), we change layer transform to
     12        reflect change of the middle commit.
     13
     14        However, that commit does not mean web process issues new paint, so the adjustment can be wrong. We find the
     15        handling of middle commits causes issues in SPI client's use case  (rdar://47623140). Also by manual testing,
     16        it's not clear how the code can benefit current SPI clients. It seems to cause the same trouble sometimes. So
     17        let's just remove it.
     18
     19        * UIProcess/API/ios/WKWebViewIOS.mm:
     20        (-[WKWebView _didCommitLayerTreeDuringAnimatedResize:]):
     21
    1222021-03-24  Per Arne  <pvollan@apple.com>
    223
  • trunk/Source/WebKit/UIProcess/API/ios/WKWebViewIOS.mm

    r274692 r274941  
    756756{
    757757    auto updateID = layerTreeTransaction.dynamicViewportSizeUpdateID();
    758     if (updateID && *updateID == _currentDynamicViewportSizeUpdateID) {
    759         double pageScale = layerTreeTransaction.pageScaleFactor();
    760         WebCore::IntPoint scrollPosition = layerTreeTransaction.scrollPosition();
    761 
    762         CGFloat animatingScaleTarget = [[_resizeAnimationView layer] transform].m11;
    763         double currentTargetScale = animatingScaleTarget * [[_contentView layer] transform].m11;
    764         double scale = pageScale / currentTargetScale;
    765         _resizeAnimationTransformAdjustments = CATransform3DMakeScale(scale, scale, 1);
    766 
    767         CGPoint newContentOffset = [self _contentOffsetAdjustedForObscuredInset:CGPointMake(scrollPosition.x() * pageScale, scrollPosition.y() * pageScale)];
    768         CGPoint currentContentOffset = [_scrollView contentOffset];
    769 
    770         _resizeAnimationTransformAdjustments.m41 = (currentContentOffset.x - newContentOffset.x) / animatingScaleTarget;
    771         _resizeAnimationTransformAdjustments.m42 = (currentContentOffset.y - newContentOffset.y) / animatingScaleTarget;
    772 
    773         [_resizeAnimationView layer].sublayerTransform = _resizeAnimationTransformAdjustments;
    774 
    775         // If we've already passed endAnimatedResize, immediately complete
    776         // the resize when we have an up-to-date layer tree. Otherwise,
    777         // we will defer completion until endAnimatedResize.
    778         _waitingForCommitAfterAnimatedResize = NO;
    779         if (!_waitingForEndAnimatedResize)
    780             [self _didCompleteAnimatedResize];
    781 
    782         return;
    783     }
    784 
    785     // If a commit arrives during the live part of a resize but before the
    786     // layer tree takes the current resize into account, it could change the
    787     // WKContentView's size. Update the resizeAnimationView's scale to ensure
    788     // we continue to fill the width of the resize target.
    789 
    790     if (_waitingForEndAnimatedResize)
    791         return;
    792 
    793     auto newViewLayoutSize = [self activeViewLayoutSize:self.bounds];
    794     CGFloat resizeAnimationViewScale = _animatedResizeOriginalContentWidth / newViewLayoutSize.width();
    795     [[_resizeAnimationView layer] setSublayerTransform:CATransform3DMakeScale(resizeAnimationViewScale, resizeAnimationViewScale, 1)];
     758    if (updateID != _currentDynamicViewportSizeUpdateID)
     759        return;
     760
     761    double pageScale = layerTreeTransaction.pageScaleFactor();
     762    WebCore::IntPoint scrollPosition = layerTreeTransaction.scrollPosition();
     763
     764    CGFloat animatingScaleTarget = [[_resizeAnimationView layer] transform].m11;
     765    double currentTargetScale = animatingScaleTarget * [[_contentView layer] transform].m11;
     766    double scale = pageScale / currentTargetScale;
     767    _resizeAnimationTransformAdjustments = CATransform3DMakeScale(scale, scale, 1);
     768
     769    CGPoint newContentOffset = [self _contentOffsetAdjustedForObscuredInset:CGPointMake(scrollPosition.x() * pageScale, scrollPosition.y() * pageScale)];
     770    CGPoint currentContentOffset = [_scrollView contentOffset];
     771
     772    _resizeAnimationTransformAdjustments.m41 = (currentContentOffset.x - newContentOffset.x) / animatingScaleTarget;
     773    _resizeAnimationTransformAdjustments.m42 = (currentContentOffset.y - newContentOffset.y) / animatingScaleTarget;
     774
     775    [_resizeAnimationView layer].sublayerTransform = _resizeAnimationTransformAdjustments;
     776
     777    // If we've already passed endAnimatedResize, immediately complete
     778    // the resize when we have an up-to-date layer tree. Otherwise,
     779    // we will defer completion until endAnimatedResize.
     780    _waitingForCommitAfterAnimatedResize = NO;
     781    if (!_waitingForEndAnimatedResize)
     782        [self _didCompleteAnimatedResize];
    796783}
    797784
Note: See TracChangeset for help on using the changeset viewer.