gecko-dev/dom/smil
Brian Birtles ebedef2a25 Bug 849593 - Skip samples of active SMIL timed elements when the sample time precedes the current interval; r=dholbert
In some circumstances it is possible to sample a timed element in the active
state with a time that precedes is current interval.

One possible sequence of steps leading to this situation is as follows:

1. A timed element (e.g. <set>, <animate>) with a non-zero begin time is the
   child of <svg> element A (its "time container") but has yet to be sampled.

2. In order to resolve its initial interval, the timed element registers a
   startup milestone with its time container at time 0.

3. However, before the sample is performed where the timed element's initial
   current interval is resolved, <svg> element A is detached from the document
   tree.

4. The timed element is then attached to a different <svg> element B that has
   a current time greater than the begin time of the timed element and less than
   that of <svg> element A.

5. Since the timed element is still in its startup state it registers its
   startup milestone again, this time with its new time container, i.e. <svg>
   element B.

6. A tick occurs or the document has its style flushed such that a sample is
   performed.

   This includes running the milestone sample which causes the timed element to
   resolve its initial current interval. Furthermore the subsequent regular
   sample of the timed element causes it to transition into its active state
   because the current time of <svg> element B is greater than the begin time of
   the timed element.

7. <svg> element A is re-attached to the document.

8. When we go to run the next sample, we iterate through all time containers
   associated with the document's animation controller which includes both <svg>
   element A, and <svg> element B.

9. <svg> element A renders up its 0 milestone from step (2) since it has yet to
   run it. It converts this to parent time, i.e. the time space of the animation
   controller, which will be zero or less depending on the current time of <svg>
   element A when it was re-attached.

10. Since the milestone from <svg> element A will be the earliest milestone
    time, it will be used as the next milestone sample time.

11. The timed element is then sampled using this time, but first it is converted
    to a time in the time space of the timed element's time container, which is
    now <svg> element B.

    As a result of this conversion, the sample time may end up being *before*
    the beginning of the timed element's current interval. Since timed elements
    never expect the time to go backwards an assertion fails when it detects
    that it is active, but is being sampled before its current interval.

For this particular case, ignoring the "early" sample seems to be the most
appropriate action.

More generally, however, we can anticipate other cases similar to this where
milestones are registered that cause the sample time to temporarily go
backwards. A quick audit of nsSMILTimedElement::DoSampleAt suggests that, with
the code changes from this patch, that is probably ok.

As an alternative we could, perhaps, try to drop and re-create all milestones
when time containers are re-attached to the document tree but that would add
more complexity and would not necessarily cover other similar cases of this
situation.

I have verified that the crashtest included in this changeset fails without the
code changes also in this changeset.

MozReview-Commit-ID: KKGYRayNkpo

