<?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>171602</bug_id>
          
          <creation_ts>2017-05-03 05:36:42 -0700</creation_ts>
          <short_desc>REGRESSION(r215686): Incremental reads from SharedBuffer are wrong after r215686</short_desc>
          <delta_ts>2017-05-08 09:03:13 -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>Platform</component>
          <version>WebKit Nightly Build</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          <see_also>https://bugs.webkit.org/show_bug.cgi?id=170956</see_also>
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>Gtk, LayoutTestFailure</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Carlos Garcia Campos">cgarcia</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>achristensen</cc>
    
    <cc>ap</cc>
    
    <cc>buildbot</cc>
    
    <cc>cdumez</cc>
    
    <cc>dbates</cc>
    
    <cc>eric.carlson</cc>
    
    <cc>japhet</cc>
    
    <cc>jer.noble</cc>
    
    <cc>mcatanzaro</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1304008</commentid>
    <comment_count>0</comment_count>
    <who name="Carlos Garcia Campos">cgarcia</who>
    <bug_when>2017-05-03 05:36:42 -0700</bug_when>
    <thetext>In TextTrackLoader::processNewCueData() and PNGImageReader::decode() we changed the patter to read data from a SharedBuffer at a given offset. The new pattern is not correct, because it assumes the whole segment is always read, and the new offset is not correct when that&apos;s not the case. This has broken the rendering of png images in the GTK+ port, only the first bytes are correctly decoded and drawn, but not the rest of the image. See for example:

https://build.webkit.org/results/GTK Linux 64-bit Release (Tests)/r216114 (888)/editing/pasteboard/paste-image-using-image-data-diff.png</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1304010</commentid>
    <comment_count>1</comment_count>
      <attachid>308899</attachid>
    <who name="Carlos Garcia Campos">cgarcia</who>
    <bug_when>2017-05-03 05:42:33 -0700</bug_when>
    <thetext>Created attachment 308899
Patch</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1304392</commentid>
    <comment_count>2</comment_count>
      <attachid>308899</attachid>
    <who name="Alexey Proskuryakov">ap</who>
    <bug_when>2017-05-03 16:59:41 -0700</bug_when>
    <thetext>Comment on attachment 308899
Patch

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

&gt; Source/WebCore/loader/TextTrackLoader.cpp:103
&gt; -        m_cueParser-&gt;parseBytes(segment-&gt;data() + bytesToSkip, segment-&gt;size() - bytesToSkip);
&gt; +        auto bytesToUse = segment-&gt;size() - bytesToSkip;
&gt; +        m_cueParser-&gt;parseBytes(segment-&gt;data() + bytesToSkip, bytesToUse);
&gt;          bytesToSkip = 0;
&gt; -        m_parseOffset += segment-&gt;size();
&gt; +        m_parseOffset += bytesToUse;

