cc: Avoid unnecessary pending trees during image animation updates.
CURRENT CODE: The current flow of animations initiated by the ImageAnimationController is as follows: 1) Each time a pending tree is updated, which is when animated images from display lists would have been registered with the controller, we compute the earliest time the next animation update will be needed and schedule a delayed task to trigger an invalidation. 2) The delayed task triggers an invalidation, which update the frame on the sync tree created as a result. And schedules the next invalidation if needed. THE BUG: In the steps above, first for progressing the animation on the sync tree and for scheduling the delayed task, we use the frame_time from the BeginFrameArgs of the current frame as the "now" time. This resulted in 2 bugs: 1) Since the delayed task could be scheduled at any time within the impl frame, using the frame_time from BeginFrameArgs as now was incorrect and the delayed task would run at an unexpected time. 2) When the task did run at the correct time, resulting in an invalidation, the pending tree would not be updated if the frame times of the animation did not align with the BeginFrame frame times. For instance, if the frame time is 0ms and the animation wants to run at 8ms. Even if the invalidation runs at 8ms, the "now" time would be the BeginFrame frame_time, which is 0ms and earlier than when the animation wants to run. This would create wasted pending trees. FIX: This patch fixes the above by changing some fundamental aspects of how image animations are progressed. 1) Instead of respecting the frame durations associated with the animated image completely, snap them to frame boundaries. This ensures that the animation always starts at the beginning of the frame in which the desired time lies. This is also the optimal time to start the work for the frame in which the animation wants to update. 2) Instead of always requesting an invalidation at the time for the next animation update, request an impl frame instead. At the beginning of the impl frame, upgrade it to an invalidation request if the frame_time for that impl frame ensures that the animation will be updated. This avoids a race between triggering an invalidation and receiving the target BeginFrame in the renderer. R=enne@chromium.org,sunnyps@chromium.org Change-Id: Iffcaafc3dd72f7649ada1eceea2835054c44e911 Reviewed-on: https://chromium-review.googlesource.com/c/1464972 Commit-Queue: Khushal <khushalsagar@chromium.org> Reviewed-by:Sunny Sachanandani <sunnyps@chromium.org> Reviewed-by:
enne <enne@chromium.org> Auto-Submit: Khushal <khushalsagar@chromium.org> Cr-Commit-Position: refs/heads/master@{#634935}
Showing
This diff is collapsed.
This diff is collapsed.
Please register or sign in to comment