--HG--
extra : rebase_source : 832d4b357a2a2fe07abf9eab3a6046599aff3ef5
2017-10-24 13:06:04 +09:00
..
crashtests Bug 849593 - Skip samples of active SMIL timed elements when the sample time precedes the current interval; r=dholbert 2017-10-24 13:06:04 +09:00
test Bug 1404803 - Convert empty values to suitable zero values even when using discrete interpolation; r=hiro 2017-10-04 15:04:23 +09:00
moz.build Bug 1062106 part 3 - Remove SMIL MappedAttribute mechanism. r=birtles 2017-03-21 15:45:58 +09:00
nsISMILAttr.h Bug 1391803 - Use nsStringFwd.h for forward declaring string classes. r=froydnj 2017-08-16 16:48:52 -07:00
nsISMILType.h
nsSMILAnimationController.cpp Bug 1400460 - Rename nsIAtom as nsAtom. r=hiro. 2017-10-03 09:05:19 +11:00
nsSMILAnimationController.h Bug 1355348 - Add SMIL restyles in the stylo pretraverse; r=heycam 2017-04-26 13:00:11 +09:00
nsSMILAnimationFunction.cpp Bug 1400460 - Rename nsIAtom as nsAtom. r=hiro. 2017-10-03 09:05:19 +11:00
nsSMILAnimationFunction.h Bug 1400460 - Rename nsIAtom as nsAtom. r=hiro. 2017-10-03 09:05:19 +11:00
nsSMILCompositor.cpp Bug 1355349 - Treat properties that can't be animated by the Servo backend as unanimatable; r=hiro 2017-06-02 15:14:43 +09:00
nsSMILCompositor.h Bug 1406441 - provide nsSMILCompositor with a move constructor, rather than a copy constructor; r=dholbert 2017-10-09 10:39:38 -04:00
nsSMILCompositorTable.h
nsSMILCSSProperty.cpp Bug 1381844: Be more explicit about the kind of style context we handle all the time. r=bholley 2017-07-22 18:02:57 +02:00
nsSMILCSSProperty.h Bug 1400460 - Rename nsIAtom as nsAtom. r=hiro. 2017-10-03 09:05:19 +11:00
nsSMILCSSValueType.cpp Bug 1404803 - Convert empty values to suitable zero values even when using discrete interpolation; r=hiro 2017-10-04 15:04:23 +09:00
nsSMILCSSValueType.h Bug 1404803 - Convert empty values to suitable zero values even when using discrete interpolation; r=hiro 2017-10-04 15:04:23 +09:00
nsSMILFloatType.cpp
nsSMILFloatType.h
nsSMILInstanceTime.cpp
nsSMILInstanceTime.h
nsSMILInterval.cpp
nsSMILInterval.h
nsSMILKeySpline.cpp
nsSMILKeySpline.h
nsSMILMilestone.h
nsSMILNullType.cpp Bug 1406440 - don't inline nsSMILNullType::Singleton(); r=dholbert 2017-10-09 10:39:38 -04:00
nsSMILNullType.h Bug 1406440 - don't inline nsSMILNullType::Singleton(); r=dholbert 2017-10-09 10:39:38 -04:00
nsSMILParserUtils.cpp Bug 1400460 - Rename nsIAtom as nsAtom. r=hiro. 2017-10-03 09:05:19 +11:00
nsSMILParserUtils.h
nsSMILRepeatCount.cpp
nsSMILRepeatCount.h
nsSMILSetAnimationFunction.cpp Bug 1400460 - Rename nsIAtom as nsAtom. r=hiro. 2017-10-03 09:05:19 +11:00
nsSMILSetAnimationFunction.h Bug 1400460 - Rename nsIAtom as nsAtom. r=hiro. 2017-10-03 09:05:19 +11:00
nsSMILTargetIdentifier.h Bug 1400460 - Rename nsIAtom as nsAtom. r=hiro. 2017-10-03 09:05:19 +11:00
nsSMILTimeContainer.cpp Bug 1062106 part 3 - Remove SMIL MappedAttribute mechanism. r=birtles 2017-03-21 15:45:58 +09:00
nsSMILTimeContainer.h
nsSMILTimedElement.cpp Bug 849593 - Skip samples of active SMIL timed elements when the sample time precedes the current interval; r=dholbert 2017-10-24 13:06:04 +09:00
nsSMILTimedElement.h Bug 1400460 - Rename nsIAtom as nsAtom. r=hiro. 2017-10-03 09:05:19 +11:00
nsSMILTimeValue.cpp Bug 1322849 - Add a range check when the duration is multiplied by the repeat count. r=birtles 2017-10-17 22:19:54 +01:00
nsSMILTimeValue.h Bug 1374861 - add const keyword where appropriate. r=birtles 2017-07-01 10:55:27 +01:00
nsSMILTimeValueSpec.cpp
nsSMILTimeValueSpec.h Bug 1403500, part 5 - Document and do some renaming for nsSMILTimeValueSpec's TimeReferenceElement. r=longsonr 2017-09-13 08:22:55 +01:00
nsSMILTimeValueSpecParams.h Bug 1400460 - Rename nsIAtom as nsAtom. r=hiro. 2017-10-03 09:05:19 +11:00
nsSMILTypes.h
nsSMILValue.cpp Bug 1378712 - Remove all trailing whitespaces r=Ehsan 2017-07-06 14:00:35 +02:00
nsSMILValue.h
SMILBoolType.cpp
SMILBoolType.h
SMILEnumType.cpp
SMILEnumType.h
SMILIntegerType.cpp
SMILIntegerType.h
SMILStringType.cpp
SMILStringType.h
TimeEvent.cpp Bug 1391005 - Eliminate NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED. r=peterv 2017-08-29 16:02:48 -07:00
TimeEvent.h