Bug 158933 - [iOS][WK2] When an animation frame is missed, the UI process should immediately notify the Web process once a frame is committed
Summary: [iOS][WK2] When an animation frame is missed, the UI process should immediate...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Animations (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Said Abou-Hallawa
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2016-06-20 00:52 PDT by Said Abou-Hallawa
Modified: 2016-06-21 13:53 PDT (History)
4 users (show)

See Also:


Attachments
Patch (5.46 KB, patch)
2016-06-20 01:00 PDT, Said Abou-Hallawa
no flags Details | Formatted Diff | Diff
Patch (4.14 KB, patch)
2016-06-21 12:20 PDT, Said Abou-Hallawa
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Said Abou-Hallawa 2016-06-20 00:52:39 PDT
When a frame is committed, the UI process schedules a CADisplayLink and waits until the next didRefreshDisplay event is fired. This causes more delay in the scenario where there are frames are dropped. didRefreshDisplay() should be called immediately when commitLayerTree message is received and the last frame was dropped.

The fix is to have the CADisplayLink active all the times. It should be paused only when we detect at least one frame is dropped. In this case we should not send a message to the UI process since it has not sent the last requested LayerTree. Also we should not waste the CPU time by scheduling a new CADisplayLink since we have not processed the last event. We should resume CADisplayLink timer once a commitLayerTree message is received.

We are going to introduce the state variable m_didUpdateMessageState to RemoteLayerTreeDrawingAreaProxy whose value is one of the following: { NotSent, Sent, MissedCommit }. Here is its state table. The only events that affect its value are commitLayerTree() and didRefreshDisplay()


CurrentValue           commitLayerTree                            didRefreshDisplay
  NotSent                  NotSent                                  Sent          (message is sent to the WebProcess)
  Sent                     NotSent                                  MissedCommit  (no message is sent and the CADisplayLink is paused)
  MissedCommit             NotSent (call didRefreshDisplay())       MissedCommit  (no message)
Comment 1 Said Abou-Hallawa 2016-06-20 01:00:55 PDT
Created attachment 281637 [details]
Patch
Comment 2 Tim Horton 2016-06-20 10:31:51 PDT
Comment on attachment 281637 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=281637&action=review

> Source/WebKit2/ChangeLog:30
> +        * UIProcess/mac/RemoteLayerTreeDrawingAreaProxy.h:
> +        * UIProcess/mac/RemoteLayerTreeDrawingAreaProxy.mm:
> +        (-[WKOneShotDisplayLinkHandler pause]):
> +        (WebKit::RemoteLayerTreeDrawingAreaProxy::commitLayerTree):
> +        (WebKit::RemoteLayerTreeDrawingAreaProxy::didRefreshDisplay):
> +        (-[WKOneShotDisplayLinkHandler displayLinkFired:]): Deleted.
> +        * WebProcess/WebPage/mac/RemoteLayerTreeDrawingArea.mm:
> +        (WebKit::RemoteLayerTreeDrawingArea::BackingStoreFlusher::flush):
> +        We should clear the graphics contexts when the drawing layers are flushed
> +        in the commitQueue thread instead of delaying this to be done in the main
> +        thread when the old m_pendingBackingStoreFlusher is released.

This should probably happen in a different patch so we can separate the performance impact of the two unrelated changes.
Comment 3 Said Abou-Hallawa 2016-06-20 13:25:53 PDT
<rdar://problem/23490249>
Comment 4 Said Abou-Hallawa 2016-06-21 12:20:54 PDT
Created attachment 281768 [details]
Patch
Comment 5 Said Abou-Hallawa 2016-06-21 12:22:44 PDT
Comment on attachment 281637 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=281637&action=review

>> Source/WebKit2/ChangeLog:30
>> +        thread when the old m_pendingBackingStoreFlusher is released.
> 
> This should probably happen in a different patch so we can separate the performance impact of the two unrelated changes.

This part was removed but I did not notice much difference in MotionMark score between adding it or removing it. So I am mot sure if it is worth adding it a separate patch even.
Comment 6 Said Abou-Hallawa 2016-06-21 12:32:44 PDT
This patch shows 8% progression in MotionMark score on iPad Air.
Comment 7 WebKit Commit Bot 2016-06-21 13:53:55 PDT
Comment on attachment 281768 [details]
Patch

Clearing flags on attachment: 281768

Committed r202291: <http://trac.webkit.org/changeset/202291>
Comment 8 WebKit Commit Bot 2016-06-21 13:53:59 PDT
All reviewed patches have been landed.  Closing bug.