<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>310804</bug_id>
          
          <creation_ts>2026-03-26 04:16:13 -0700</creation_ts>
          <short_desc>[threaded-animations] animating `offset-path` with a percentage-based `offset-distance` value fails</short_desc>
          <delta_ts>2026-04-14 13:28:27 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>Animations</component>
          <version>WebKit Nightly Build</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          <see_also>https://bugs.webkit.org/show_bug.cgi?id=310943</see_also>
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Antoine Quint">graouts</reporter>
          <assigned_to name="Antoine Quint">graouts</assigned_to>
          <cc>graouts</cc>
    
    <cc>sam</cc>
    
    <cc>webkit-bug-importer</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>2193877</commentid>
    <comment_count>0</comment_count>
      <attachid>478803</attachid>
    <who name="Antoine Quint">graouts</who>
    <bug_when>2026-03-26 04:16:13 -0700</bug_when>
    <thetext>Created attachment 478803
Test

A keyframe such as this one:

```
@keyframes move {
    from { offset-path: rect(0px 100px 100px 0px) }
	to { offset-distance: 100% }
}
```

… fails a debug assertion for `PrimitiveNumeric`:

```
    IPCData ipcData() const
    {
        return WTF::switchOn(m_value,
            [](const Dimension&amp; dimension) -&gt; IPCData { return dimension; },
            [](const Percentage&amp; percentage) -&gt; IPCData { return percentage; },
            [](const Calc&amp;) -&gt; IPCData { ASSERT_NOT_REACHED(); return Dimension { 0 }; } // &lt;&lt;&lt;&lt; HERE
        );
    }
```

I find it surprising since we&apos;re not using `calc()` anywhere here.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2193980</commentid>
    <comment_count>1</comment_count>
    <who name="Antoine Quint">graouts</who>
    <bug_when>2026-03-26 09:16:12 -0700</bug_when>
    <thetext>Once we fix this, we&apos;ll crash in the blending code which needs to fix this way:

```
diff --git a/Source/WebCore/platform/animation/AcceleratedEffect.cpp b/Source/WebCore/platform/animation/AcceleratedEffect.cpp
index d72a1b1433b8..741a4cb602a4 100644
--- a/Source/WebCore/platform/animation/AcceleratedEffect.cpp
+++ b/Source/WebCore/platform/animation/AcceleratedEffect.cpp
@@ -366,8 +366,12 @@ static void blend(AcceleratedEffectProperty property, AcceleratedEffectValues&amp; o
         output.offsetDistance = blend(from.offsetDistance, to.offsetDistance, blendingContext);
         break;
     case AcceleratedEffectProperty::OffsetPath:
-        if (auto&amp; fromOffsetPath = from.offsetPath)
-            output.offsetPath = fromOffsetPath-&gt;blend(to.offsetPath.get(), blendingContext);
+        if (!from.offsetPath || !to.offsetPath) {
+            blendingContext.isDiscrete = true;
+            blendingContext.normalizeProgress();
+            output.offsetPath = blendingContext.progress ? to.offsetPath : from.offsetPath;
+        } else
+            output.offsetPath = from.offsetPath-&gt;blend(to.offsetPath.get(), blendingContext);
         break;
     case AcceleratedEffectProperty::OffsetPosition:
         if (!canBlend(from.offsetPosition, to.offsetPosition)) {
```</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2194050</commentid>
    <comment_count>2</comment_count>
    <who name="Sam Weinig">sam</who>
    <bug_when>2026-03-26 13:22:45 -0700</bug_when>
    <thetext>The reason there is a calc() here is that the `rect()` in `offset-path: rect(0px 100px 100px 0px)` gets converted to its &quot;inset&quot; form during style building, which introduces the calcs. 

rect(0px 100px 100px 0px) -&gt; inset(0px calc(100% - 100px) calc(100% - 100px) 0px)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2194645</commentid>
    <comment_count>3</comment_count>
    <who name="Antoine Quint">graouts</who>
    <bug_when>2026-03-28 01:27:22 -0700</bug_when>
    <thetext>Will likely be fixed by bug 310943.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2194898</commentid>
    <comment_count>4</comment_count>
    <who name="Sam Weinig">sam</who>
    <bug_when>2026-03-29 14:02:19 -0700</bug_when>
    <thetext>When https://bugs.webkit.org/show_bug.cgi?id=310943 lands, this no longer asserts, but the animation doesn&apos;t match the behavior when threaded animations are disabled.

