Closed Bug 1223255 Opened 10 years ago Closed 10 years ago

Compositor animations with positive delay and playbackRate != 1 jump

Categories

(Core :: DOM: Animation, defect)

Other Branch
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla45
Tracking Status
firefox45 --- fixed

People

(Reporter: hiro, Assigned: hiro)

Details

Attachments

(2 files, 1 obsolete file)

Attached file A test case
Animations on compositor which has positive delay and is set playbackRate jumps to unusual position after it started.
Summary: Compositor animations which has positive delay and is set playbackRate !1 → Compositor animations with positive delay and playbackRate != 1 jump
I found the reason of this problem. For compositor animations elapsed duration is calculated at [1]. (aPoint - animation.startTime()).MultDouble(animation.playbackRate()) The animation.startTime() comes from [2]. timeline->ToTimeStamp(startTime.Value() + timing.mDelay) We need here to divide the mDelay by playback rate just like Animation::AnimationTimeToTimeStamp does[3]. Or use AnimationTimeToTimeStamp here too. [1] https://dxr.mozilla.org/mozilla-central/source/gfx/layers/composite/AsyncCompositionManager.cpp#561 [2] https://dxr.mozilla.org/mozilla-central/source/layout/base/nsDisplayList.cpp#380 [3] https://dxr.mozilla.org/mozilla-central/source/dom/animation/Animation.cpp#1162
Use Animation::AnimationTimeToTimeStamp instead of timeline->ToTimeStamp otherwise delay value is multiplied by playbackRate twice.
Attachment #8688244 - Flags: review?(bbirtles)
Comment on attachment 8688244 [details] [diff] [review] Use Animation::AnimationTimeToTimeStamp to calculate timestamp for the compositor >--- a/dom/animation/Animation.h >+++ b/dom/animation/Animation.h >@@ -294,16 +294,18 @@ public: > void ComposeStyle(RefPtr<AnimValuesStyleRule>& aStyleRule, > nsCSSPropertySet& aSetProperties, > bool& aStyleChanging); > > void NotifyEffectTimingUpdated(); > > AnimationCollection* GetCollection() const; > >+ TimeStamp AnimationTimeToTimeStamp(const StickyTimeDuration& aTime) const; >+ * Nit: This might make more sense just after GetCurrentOrPendingStartTime since we seems to have most of the time-related methods first, then the effect-related methods. * Please add a comment here: "Converts a time in the timescale of this Animation's currentTime, to a TimeStamp. Returns a null TimeStamp if the conversion cannot be performed because of the current state of this Animation (e.g. it has no timeline, a zero playbackRate, an unresolved start time etc.) or the value of the time passed-in (e.g. an infinite time)." (We should probably expose GetAnimationTimeAsTimelineTime instead (or as well), and then convert to a TimeStamp at the call-site, but I think this is fine for now.) * Perhaps we should move the order of AnimationTimeToTimeStamp within the .cpp file to match the .h file order? What do you think? * The following comment in AnimationTimeToTimeStamp is no longer true: // Since we never compare the result of this method with TimeStamp::Now() // it is ok to return values even if mTimeline->TracksWallclockTime() is // false. https://dxr.mozilla.org/mozilla-central/rev/a2f83cbe53ac4009afa4cb2b0b8f549289b23eeb/dom/animation/Animation.cpp#1144 We should just drop that whole paragraph. >+addAsyncAnimTest(function *() { >+ var [ div, cs ] = new_div("animation: anim 10s 1s"); >+ var animation = div.getAnimations()[0]; >+ animation.playbackRate = 0.5; >+ >+ advance_clock(2000); // 1s * (1 / playbackRate) >+ >+ yield waitForPaints(); >+ omta_is(div, "transform", { tx: 0 }, RunningOn.Compositor, >+ "animation with positive delay and playbackRate > 1 should " + >+ "start from the initial position at the beginning of the " + >+ "active duration"); >+ done_div(); >+}); Does this test fail without the changes to nsDisplayList.cpp? r=birtles assuming the tests fail without the changes applied.
Attachment #8688244 - Flags: review?(bbirtles) → review+
Assignee: nobody → hiikezoe
Status: NEW → ASSIGNED
(In reply to Brian Birtles (:birtles) from comment #3) > Comment on attachment 8688244 [details] [diff] [review] > Use Animation::AnimationTimeToTimeStamp to calculate timestamp for the > compositor > > >--- a/dom/animation/Animation.h > >+++ b/dom/animation/Animation.h > >@@ -294,16 +294,18 @@ public: > > void ComposeStyle(RefPtr<AnimValuesStyleRule>& aStyleRule, > > nsCSSPropertySet& aSetProperties, > > bool& aStyleChanging); > > > > void NotifyEffectTimingUpdated(); > > > > AnimationCollection* GetCollection() const; > > > >+ TimeStamp AnimationTimeToTimeStamp(const StickyTimeDuration& aTime) const; > >+ > > * Nit: This might make more sense just after GetCurrentOrPendingStartTime > since we seems to have most of the time-related methods first, then the > effect-related methods. OK. I will do it. > * Please add a comment here: > > "Converts a time in the timescale of this Animation's currentTime, to a > TimeStamp. Returns a null TimeStamp if the conversion cannot be performed > because of the current state of this Animation (e.g. it has no timeline, a > zero playbackRate, an unresolved start time etc.) or the value of the time > passed-in (e.g. an infinite time)." Thanks always for comments. I will try my best. > (We should probably expose GetAnimationTimeAsTimelineTime instead (or as > well), and then convert to a TimeStamp at the call-site, but I think this is > fine for now.) Ah, that will make much sense! > * Perhaps we should move the order of AnimationTimeToTimeStamp within the > .cpp file to match the .h file order? What do you think? It sounds good. I will change the order. > * The following comment in AnimationTimeToTimeStamp is no longer true: > > // Since we never compare the result of this method with TimeStamp::Now() > // it is ok to return values even if mTimeline->TracksWallclockTime() is > // false. > > https://dxr.mozilla.org/mozilla-central/rev/ > a2f83cbe53ac4009afa4cb2b0b8f549289b23eeb/dom/animation/Animation.cpp#1144 > > We should just drop that whole paragraph. Thanks. I did not notice the comment. I will remove the paragraph. > >+addAsyncAnimTest(function *() { > >+ var [ div, cs ] = new_div("animation: anim 10s 1s"); > >+ var animation = div.getAnimations()[0]; > >+ animation.playbackRate = 0.5; > >+ > >+ advance_clock(2000); // 1s * (1 / playbackRate) > >+ > >+ yield waitForPaints(); > >+ omta_is(div, "transform", { tx: 0 }, RunningOn.Compositor, > >+ "animation with positive delay and playbackRate > 1 should " + > >+ "start from the initial position at the beginning of the " + > >+ "active duration"); > >+ done_div(); > >+}); > > Does this test fail without the changes to nsDisplayList.cpp? Yes, sure. Without changes the animation lives still on main-thread (does not start) at the beginning.
Status: ASSIGNED → RESOLVED
Closed: 10 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla45
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: