Closed Bug 1378707 Opened 7 years ago Closed 7 years ago

SVG: text clippath renders incorrectly when clipped group has animated contents

Categories

(Core :: SVG, defect, P2)

54 Branch
defect

Tracking

()

RESOLVED DUPLICATE of bug 1378710
mozilla56
Tracking Status
firefox54 --- wontfix
firefox55 --- wontfix
firefox56 --- fixed

People

(Reporter: paul.lebeau, Assigned: u459114)

References

Details

(Keywords: regression)

User Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:54.0) Gecko/20100101 Firefox/54.0
Build ID: 20170628075643

Steps to reproduce:

This is a weird one.  If a clipPath consists of text elements, and the group it is applied to contains only animated elements, then it does not render correctly.

Try the following test case: https://jsfiddle.net/nhoqs7j2/

<svg viewBox="0 0 600 150">

  <clippath id="cp-text">
    <text x="0" y="50%">hello svg clippath</text>
  </clippath>

  <g clip-path="url(#cp-text)" class="colortext">
    <rect x="0" y="0" width="100%" height="100%" class="anim-shape"/>
  </g> 
</svg>

body {
  font-size: 80px;
  font-weight: 800;
}

.anim-shape {
  transform: translate(-600px, 0);
  animation: moving-panel 4s forwards ease-out;
}     

@keyframes moving-panel {
  100% {
    transform: translate(0, 0);
  }
}




Actual results:

While the animation is running, the clipped rectangle does not render correctly. However when it updates at anim end, the render is correct.



Expected results:


== Odd workaround 1 ==

However, if you add a non-animated element to the clipped group, everything renders perfectly - including during the animation.

  <g clip-path="url(#cp-text)" class="colortext">
    <rect x="0" y="0" width="100%" height="1%" fill="transparent" />
    <rect x="0" y="0" width="100%" height="100%" class="anim-shape"/>
  </g> 

https://jsfiddle.net/nhoqs7j2/3/

Interestingly, only that portion of the SVG that overlaps the width of the added element renders correctly. If you reduce the width of this added element, only the first half of the animation is rendered correctly.

== Work around 2 ==

It also seems that if you use non-text elements in the clipPath, the bug no longer manifests.

  <clippath id="cp-text">
    <polygon points="0,0, 600,75, 0,150"/>
  </clippath>

https://jsfiddle.net/nhoqs7j2/2/
In fact there might be two bugs here:

1. clipPaths containing text elements
2. clipPaths OR masks applied to groups with animated contents.

A similar SVG that uses a mask, instead of a clipPath, also fails:

See: https://jsfiddle.net/q770saez/1/

<svg viewBox="0 0 600 150">

  <mask id="m">
    <rect width="100%" height="100%" fill="black"/>
    <polygon points="0,0, 600,75, 0,150" fill="white"/>
  </mask>

  <g mask="url(#m)">
    <rect width="100%" height="100%" class="anim-shape"/>
  </g> 

</svg>

(same CSS as above)

But if you apply the same workaround as above (non-animated transparent rect in the group), the animation renders correctly.

https://jsfiddle.net/q770saez/3/

  <g mask="url(#m)">
    <rect x="0" y="0" width="100%" height="100%" fill="transparent" />
    <rect width="100%" height="100%" class="anim-shape"/>
  </g>
Actually, please ignore my last comment. A clipPath with animated contents works fine (as long as it doesn't contain text elements). So the mask issue is a related but different bug. I've created a new bug for that.

See bug #1378710
Component: Untriaged → SVG
Product: Firefox → Core
Assignee: nobody → cku
Flags: needinfo?(cku)
Not a new regression in 54. Mark 54 won't fix and see if we can fix it in 55.
The patch in bug 1378710 can also fix this bug
Status: NEW → RESOLVED
Closed: 7 years ago
Resolution: --- → DUPLICATE
Priority: -- → P2
Target Milestone: --- → mozilla56
You need to log in before you can comment on or make changes to this bug.