<?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>299823</bug_id>
          
          <creation_ts>2025-09-29 14:10:33 -0700</creation_ts>
          <short_desc>REGRESSION(294049@main): starting an animation via el.animate().reverse only works every other time</short_desc>
          <delta_ts>2025-10-13 09:25:25 -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>Safari 26</version>
          <rep_platform>Mac (Intel)</rep_platform>
          <op_sys>macOS 26</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          <see_also>https://bugs.webkit.org/show_bug.cgi?id=290993</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="Caleb Hearon">caleb</reporter>
          <assigned_to name="Antoine Quint">graouts</assigned_to>
          <cc>graouts</cc>
    
    <cc>graouts</cc>
    
    <cc>karlcow</cc>
    
    <cc>stephen</cc>
    
    <cc>webkit-bug-importer</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>2146954</commentid>
    <comment_count>0</comment_count>
    <who name="Caleb Hearon">caleb</who>
    <bug_when>2025-09-29 14:10:33 -0700</bug_when>
    <thetext>jsfiddle: https://jsfiddle.net/n962tryh/

- Safari 18 animates the div every button click
- Safari 26 animates the 1st, 3rd, 5th... times
- Firefox animates every click
- Chrome animates every click

I don&apos;t know Web Animations well enough to know what should happen, or if this is an under-specified area, but it broke our app. It&apos;s possibly Intel-specific: my colleague was not able to reproduce on Apple Silicon</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2146975</commentid>
    <comment_count>1</comment_count>
    <who name="Stephen Thomas">stephen</who>
    <bug_when>2025-09-29 15:36:50 -0700</bug_when>
    <thetext>Can confirm with Safari 26.0.1 on Sequoia as well. Versions 15.7 and 15.7.1. But only on a Mini with an Intel CPU. No bug observed on a different M4 Mini.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2148837</commentid>
    <comment_count>2</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2025-10-06 14:11:10 -0700</bug_when>
    <thetext>&lt;rdar://problem/162067522&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2148995</commentid>
    <comment_count>3</comment_count>
    <who name="Antoine Quint">graouts</who>
    <bug_when>2025-10-06 23:37:11 -0700</bug_when>
    <thetext>It&apos;s not Intel-specific, I can reproduce this with Safari 26.0.1 on macOS Tahoe 26.0.1 (25A362). Will find the regression point.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2148997</commentid>
    <comment_count>4</comment_count>
    <who name="Antoine Quint">graouts</who>
    <bug_when>2025-10-06 23:42:12 -0700</bug_when>
    <thetext>It appears to already have been broken in 294709@main.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2149093</commentid>
    <comment_count>5</comment_count>
    <who name="Antoine Quint">graouts</who>
    <bug_when>2025-10-07 07:26:50 -0700</bug_when>
    <thetext>The regression range is https://commits.webkit.org/compare/294072@main...294026@main. This most likely this regressed with 294049@main, the fix for bug 290993.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2150310</commentid>
    <comment_count>6</comment_count>
    <who name="Antoine Quint">graouts</who>
    <bug_when>2025-10-12 01:03:27 -0700</bug_when>
    <thetext>Oddly enough this does not reproduce with the HTML and JS code pasted into an HTML file. But it does within the iframe on jsfiddle.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2150319</commentid>
    <comment_count>7</comment_count>
    <who name="Antoine Quint">graouts</who>
    <bug_when>2025-10-12 05:39:25 -0700</bug_when>
    <thetext>I expect this is going to be something to do with throttling.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2150321</commentid>
    <comment_count>8</comment_count>
    <who name="Antoine Quint">graouts</who>
    <bug_when>2025-10-12 06:05:13 -0700</bug_when>
    <thetext>There&apos;s really something specific to jsfiddle here. If I call `document.getAnimations()[0].cancel()` after the page is loaded, the bug stops reproducing.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2150322</commentid>
    <comment_count>9</comment_count>
    <who name="Antoine Quint">graouts</who>
    <bug_when>2025-10-12 06:08:08 -0700</bug_when>
    <thetext>So there&apos;s some bad interaction between the CSS Animation applied to the &quot;AN&quot; avatar in the page&apos;s top bar above the HTML and the animation in the content. Will try to reduce this, but it&apos;s quite odd.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2150357</commentid>
    <comment_count>10</comment_count>
    <who name="Antoine Quint">graouts</who>
    <bug_when>2025-10-12 13:12:20 -0700</bug_when>
    <thetext>This can be reduced to a host document running a constant background-color animation while a child document, hosted via an &lt;iframe&gt;, animates using the reverse() method.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2150460</commentid>
    <comment_count>11</comment_count>
    <who name="Antoine Quint">graouts</who>
    <bug_when>2025-10-13 00:10:51 -0700</bug_when>
    <thetext>I think this is due to timers being throttled in iframes and the call to `AnimationTimelinesController::processPendingAnimations()` taking longer than expected to run, only after the next animation resolution, and thus the animation never getting a committed start time.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2150484</commentid>
    <comment_count>12</comment_count>
    <who name="Stephen Thomas">stephen</who>
    <bug_when>2025-10-13 03:15:01 -0700</bug_when>
    <thetext>Just a note to add that we encountered the bug in our application, which does not use Iframes. So it is  NOT strictly an iframe issue</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2150488</commentid>
    <comment_count>13</comment_count>
    <who name="Antoine Quint">graouts</who>
    <bug_when>2025-10-13 03:32:46 -0700</bug_when>
    <thetext>So far I&apos;ve only managed to reproduce the issue in the context of iframes where timing is different… but since this is a timing issue, I expect this may occur depending on the JavaScript performance. If you can make a reduction that does not involve iframes, it would be good to see it as well.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2150492</commentid>
    <comment_count>14</comment_count>
    <who name="Antoine Quint">graouts</who>
    <bug_when>2025-10-13 03:53:25 -0700</bug_when>
    <thetext>Pull request: https://github.com/WebKit/WebKit/pull/52233</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2150495</commentid>
    <comment_count>15</comment_count>
    <who name="Stephen Thomas">stephen</who>
    <bug_when>2025-10-13 04:24:52 -0700</bug_when>
    <thetext>Looks like the issue has been found, but for completeness, unfortunately our application code is too complex to share easily (and is also proprietary) but the fact that we could easily reproduce on Intel clients but not Apple Silicon clients definitely supports the idea that it&apos;s timing/performance related. I can share the workaround we deployed, if that&apos;s helpful.

Broken:

```
const animation = el.animate(keyframes, {duration: 200});
animation.addEventListener(&quot;finish&quot;, done);
if (reverse) animation.reverse();
```

Works:

```
if (reverse) keyframes.reverse();
const animation = el.animate(keyframes, {duration: 200});
animation.addEventListener(&quot;finish&quot;, done);
```</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2150560</commentid>
    <comment_count>16</comment_count>
    <who name="EWS">ews-feeder</who>
    <bug_when>2025-10-13 09:25:23 -0700</bug_when>
    <thetext>Committed 301414@main (841997317f49): &lt;https://commits.webkit.org/301414@main&gt;

Reviewed commits have been landed. Closing PR #52233 and removing active labels.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>