<?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>219751</bug_id>
          
          <creation_ts>2020-12-10 11:44:26 -0800</creation_ts>
          <short_desc>Efficient low frequency animations</short_desc>
          <delta_ts>2020-12-16 04:30:45 -0800</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 Technology Preview</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>NEW</bug_status>
          <resolution></resolution>
          
          
          <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="Jake Archibald">jaffathecake</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>dino</cc>
    
    <cc>graouts</cc>
    
    <cc>jer.noble</cc>
    
    <cc>simon.fraser</cc>
    
    <cc>webkit-bug-importer</cc>
    
    <cc>ysuzuki</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1713638</commentid>
    <comment_count>0</comment_count>
    <who name="Jake Archibald">jaffathecake</who>
    <bug_when>2020-12-10 11:44:26 -0800</bug_when>
    <thetext>I did some research on how efficient browsers are at animations where not-a-lot happens.

https://static-misc-2.glitch.me/low-freq-anims/

I played with the above while monitoring the task manager.

The &quot;High frequency animation&quot; shows how much CPU is used on a 60hz (or whatever display frequency) animation.

&quot;setTimeout&quot; shows how much CPU is used for a setTimeout-driven animation that updates every 5 seconds. This uses almost no CPU.

The rest are CSS/web animations that update infrequently.

I&apos;m _really_ impressed with how Safari handles these cases, but there are some opportunities for optimisation.

In the following tests:

- Discrete values
- Mostly same values
- Empty animation

…Safari seems to use more CPU than necessary, as if it&apos;s running a 60hz timer internally.

Related Chrome issue: https://bugs.chromium.org/p/chromium/issues/detail?id=1157483</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1713761</commentid>
    <comment_count>1</comment_count>
    <who name="Simon Fraser (smfr)">simon.fraser</who>
    <bug_when>2020-12-10 16:26:57 -0800</bug_when>
    <thetext>Thanks for the info.

Our long-term objective is web-exposed API that allows devs to express what frame rate their animation needs.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1713829</commentid>
    <comment_count>2</comment_count>
    <who name="Jake Archibald">jaffathecake</who>
    <bug_when>2020-12-10 23:06:01 -0800</bug_when>
    <thetext>Yeah, I think we need that too. I made some notes here https://github.com/whatwg/html/issues/5025 - seems important to allow multiple animations to exist on the same reduced frame rate timeline. I know you&apos;ve thought about this more than me though, any API ideas?

However, I think the unoptimised cases in this test are still worth fixing.

Discrete - although a fixed frame rate would work here, it&apos;s already expressed in the animation keyframes.

Mostly same values - this can&apos;t be fixed by a reduced frame rate. I&apos;ve used this style of animation for a &quot;recording&quot; indicator. Like, a red circle that briefly fades from opacity 0.6 to 1, then back to 0.6, then stays at 0.6 for a few seconds. The fading should be high frequency, but the browser shouldn&apos;t run a high frequency timer while values aren&apos;t changing.

Empty animation - this is an alternative to setTimeout but works with the document timeline timer, and doesn&apos;t tick when the document is hidden. I guess you could define this as a 0fps animation? But again this can be inferred.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1714985</commentid>
    <comment_count>3</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2020-12-15 18:10:23 -0800</bug_when>
    <thetext>&lt;rdar://problem/72366315&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1715069</commentid>
    <comment_count>4</comment_count>
    <who name="Antoine Quint">graouts</who>
    <bug_when>2020-12-16 04:30:45 -0800</bug_when>
    <thetext>I had actually already planned to deal with discrete values, I&apos;m still in the middle of implementing some remaining CSS properties for discrete animations.

Mostly same values… that&apos;ll require a bit more thinking.

Empty animations: that one&apos;s easy and I&apos;ll file a dedicated bug for this.

Note that for steps() we have dedicated logic already.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>