<?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>195228</bug_id>
          
          <creation_ts>2019-03-01 14:04:30 -0800</creation_ts>
          <short_desc>gPictureOwnerMap is unnecessary</short_desc>
          <delta_ts>2019-03-04 19:26:21 -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>DOM</component>
          <version>WebKit Nightly Build</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</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="Ryosuke Niwa">rniwa</reporter>
          <assigned_to name="Ryosuke Niwa">rniwa</assigned_to>
          <cc>cdumez</cc>
    
    <cc>dbates</cc>
    
    <cc>dino</cc>
    
    <cc>esprehn+autocc</cc>
    
    <cc>ews-watchlist</cc>
    
    <cc>gyuyoung.kim</cc>
    
    <cc>simon.fraser</cc>
    
    <cc>webkit-bug-importer</cc>
    
    <cc>zalan</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1511605</commentid>
    <comment_count>0</comment_count>
    <who name="Ryosuke Niwa">rniwa</who>
    <bug_when>2019-03-01 14:04:30 -0800</bug_when>
    <thetext>We can just store it in HTMLImageElement.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1511606</commentid>
    <comment_count>1</comment_count>
      <attachid>363373</attachid>
    <who name="Ryosuke Niwa">rniwa</who>
    <bug_when>2019-03-01 14:09:23 -0800</bug_when>
    <thetext>Created attachment 363373
Fixes the bug</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1511865</commentid>
    <comment_count>2</comment_count>
      <attachid>363373</attachid>
    <who name="Daniel Bates">dbates</who>
    <bug_when>2019-03-02 15:30:07 -0800</bug_when>
    <thetext>Comment on attachment 363373
Fixes the bug

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

&gt; Source/WebCore/ChangeLog:8
&gt; +        Just store in HTMLImageElement. An extra pointer isn&apos;t going to affect the memory use here.

I’m leaning towards you’re right, but I just can’t shake my intuition that images are the most used subresource on the internet today (now there is more than one way to load an image and I don’t know the breakdown in usage for that). This thought prevents me from reviewing this patch without seeing some numbers or reassurance that you actually thought this through because you’re increasing the size of each &lt;img&gt; by 8 bytes. Yes, I know there is overhead for the HashMap, but we pay it once no matter how many images a page has and, for now, how many images in loaded in subframes.

&gt; Source/WebCore/ChangeLog:9
&gt; +        If anything, we should worry about m_editableImage and m_pendingClonedAttachmentID instead.

Why? What is so different about these things? At least the latter is conditionally compiled in so only platforms that enable it pay the cost.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1512348</commentid>
    <comment_count>3</comment_count>
      <attachid>363373</attachid>
    <who name="Ryosuke Niwa">rniwa</who>
    <bug_when>2019-03-04 13:46:59 -0800</bug_when>
    <thetext>Comment on attachment 363373
Fixes the bug

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

&gt;&gt; Source/WebCore/ChangeLog:8
&gt;&gt; +        Just store in HTMLImageElement. An extra pointer isn&apos;t going to affect the memory use here.
&gt; 
&gt; I’m leaning towards you’re right, but I just can’t shake my intuition that images are the most used subresource on the internet today (now there is more than one way to load an image and I don’t know the breakdown in usage for that). This thought prevents me from reviewing this patch without seeing some numbers or reassurance that you actually thought this through because you’re increasing the size of each &lt;img&gt; by 8 bytes. Yes, I know there is overhead for the HashMap, but we pay it once no matter how many images a page has and, for now, how many images in loaded in subframes.

This is not something we need to get data to figure out.
We know for a matter of fact, the most resource consuming thing about an image is its backing store, not the image element itself.
In general, this kind of byte-by-byte counting we historically did turned out to be pretty silly exercise.
In today&apos;s web, the most of memory is going to text nodes, JS heap, CA layers, and other more memory hungry objects.

&gt;&gt; Source/WebCore/ChangeLog:9
&gt;&gt; +        If anything, we should worry about m_editableImage and m_pendingClonedAttachmentID instead.
&gt; 
&gt; Why? What is so different about these things? At least the latter is conditionally compiled in so only platforms that enable it pay the cost.