There doesn&apos;t seem to be a test for this part of the patch. What does this fix?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1304524</commentid>
    <comment_count>3</comment_count>
    <who name="Carlos Garcia Campos">cgarcia</who>
    <bug_when>2017-05-03 23:00:39 -0700</bug_when>
    <thetext>(In reply to Alexey Proskuryakov from comment #2)
&gt; Comment on attachment 308899 [details]
&gt; Patch
&gt; 
&gt; View in context:
&gt; https://bugs.webkit.org/attachment.cgi?id=308899&amp;action=review
&gt; 
&gt; &gt; Source/WebCore/loader/TextTrackLoader.cpp:103
&gt; &gt; -        m_cueParser-&gt;parseBytes(segment-&gt;data() + bytesToSkip, segment-&gt;size() - bytesToSkip);
&gt; &gt; +        auto bytesToUse = segment-&gt;size() - bytesToSkip;
&gt; &gt; +        m_cueParser-&gt;parseBytes(segment-&gt;data() + bytesToSkip, bytesToUse);
&gt; &gt;          bytesToSkip = 0;
&gt; &gt; -        m_parseOffset += segment-&gt;size();
&gt; &gt; +        m_parseOffset += bytesToUse;
&gt; 
&gt; There doesn&apos;t seem to be a test for this part of the patch. What does this
&gt; fix?

I don&apos;t even know what TextTrackLoader is, but the pattern to read the data is exactly the same as in PNGEncoder, so this will fail the same way in case of incremental reads where bytesToSkip != 0 in any of the reads. Alex said he was going to add API to SharedBuffer to make it easier to read this way, so this and PNGEncoder will be updated too eventually.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1304529</commentid>
    <comment_count>4</comment_count>
    <who name="Carlos Garcia Campos">cgarcia</who>
    <bug_when>2017-05-03 23:14:46 -0700</bug_when>
    <thetext>Committed r216174: &lt;http://trac.webkit.org/changeset/216174&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1305871</commentid>
    <comment_count>5</comment_count>
      <attachid>308899</attachid>
    <who name="Alex Christensen">achristensen</who>
    <bug_when>2017-05-08 09:03:13 -0700</bug_when>
    <thetext>Comment on attachment 308899
Patch

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

&gt;&gt;&gt; Source/WebCore/loader/TextTrackLoader.cpp:103
&gt;&gt;&gt; +        m_parseOffset += bytesToUse;
&gt;&gt; 
&gt;&gt; There doesn&apos;t seem to be a test for this part of the patch. What does this fix?
&gt; 
&gt; I don&apos;t even know what TextTrackLoader is, but the pattern to read the data is exactly the same as in PNGEncoder, so this will fail the same way in case of incremental reads where bytesToSkip != 0 in any of the reads. Alex said he was going to add API to SharedBuffer to make it easier to read this way, so this and PNGEncoder will be updated too eventually.

To clarify, we shouldn&apos;t add API to SharedBuffer to read from a certain offset.  Since we always read entire segments from SharedBuffers, we should stop keeping track of how many bytes we have read and instead keep track of how many segments we have read.  Then we can skip to a segment with a known index instead of iterating all the segments and counting the number of bytes to skip.  This will require new SharedBuffer API, and it will make loading actually make sense.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>308899</attachid>
            <date>2017-05-03 05:42:33 -0700</date>
            <delta_ts>2017-05-03 09:47:11 -0700</delta_ts>
            <desc>Patch</desc>
            <filename>wk-shared-buffer-partial-read.diff</filename>
            <type>text/plain</type>
            <size>3137</size>
            <attacher name="Carlos Garcia Campos">cgarcia</attacher>
            
              <data encoding="base64">ZGlmZiAtLWdpdCBhL1NvdXJjZS9XZWJDb3JlL0NoYW5nZUxvZyBiL1NvdXJjZS9XZWJDb3JlL0No
YW5nZUxvZwppbmRleCA3ODIzZjhkNzQwYi4uMzljYzhjNjdmMDggMTAwNjQ0Ci0tLSBhL1NvdXJj
ZS9XZWJDb3JlL0NoYW5nZUxvZworKysgYi9Tb3VyY2UvV2ViQ29yZS9DaGFuZ2VMb2cKQEAgLTEs
MyArMSwyMiBAQAorMjAxNy0wNS0wMyAgQ2FybG9zIEdhcmNpYSBDYW1wb3MgIDxjZ2FyY2lhQGln
YWxpYS5jb20+CisKKyAgICAgICAgUkVHUkVTU0lPTihyMjE1Njg2KTogSW5jcmVtZW50YWwgcmVh
ZHMgZnJvbSBTaGFyZWRCdWZmZXIgYXJlIHdyb25nIGFmdGVyIHIyMTU2ODYKKyAgICAgICAgaHR0
cHM6Ly9idWdzLndlYmtpdC5vcmcvc2hvd19idWcuY2dpP2lkPTE3MTYwMgorCisgICAgICAgIFJl
dmlld2VkIGJ5IE5PQk9EWSAoT09QUyEpLgorCisgICAgICAgIEluIFRleHRUcmFja0xvYWRlcjo6
cHJvY2Vzc05ld0N1ZURhdGEoKSBhbmQgUE5HSW1hZ2VSZWFkZXI6OmRlY29kZSgpIHdlIGNoYW5n
ZWQgdGhlIHBhdHRlciB0byByZWF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RhdGEoKSArIGJ5dGVzVG9Ta2lwKSksIGJ5dGVzVG9Vc2UpOwogICAgICAgICAgICAgYnl0
ZXNUb1NraXAgPSAwOwogICAgICAgICAgICAgLy8gV2UgZXhwbGljaXRseSBzcGVjaWZ5IHRoZSBz
dXBlcmNsYXNzIGVuY29kZWREYXRhU3RhdHVzKCkgYmVjYXVzZSB3ZQogICAgICAgICAgICAgLy8g
bWVyZWx5IHdhbnQgdG8gY2hlY2sgaWYgd2UndmUgbWFuYWdlZCB0byBzZXQgdGhlIHNpemUsIG5v
dAo=
</data>
<flag name="review"
          id="330067"
          type_id="1"
          status="+"
          setter="mcatanzaro"
    />
          </attachment>
      

    </bug>

</bugzilla>