To illustrate why it still doesn&apos;t match, I am going to make the values a bit more explicit in the example:

```
@keyframes move {
    from { 
        offset-path: rect(0px 100px 100px 0px);
        offset-distance: 0%;
    }
    to { 
        offset-path: none;
        offset-distance: 100%;
     }
}
```

When converted to AcceleratedEffectValues these become:

from -&gt; AcceleratedEffectValues {
    offset-path: {some path}
    offset-distance: 0;
}

to -&gt; AcceleratedEffectValues {
    offset-path: none
    offset-distance: 0;
}
```

Importantly, `offset-distance` stays `0`. This happens for two reasons.
1. Because `offset-distance` is only calculated at all if there is an `offset-path` (we can fix this one by just unconditionally evaluated the `offset-distance`)
2. Because percentage/calc `offset-distance` values are evaluated with respect to the length `offset-path`.

Due to #2, the lack of `offset-path` makes the `offset-distance: 100%` incalculable.

--

So what should we do?

We need to ensure that we don&apos;t use the accelerated animation path for keyframe pairs where:

- The length of `offset-path` is changing (this probably boils down to if &quot;`offset-path` is changing&quot; at all).
and
- The value of `offset-distance` is percentage or calc for either keyframe.

We should also change it so calculate values for all the `offset-*` properties regardless of whether `tryPath()` succeeds (except, of course, `offset-distance` when it is percentage or calc), so that they can properly interpolate even when one keyframe does not have a valid `offset-path`.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2196243</commentid>
    <comment_count>5</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2026-04-02 04:17:13 -0700</bug_when>
    <thetext>&lt;rdar://problem/173926809&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2199729</commentid>
    <comment_count>6</comment_count>
    <who name="Antoine Quint">graouts</who>
    <bug_when>2026-04-13 07:43:56 -0700</bug_when>
    <thetext>Retitling given that the original issue was fixed by 310943.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2199746</commentid>
    <comment_count>7</comment_count>
    <who name="Antoine Quint">graouts</who>
    <bug_when>2026-04-13 08:22:21 -0700</bug_when>
    <thetext>Pull request: https://github.com/WebKit/WebKit/pull/62638</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2200335</commentid>
    <comment_count>8</comment_count>
    <who name="EWS">ews-feeder</who>
    <bug_when>2026-04-14 13:28:25 -0700</bug_when>
    <thetext>Committed 311224@main (89607e24306f): &lt;https://commits.webkit.org/311224@main&gt;

Reviewed commits have been landed. Closing PR #62638 and removing active labels.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>478803</attachid>
            <date>2026-03-26 04:16:13 -0700</date>
            <delta_ts>2026-03-26 04:16:13 -0700</delta_ts>
            <desc>Test</desc>
            <filename>offset-path-in-keyframe.html</filename>
            <type>text/html</type>
            <size>257</size>
            <attacher name="Antoine Quint">graouts</attacher>
            
              <data encoding="base64">PHN0eWxlPgoKQGtleWZyYW1lcyBtb3ZlIHsKICAgIGZyb20geyBvZmZzZXQtcGF0aDogcmVjdCgw
cHggMTAwcHggMTAwcHggMHB4KSB9Cgl0byB7IG9mZnNldC1kaXN0YW5jZTogMTAwJSB9Cn0KCi50
YXJnZXQgewogICAgd2lkdGg6IDEwcHg7CgloZWlnaHQ6IDEwcHg7CgliYWNrZ3JvdW5kLWNvbG9y
OiBibGFjazsKCWFuaW1hdGlvbjogbW92ZSA0cyBpbmZpbml0ZSBsaW5lYXI7Cn0KCjwvc3R5bGU+
Cgo8ZGl2IGNsYXNzPSJ0YXJnZXQiPjwvZGl2Pgo=
</data>

          </attachment>
      

    </bug>

</bugzilla>