m_editableImage is definitely compiled on all platforms now, and nobody really uses it right now.
It&apos;s definitely not used in Safari and most of other web browsers.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1512355</commentid>
    <comment_count>4</comment_count>
    <who name="Ryosuke Niwa">rniwa</who>
    <bug_when>2019-03-04 14:00:30 -0800</bug_when>
    <thetext>Committed r242391: &lt;https://trac.webkit.org/changeset/242391&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1512358</commentid>
    <comment_count>5</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2019-03-04 14:14:04 -0800</bug_when>
    <thetext>&lt;rdar://problem/48576577&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1512438</commentid>
    <comment_count>6</comment_count>
    <who name="Daniel Bates">dbates</who>
    <bug_when>2019-03-04 18:00:25 -0800</bug_when>
    <thetext>(In reply to Ryosuke Niwa from comment #3)
&gt; Comment on attachment 363373 [details]
&gt; Fixes the bug
&gt; 
&gt; View in context:
&gt; https://bugs.webkit.org/attachment.cgi?id=363373&amp;action=review
&gt; 
&gt; &gt;&gt; Source/WebCore/ChangeLog:8
&gt; &gt;&gt; +        Just store in HTMLImageElement. An extra pointer isn&apos;t going to affect the memory use here.
&gt; &gt; 
&gt; &gt; I’m leaning towards you’re right, but I just can’t shake my intuition that images are the most used subresource on the internet today (now there is more than one way to load an image and I don’t know the breakdown in usage for that). This thought prevents me from reviewing this patch without seeing some numbers or reassurance that you actually thought this through because you’re increasing the size of each &lt;img&gt; by 8 bytes. Yes, I know there is overhead for the HashMap, but we pay it once no matter how many images a page has and, for now, how many images in loaded in subframes.
&gt; 
&gt; This is not something we need to get data to figure out.
&gt; We know for a matter of fact, the most resource consuming thing about an
&gt; image is its backing store, not the image element itself.

This is vacuously true (how many 8 byte images do you encounter now a days? Maybe still 1x1 spacer images? I’m not even talking about uncompressed, yet) and does not help me better understand when we should micro-optimize memory size and when not to.

&gt; In general, this kind of byte-by-byte counting we historically did turned
&gt; out to be pretty silly exercise.

I’m going remember this quote.

&gt; In today&apos;s web, the most of memory is going to text nodes, JS heap, CA
&gt; layers, and other more memory hungry objects.
&gt; 
&gt; &gt;&gt; Source/WebCore/ChangeLog:9
&gt; &gt;&gt; +        If anything, we should worry about m_editableImage and m_pendingClonedAttachmentID instead.
&gt; &gt; 
&gt; &gt; Why? What is so different about these things? At least the latter is conditionally compiled in so only platforms that enable it pay the cost.
&gt; 
&gt; m_editableImage is definitely compiled on all platforms now, and nobody
&gt; really uses it right now.
&gt; It&apos;s definitely not used in Safari and most of other web browsers.

m_editableImage was the least important bit in that sentence</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1512460</commentid>
    <comment_count>7</comment_count>
    <who name="Ryosuke Niwa">rniwa</who>
    <bug_when>2019-03-04 19:26:21 -0800</bug_when>
    <thetext>(In reply to Daniel Bates from comment #6)
&gt; (In reply to Ryosuke Niwa from comment #3)
&gt; &gt; Comment on attachment 363373 [details]
&gt; &gt; Fixes the bug
&gt; &gt; 
&gt; &gt; View in context:
&gt; &gt; https://bugs.webkit.org/attachment.cgi?id=363373&amp;action=review
&gt; &gt; 
&gt; &gt; &gt;&gt; Source/WebCore/ChangeLog:8
&gt; &gt; &gt;&gt; +        Just store in HTMLImageElement. An extra pointer isn&apos;t going to affect the memory use here.
&gt; &gt; &gt; 
&gt; &gt; &gt; I’m leaning towards you’re right, but I just can’t shake my intuition that images are the most used subresource on the internet today (now there is more than one way to load an image and I don’t know the breakdown in usage for that). This thought prevents me from reviewing this patch without seeing some numbers or reassurance that you actually thought this through because you’re increasing the size of each &lt;img&gt; by 8 bytes. Yes, I know there is overhead for the HashMap, but we pay it once no matter how many images a page has and, for now, how many images in loaded in subframes.
&gt; &gt; 
&gt; &gt; This is not something we need to get data to figure out.
&gt; &gt; We know for a matter of fact, the most resource consuming thing about an
&gt; &gt; image is its backing store, not the image element itself.
&gt; 
&gt; This is vacuously true (how many 8 byte images do you encounter now a days?
&gt; Maybe still 1x1 spacer images? I’m not even talking about uncompressed, yet)
&gt; and does not help me better understand when we should micro-optimize memory
&gt; size and when not to.

1x1 spacer images used to be popular but not anymore.
I think we&apos;ve over-optimized WebCore by thinking all these tiny increase matters.

&gt; &gt; In today&apos;s web, the most of memory is going to text nodes, JS heap, CA
&gt; &gt; layers, and other more memory hungry objects.
&gt; &gt; 
&gt; &gt; &gt;&gt; Source/WebCore/ChangeLog:9
&gt; &gt; &gt;&gt; +        If anything, we should worry about m_editableImage and m_pendingClonedAttachmentID instead.
&gt; &gt; &gt; 
&gt; &gt; &gt; Why? What is so different about these things? At least the latter is conditionally compiled in so only platforms that enable it pay the cost.
&gt; &gt; 
&gt; &gt; m_editableImage is definitely compiled on all platforms now, and nobody
&gt; &gt; really uses it right now.
&gt; &gt; It&apos;s definitely not used in Safari and most of other web browsers.
&gt; 
&gt; m_editableImage was the least important bit in that sentence

I don&apos;t get what your point is but my point stands that HTMLImageElement has other pointers that are way less frequently used than m_pictureElement. In particular, m_editableImage, is currently never used by any WebKit client. If we&apos;re worried about the memory usage of pointers in HTMLImageElement, we should be worrying about m_editableImage, not m_pictureElement.

HTMLImageElement also has things like m_bestFitImageURL, m_currentSrc, m_parsedUsemap, m_form, m_formSetByParser, all of which are rarely used. Again, we should be worrying about these pointers if we&apos;re truly worried about the size of HTMLImageElement.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>363373</attachid>
            <date>2019-03-01 14:09:23 -0800</date>
            <delta_ts>2019-03-04 13:55:51 -0800</delta_ts>
            <desc>Fixes the bug</desc>
            <filename>bug-195228-20190301140922.patch</filename>
            <type>text/plain</type>
            <size>3001</size>
            <attacher name="Ryosuke Niwa">rniwa</attacher>
            
              <data encoding="base64">SW5kZXg6IFNvdXJjZS9XZWJDb3JlL0NoYW5nZUxvZwo9PT09PT09PT09PT09PT09PT09PT09PT09
PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09Ci0tLSBTb3VyY2UvV2Vi
Q29yZS9DaGFuZ2VMb2cJKHJldmlzaW9uIDI0MjI4NykKKysrIFNvdXJjZS9XZWJDb3JlL0NoYW5n
ZUxvZwkod29ya2luZyBjb3B5KQpAQCAtMSwzICsxLDE4IEBACisyMDE5LTAzLTAxICBSeW9zdWtl
IE5pd2EgIDxybml3YUB3ZWJraXQub3JnPgorCisgICAgICAgIGdQaWN0dXJlT3duZXJNYXAgaXMg
dW5uZWNlc3NhcnkKKyAgICAgICAgaHR0cHM6Ly9idWdzLndlYmtpdC5vcmcvc2hvd19idWcuY2dp
P2lkPTE5NTIyOAorCisgICAgICAgIFJldmlld2VkIGJ5IE5PQk9EWSAoT09QUyEpLgorCisgICAg
ICAgIEp1c3Qgc3RvcmUgaW4gSFRNTEltYWdlRWxlbWVudC4gQW4gZXh0cmEgcG9pbnRlciBpc24n
dCBnb2luZyB0byBhZmZlY3QgdGhlIG1lbW9yeSB1c2UgaGVyZS4KKyAgICAgICAgSWYgYW55dGhp
bmcsIHdlIHNob3VsZCB3b3JyeSBhYm91dCBtX2VkaXRhYmxlSW1hZ2UgYW5kIG1fcGVuZGluZ0Ns
b25lZEF0dGFjaG1lbnRJRCBpbnN0ZWFkLgorCisgICAgICAgICogaHRtbC9IVE1MSW1hZ2VFbGVt
ZW50LmNwcDoKKyAgICAgICAgKFdlYkNvcmU6OkhUTUxJbWFnZUVsZW1lbnQ6OnBpY3R1cmVFbGVt
Z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bWFrZVdlYWtQdHIocGljdHVyZUVs
ZW1lbnQpOwogfQogICAgIAogdW5zaWduZWQgSFRNTEltYWdlRWxlbWVudDo6d2lkdGgoYm9vbCBp
Z25vcmVQZW5kaW5nU3R5bGVzaGVldHMpCkluZGV4OiBTb3VyY2UvV2ViQ29yZS9odG1sL0hUTUxJ
bWFnZUVsZW1lbnQuaAo9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09
PT09PT09PT09PT09PT09PT09PT09PT09Ci0tLSBTb3VyY2UvV2ViQ29yZS9odG1sL0hUTUxJbWFn
ZUVsZW1lbnQuaAkocmV2aXNpb24gMjQyMjc2KQorKysgU291cmNlL1dlYkNvcmUvaHRtbC9IVE1M
SW1hZ2VFbGVtZW50LmgJKHdvcmtpbmcgY29weSkKQEAgLTE4NSw2ICsxODUsOCBAQCBwcml2YXRl
OgogICAgIGJvb2wgbV9oYWROYW1lQmVmb3JlQXR0cmlidXRlQ2hhbmdlZCB7IGZhbHNlIH07IC8v
IEZJWE1FOiBXZSBvbmx5IG5lZWQgdGhpcyBiZWNhdXNlIHBhcnNlQXR0cmlidXRlKCkgY2FuJ3Qg
c2VlIHRoZSBvbGQgdmFsdWUuCiAKICAgICBSZWZQdHI8RWRpdGFibGVJbWFnZVJlZmVyZW5jZT4g
bV9lZGl0YWJsZUltYWdlOworICAgIFdlYWtQdHI8SFRNTFBpY3R1cmVFbGVtZW50PiBtX3BpY3R1
cmVFbGVtZW50OworCiAjaWYgRU5BQkxFKEFUVEFDSE1FTlRfRUxFTUVOVCkKICAgICBTdHJpbmcg
bV9wZW5kaW5nQ2xvbmVkQXR0YWNobWVudElEOwogI2VuZGlmCg==
</data>
<flag name="review"
          id="379977"
          type_id="1"
          status="+"
          setter="zalan"
    />
          </attachment>
      

    </bug>

</bugzilla>