Changeset 214391 in webkit


Ignore:
Timestamp:
Mar 24, 2017 6:04:32 PM (7 years ago)
Author:
Simon Fraser
Message:

[iOS WK2] Move from a pre-commit handler to dispatch_async for visible content rect updates
https://bugs.webkit.org/show_bug.cgi?id=170091
rdar://problem/30682584

Reviewed by Tim Horton.

[CATransaction addCommitHandler:forPhase:] is sometimes not called when running inside another
commit callback (rdar://problem/31253952), and we don't yet have a reliable way to detect this.

So dispatch_async() to postpone the call to [CATransaction addCommitHandler:forPhase:] to a known-
good time.

  • UIProcess/API/Cocoa/WKWebView.mm:

(-[WKWebView _scheduleVisibleContentRectUpdateAfterScrollInView:]):

Location:
trunk/Source/WebKit2
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r214389 r214391  
     12017-03-24  Simon Fraser  <simon.fraser@apple.com>
     2
     3        [iOS WK2] Move from a pre-commit handler to dispatch_async for visible content rect updates
     4        https://bugs.webkit.org/show_bug.cgi?id=170091
     5        rdar://problem/30682584
     6
     7        Reviewed by Tim Horton.
     8       
     9        [CATransaction addCommitHandler:forPhase:] is sometimes not called when running inside another
     10        commit callback (rdar://problem/31253952), and we don't yet have a reliable way to detect this.
     11
     12        So dispatch_async() to postpone the call to [CATransaction addCommitHandler:forPhase:] to a known-
     13        good time.
     14
     15        * UIProcess/API/Cocoa/WKWebView.mm:
     16        (-[WKWebView _scheduleVisibleContentRectUpdateAfterScrollInView:]):
     17
    1182017-03-24  John Wilander  <wilander@apple.com>
    219
  • trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm

    r214113 r214391  
    289289    RetainPtr<WKPasswordView> _passwordView;
    290290
    291     BOOL _hasInstalledPreCommitHandlerForVisibleRectUpdate;
     291    BOOL _hasScheduledVisibleRectUpdate;
    292292    BOOL _visibleContentRectUpdateScheduledFromScrollViewInStableState;
    293293    Vector<BlockPtr<void ()>> _visibleContentRectUpdateCallbacks;
     
    23022302    _visibleContentRectUpdateScheduledFromScrollViewInStableState = [self _scrollViewIsInStableState:scrollView];
    23032303
    2304     if (_hasInstalledPreCommitHandlerForVisibleRectUpdate)
     2304    if (_hasScheduledVisibleRectUpdate)
    23052305        return;
    23062306
    2307     _hasInstalledPreCommitHandlerForVisibleRectUpdate = YES;
    2308 
    2309     [CATransaction addCommitHandler:[retainedSelf = retainPtr(self)] {
    2310         WKWebView *webView = retainedSelf.get();
    2311         [webView _updateVisibleContentRects];
    2312         webView->_hasInstalledPreCommitHandlerForVisibleRectUpdate = NO;
    2313     } forPhase:kCATransactionPhasePreCommit];
     2307    _hasScheduledVisibleRectUpdate = YES;
     2308   
     2309    // FIXME: remove the dispatch_async() when we have a fix for rdar://problem/31253952.
     2310    dispatch_async(dispatch_get_main_queue(), [retainedSelf = retainPtr(self)] {
     2311        [CATransaction addCommitHandler:[retainedSelf] {
     2312            WKWebView *webView = retainedSelf.get();
     2313            [webView _updateVisibleContentRects];
     2314            webView->_hasScheduledVisibleRectUpdate = NO;
     2315        } forPhase:kCATransactionPhasePreCommit];
     2316    });
    23142317}
    23152318
Note: See TracChangeset for help on using the changeset viewer.