<?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>120813</bug_id>
          
          <creation_ts>2013-09-05 17:07:50 -0700</creation_ts>
          <short_desc>Use of Uint8ClampedArray makes filters twice as slow</short_desc>
          <delta_ts>2022-12-30 16:39:31 -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>Layout and Rendering</component>
          <version>528+ (Nightly build)</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="Simon Fraser (smfr)">simon.fraser</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>ahmad.saleem792</cc>
    
    <cc>krit</cc>
    
    <cc>oliver</cc>
    
    <cc>savagobr</cc>
    
    <cc>simon.fraser</cc>
    
    <cc>thorton</cc>
    
    <cc>webkit-bug-importer</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>925294</commentid>
    <comment_count>0</comment_count>
    <who name="Simon Fraser (smfr)">simon.fraser</who>
    <bug_when>2013-09-05 17:07:50 -0700</bug_when>
    <thetext>I was curious about why blur filters on image backgrounds are incredibly slow. Sampling shows lots of time in GenericTypedArrayView::set(unsigned index, double value) const which is doing a safe double -&gt; int cast with clamping.

This comes out of a tight look in the blurring code:

                for (int x = 0; x &lt; effectWidth; ++x) {
                    int pixelByteOffset = line + x * stride + channel;
                    dstPixelArray-&gt;set(pixelByteOffset, static_cast&lt;unsigned char&gt;(sum / dx));

It&apos;s crazy that we&apos;re wasting time doing double -&gt; int conversion when the caller is passing in an unsigned char. We&apos;re converting double -&gt; unsigned char -&gt; double -&gt; int32_t -&gt; uint8_t

Bypassing this crap by just filling a uint8_t[] and using dstPixelArray-&gt;setRange() makes blurring twice as fast.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>925295</commentid>
    <comment_count>1</comment_count>
      <attachid>210684</attachid>
    <who name="Simon Fraser (smfr)">simon.fraser</who>
    <bug_when>2013-09-05 17:08:10 -0700</bug_when>
    <thetext>Created attachment 210684
Testcase</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>925724</commentid>
    <comment_count>2</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2013-09-06 11:08:52 -0700</bug_when>
    <thetext>&lt;rdar://problem/14930799&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>985658</commentid>
    <comment_count>3</comment_count>
    <who name="Adenilson Cavalcanti Silva">savagobr</who>
    <bug_when>2014-02-28 11:34:49 -0800</bug_when>
    <thetext>Started looking into this.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1922336</commentid>
    <comment_count>4</comment_count>
    <who name="Ahmad Saleem">ahmad.saleem792</who>
    <bug_when>2022-12-30 16:39:31 -0800</bug_when>
    <thetext>It is still taking several steps to blur completely in Safari 16.2 &amp; STP160 but this does not seem to be working in Chrome Canary 111 and Firefox Nightly 110 for some reasons even after modifying to change pic URL to HTTPS and removing -webkit- prefix in following:

URL - https://jsfiddle.net/unz3h758/2/show</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>210684</attachid>
            <date>2013-09-05 17:08:10 -0700</date>
            <delta_ts>2013-09-05 17:08:10 -0700</delta_ts>
            <desc>Testcase</desc>
            <filename>background-filters.html</filename>
            <type>text/html</type>
            <size>872</size>
            <attacher name="Simon Fraser (smfr)">simon.fraser</attacher>
            
              <data encoding="base64">PCFET0NUWVBFIGh0bWw+Cgo8aHRtbD4KPGhlYWQ+CiAgICA8c3R5bGU+CiAgICAgICAgLmJveCB7
CiAgICAgICAgICB3aWR0aDogNDI3cHg7CiAgICAgICAgICBoZWlnaHQ6IDY0MHB4OwogICAgICAg
ICAgYmFja2dyb3VuZC1pbWFnZTogLXdlYmtpdC1maWx0ZXIodXJsKGh0dHA6Ly9mYXJtNi5zdGF0
aWNmbGlja3IuY29tLzU1NDIvOTY2MjU5Njk4NF8yZTRjMjNjMDQxX3ouanBnKSwgYmx1cigwcHgp
KTsKICAgICAgICAgIGJhY2tncm91bmQtc2l6ZTogMTAwJSAxMDAlOwogICAgICAgICAgdHJhbnNp
dGlvbjogYmFja2dyb3VuZC1pbWFnZSA0czsKICAgICAgICB9CiAgICAgICAgCiAgICAgICAgLmJv
eC5jaGFuZ2VkLCAuYm94OmhvdmVyIHsKICAgICAgICAgICAgYmFja2dyb3VuZC1pbWFnZTogLXdl
YmtpdC1maWx0ZXIodXJsKGh0dHA6Ly9mYXJtNi5zdGF0aWNmbGlja3IuY29tLzU1NDIvOTY2MjU5
Njk4NF8yZTRjMjNjMDQxX3ouanBnKSwgYmx1cigxMHB4KSk7CiAgICAgICAgfQogICAgPC9zdHls
ZT4KICAgIDxzY3JpcHQ+CiAgICAgICAgCiAgICAgICAgZnVuY3Rpb24gZG9UZXN0KCkKICAgICAg
ICB7CiAgICAgICAgICAgIHdpbmRvdy5zZXRUaW1lb3V0KGZ1bmN0aW9uKCkgewogICAgICAgICAg
ICAgICAgZG9jdW1lbnQuZ2V0RWxlbWVudEJ5SWQoJ3RhcmdldCcpLmNsYXNzTGlzdC5hZGQoJ2No
YW5nZWQnKTsKICAgICAgICAgICAgfSwgMTAwMCk7CiAgICAgICAgfQogICAgICAgIHdpbmRvdy5h
ZGRFdmVudExpc3RlbmVyKCdsb2FkJywgZG9UZXN0LCBmYWxzZSk7CiAgICA8L3NjcmlwdD4KPC9o
ZWFkPgo8Ym9keT4KCiAgICA8ZGl2IGlkPSJ0YXJnZXQiIGNsYXNzPSJib3giPgogICAgPC9kaXY+
CjwvYm9keT4KPC9odG1sPgo=
</data>

          </attachment>
      

    </bug>

</bugzilla>