Uploaded image for project: 'Batik'
  1. Batik
  2. BATIK-698

Bug in animateTransform freeze

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Resolution: Fixed
    • Affects Version/s: 1.8
    • Fix Version/s: None
    • Component/s: GVT
    • Labels:
      None
    • Environment:
      Operating System: other
      Platform: Other

      Description

      I believe I have stumbled upon a bug in Batik (present in current
      development sources). It is exposed by the following SVG:

      <svg version="1.1"
      xmlns="http://www.w3.org/2000/svg"
      xmlns:xlink="http://www.w3.org/1999/xlink"
      viewBox="-100.00 -100.00 500.00 500.00">
      <circle r="5.0000" id="button" fill="red" />
      <g transform="translate(0,15)">
      <animateTransform attributeName="transform"
      type="translate"
      from="0,15" to="0,45"
      dur="0.4s"
      fill="freeze"
      additive="replace"
      begin="button.click" />
      <circle r="5.0000" fill="blue" />
      </g>
      </svg>

      The idea here is that a click on the circle with ID "button" triggers
      the animation of the second circle (within the group). The bug is that
      quite often (at more or less random times), the circle's position is
      reset to the original position rather than remain at the end of the
      animation.

      I am unfamiliar with the Batik sources (and Java as such), but I have
      looked at the sources, and it appears to me that the problem is in
      TimedElement.java, in TimedElement.sampleAt(). Near the end there is
      something to do with computing/"sampling" the final value, and it
      seems that for some reason this is done by taking the current time (in
      the variable t) modulo the animation's duration (in the variable
      d). Presumably due to floating point inaccuracies, this modulo
      operations sometimes just "overflows" back to just above zero, causing
      the effect (position reset) described above.

      If I simply add a small constant, such as 0.05, to the duration 'd',
      the bug seems to disappear. However I don't expect that this is really
      the correct solution. Hopefully someone with a better grasp of Batik
      will be able to fix it properly.

        Attachments

          Activity

            People

            • Assignee:
              batik-dev@xmlgraphics.apache.org Batik Developer's Mailing list
              Reporter:
              frodef@stud.cs.uit.no Frode V. Fjeld
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: