<?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>235196</bug_id>
          
          <creation_ts>2022-01-13 13:28:02 -0800</creation_ts>
          <short_desc>Specify willReadFrequently: true in benchmarks tests that do 2D canvas readbacks</short_desc>
          <delta_ts>2023-06-28 17:54:52 -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>Tools / Tests</component>
          <version>WebKit Nightly Build</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>MOVED</resolution>
          
          <see_also>https://bugs.webkit.org/show_bug.cgi?id=244117</see_also>
    
    <see_also>https://bugs.webkit.org/show_bug.cgi?id=249021</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="Justin Novosad">junov</reporter>
          <assigned_to name="Justin Novosad">junov</assigned_to>
          <cc>ap</cc>
    
    <cc>cdumez</cc>
    
    <cc>darin</cc>
    
    <cc>ews-watchlist</cc>
    
    <cc>jbedard</cc>
    
    <cc>jonlee</cc>
    
    <cc>mmaxfield</cc>
    
    <cc>rniwa</cc>
    
    <cc>sabouhallawa</cc>
    
    <cc>webkit-bug-importer</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1830681</commentid>
    <comment_count>0</comment_count>
    <who name="Justin Novosad">junov</who>
    <bug_when>2022-01-13 13:28:02 -0800</bug_when>
    <thetext>The Images test of MotionMark does a lot of calls to getImageData, and therefore should use the willReadFrequently context creation attribute (see: https://github.com/whatwg/html/commit/d3e5732abdec1a73f716d1fd90f69313c4ddd54c ).

Various browsers (Firefox, Edge, Chrome) in the near future will be removing heuristics that chose between CPU and GPU based rendering in order to make the browser&apos;s behavior more predictable. For web apps to retain good readback performance after these heuristics are removed, they will need to specify willReadFrequently at context creation time.

For MotionMark to continue to provide fair comparisons of browser performance, it should use the willReadFrequently attribute when appropriate.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1830703</commentid>
    <comment_count>1</comment_count>
      <attachid>449103</attachid>
    <who name="Justin Novosad">junov</who>
    <bug_when>2022-01-13 13:57:56 -0800</bug_when>
    <thetext>Created attachment 449103
Patch</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1831298</commentid>
    <comment_count>2</comment_count>
      <attachid>449103</attachid>
    <who name="Darin Adler">darin</who>
    <bug_when>2022-01-16 08:02:24 -0800</bug_when>
    <thetext>Comment on attachment 449103
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=449103&amp;action=review

&gt; PerformanceTests/ChangeLog:12
&gt; +        this new API feature.

That doesn’t make sense to me. The benchmark is intended as a proxy for performance on websites; changes in browsers should not result in changes to the benchmark. Changes to websites could, though.

Has this change to the benchmark been discussed somewhere? Did the people discussing it consider the issue I am raising here?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1831299</commentid>
    <comment_count>3</comment_count>
    <who name="Darin Adler">darin</who>
    <bug_when>2022-01-16 08:03:09 -0800</bug_when>
    <thetext>Changing the benchmark before the websites change seems “cheeky” to me.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1831533</commentid>
    <comment_count>4</comment_count>
    <who name="Justin Novosad">junov</who>
    <bug_when>2022-01-17 11:16:25 -0800</bug_when>
    <thetext>This change has not been discussed with anyone who Maintains MotionMark. We can discuss it here.

Here is a summary of the situation:

Many browser have heuristics to switch between between GPU and CPU-based rasterization of 2d canvas content.  The reason for this is that GPU acceleration does not always perform better than without GPU acceleration, mostly because GPU readbacks are expensive, especially when they need to be synchronous, as is required by the getImageData and toDataURL methods.

The problem with these heuristics is that they sometimes cause glitchy behavior when switching between GPU and CPU rendering on the fly. For example, anti-aliased edges might have a slightly different appearance.  The sudden change in appearance may feel glitchy to users and the behaviour is sometimes surprising to web developers. Also, these heuristics result in performance characteristics that are surprising.  For example: why is the first call to getImageData slower than the second one?

To make the platform saner, it was proposed that these heuristic should be removed, and replaced by am API that gives developer explicit control in order to eliminate surprises.  The new API feature is the willReadFrequently context creation attribute:

https://html.spec.whatwg.org/multipage/canvas.html#concept-canvas-will-read-frequently

Removing the heuristics will negatively affect the performance of web sites that call getImageData repeatedly without specifying {willReadFrequently: true} at context creation time.  Therefore, there will be a devrel push to raise awareness of this issue so that Web devs can make the change before the heuristic removal goes live.

This proposed change to MotionMark would assure continuity in performance for the benchmark.  Basically it would assure that the benchmark continues to measure the same code path as before, which is the desirable code path.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1831954</commentid>
    <comment_count>5</comment_count>
    <who name="Ryosuke Niwa">rniwa</who>
    <bug_when>2022-01-19 00:01:20 -0800</bug_when>
    <thetext>(In reply to Justin Novosad from comment #4)
&gt;
&gt; To make the platform saner, it was proposed that these heuristic should be
&gt; removed, and replaced by am API that gives developer explicit control in
&gt; order to eliminate surprises.  The new API feature is the willReadFrequently
&gt; context creation attribute:
&gt; 
&gt; https://html.spec.whatwg.org/multipage/canvas.html#concept-canvas-will-read-
&gt; frequently
&gt; 
&gt; Removing the heuristics will negatively affect the performance of web sites
&gt; that call getImageData repeatedly without specifying {willReadFrequently:
&gt; true} at context creation time.  Therefore, there will be a devrel push to
&gt; raise awareness of this issue so that Web devs can make the change before
&gt; the heuristic removal goes live.
&gt; 
&gt; This proposed change to MotionMark would assure continuity in performance
&gt; for the benchmark.  Basically it would assure that the benchmark continues
&gt; to measure the same code path as before, which is the desirable code path.

The benchmarks should measure the realistic browser performance. Making use of this new API in MotionMark should only be done after the vast majority of websites, NOT just the most popular websites, that use getImageData have adopted this new API.

Otherwise, MotionMark will give unrealistically favorable numbers for browsers that implement such an new API but don&apos;t implement the aforementioned heuristics.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1832016</commentid>
    <comment_count>6</comment_count>
    <who name="Justin Novosad">junov</who>
    <bug_when>2022-01-19 06:40:58 -0800</bug_when>
    <thetext>&gt; Making use of this new API in MotionMark should only be done after the vast
&gt; majority of websites, NOT just the most popular websites, that use
&gt; getImageData have adopted this new API.

Fair enough. I will add browser instrumentation to measure feature adoption. I will chime in at a later date once adoption is strong.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1832345</commentid>
    <comment_count>7</comment_count>
      <attachid>449103</attachid>
    <who name="Ryosuke Niwa">rniwa</who>
    <bug_when>2022-01-19 21:18:21 -0800</bug_when>
    <thetext>Comment on attachment 449103
Patch

r-ing this patch for now.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1832552</commentid>
    <comment_count>8</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2022-01-20 13:28:19 -0800</bug_when>
    <thetext>&lt;rdar://problem/87846749&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1964144</commentid>
    <comment_count>9</comment_count>
    <who name="Myles C. Maxfield">mmaxfield</who>
    <bug_when>2023-06-28 17:02:17 -0700</bug_when>
    <thetext>I think this is a dup of https://github.com/WebKit/MotionMark/pull/1</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>449103</attachid>
            <date>2022-01-13 13:57:56 -0800</date>
            <delta_ts>2022-01-19 21:18:21 -0800</delta_ts>
            <desc>Patch</desc>
            <filename>bug-235196-20220113165756.patch</filename>
            <type>text/plain</type>
            <size>1770</size>
            <attacher name="Justin Novosad">junov</attacher>
            
              <data encoding="base64">SW5kZXg6IFBlcmZvcm1hbmNlVGVzdHMvQ2hhbmdlTG9nCj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EdldCBpbWFnZSBkYXRhCiAgICAgICAgICAgICB2YXIgaW1hZ2VEYXRhID0gY29u
dGV4dC5nZXRJbWFnZURhdGEoMCwgMCwgdGhpcy5pbWFnZVdpZHRoLCB0aGlzLmltYWdlSGVpZ2h0
KTsK
</data>
<flag name="review"
          id="475098"
          type_id="1"
          status="-"
          setter="rniwa"
    />
          </attachment>
      

    </bug>

</bugzilla>