<?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>203811</bug_id>
          
          <creation_ts>2019-11-04 07:15:46 -0800</creation_ts>
          <short_desc>Collect all documents before iterating in Page::forEachDocument</short_desc>
          <delta_ts>2019-11-04 17:27:20 -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>New Bugs</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="Alex Christensen">achristensen</reporter>
          <assigned_to name="Alex Christensen">achristensen</assigned_to>
          <cc>ap</cc>
    
    <cc>cdumez</cc>
    
    <cc>commit-queue</cc>
    
    <cc>rniwa</cc>
    
    <cc>webkit-bug-importer</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1586970</commentid>
    <comment_count>0</comment_count>
    <who name="Alex Christensen">achristensen</who>
    <bug_when>2019-11-04 07:15:46 -0800</bug_when>
    <thetext>Collect all documents before iterating in Page::forEachDocument</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1586971</commentid>
    <comment_count>1</comment_count>
      <attachid>382736</attachid>
    <who name="Alex Christensen">achristensen</who>
    <bug_when>2019-11-04 07:18:42 -0800</bug_when>
    <thetext>Created attachment 382736
Patch</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1586972</commentid>
    <comment_count>2</comment_count>
    <who name="Alex Christensen">achristensen</who>
    <bug_when>2019-11-04 07:18:47 -0800</bug_when>
    <thetext>&lt;rdar://problem/56832747&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1587028</commentid>
    <comment_count>3</comment_count>
      <attachid>382736</attachid>
    <who name="Alexey Proskuryakov">ap</who>
    <bug_when>2019-11-04 09:44:15 -0800</bug_when>
    <thetext>Comment on attachment 382736
Patch

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

&gt; Source/WebCore/page/Page.cpp:2873
&gt; +    for (auto&amp; document : collectDocuments())
&gt; +        functor(document);

While this pattern prevents some problems, it&apos;s inherently incorrect too. Callers of functions like &quot;forEachDocument&quot; would naturally expect that all documents had the functor applied after the call, which is not going to happen in case of additions.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1587029</commentid>
    <comment_count>4</comment_count>
    <who name="Chris Dumez">cdumez</who>
    <bug_when>2019-11-04 09:45:32 -0800</bug_when>
    <thetext>(In reply to Alexey Proskuryakov from comment #3)
&gt; Comment on attachment 382736 [details]
&gt; Patch
&gt; 
&gt; View in context:
&gt; https://bugs.webkit.org/attachment.cgi?id=382736&amp;action=review
&gt; 
&gt; &gt; Source/WebCore/page/Page.cpp:2873
&gt; &gt; +    for (auto&amp; document : collectDocuments())
&gt; &gt; +        functor(document);
&gt; 
&gt; While this pattern prevents some problems, it&apos;s inherently incorrect too.
&gt; Callers of functions like &quot;forEachDocument&quot; would naturally expect that all
&gt; documents had the functor applied after the call, which is not going to
&gt; happen in case of additions.

I agree with Alexey. Seems like the issue may be with the call sites which modify the frame tree as they iterate.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1587109</commentid>
    <comment_count>5</comment_count>
      <attachid>382736</attachid>
    <who name="Ryosuke Niwa">rniwa</who>
    <bug_when>2019-11-04 13:07:45 -0800</bug_when>
    <thetext>Comment on attachment 382736
Patch

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

&gt;&gt;&gt; Source/WebCore/page/Page.cpp:2873
&gt;&gt;&gt; +        functor(document);
&gt;&gt; 
&gt;&gt; While this pattern prevents some problems, it&apos;s inherently incorrect too. Callers of functions like &quot;forEachDocument&quot; would naturally expect that all documents had the functor applied after the call, which is not going to happen in case of additions.
&gt; 
&gt; I agree with Alexey. Seems like the issue may be with the call sites which modify the frame tree as they iterate.

If we&apos;re firing resize event, then it&apos;s inherently possible for those event listeners to modify the frame tree structure.
I don&apos;t think we can simultaneously satisfy the need to fire scripts and iterating all frames at the same time.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1587120</commentid>
    <comment_count>6</comment_count>
    <who name="Alexey Proskuryakov">ap</who>
    <bug_when>2019-11-04 13:24:37 -0800</bug_when>
    <thetext>Have other browsers solved this? Should be straightforward to build a test case that&apos;s broken with the proposed implementation.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1587123</commentid>
    <comment_count>7</comment_count>
    <who name="Ryosuke Niwa">rniwa</who>
    <bug_when>2019-11-04 13:26:14 -0800</bug_when>
    <thetext>(In reply to Alexey Proskuryakov from comment #6)
&gt; Have other browsers solved this? Should be straightforward to build a test
&gt; case that&apos;s broken with the proposed implementation.

If a new frame is inserted in the midst of resize event, that document hasn&apos;t been &quot;resized&quot; because it just got inserted. Similar for other viewport related events.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1587125</commentid>
    <comment_count>8</comment_count>
    <who name="Ryosuke Niwa">rniwa</who>
    <bug_when>2019-11-04 13:32:59 -0800</bug_when>
    <thetext>By the way, our implementation of all these events are so off the standard that the last thing I&apos;m worried about will be the edge case of an iframe inserted during other resize events. We&apos;d need to first move the time we compute whether a resize event is needed or not to Page::updateRendering. Unfortunately, I don&apos;t think I&apos;ll ever get to it in time.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1587140</commentid>
    <comment_count>9</comment_count>
      <attachid>382736</attachid>
    <who name="WebKit Commit Bot">commit-queue</who>
    <bug_when>2019-11-04 13:55:15 -0800</bug_when>
    <thetext>Comment on attachment 382736
Patch

Clearing flags on attachment: 382736

Committed r252013: &lt;https://trac.webkit.org/changeset/252013&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1587141</commentid>
    <comment_count>10</comment_count>
    <who name="WebKit Commit Bot">commit-queue</who>
    <bug_when>2019-11-04 13:55:17 -0800</bug_when>
    <thetext>All reviewed patches have been landed.  Closing bug.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1587223</commentid>
    <comment_count>11</comment_count>
    <who name="Alexey Proskuryakov">ap</who>
    <bug_when>2019-11-04 16:20:15 -0800</bug_when>
    <thetext>&quot;Page::forEachDocument&quot; doesn&apos;t say that it only works acceptably well for resize events.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1587234</commentid>
    <comment_count>12</comment_count>
    <who name="Ryosuke Niwa">rniwa</who>
    <bug_when>2019-11-04 17:27:20 -0800</bug_when>
    <thetext>(In reply to Alexey Proskuryakov from comment #11)
&gt; &quot;Page::forEachDocument&quot; doesn&apos;t say that it only works acceptably well for
&gt; resize events.

I mean, we do this elsewhere in WebCore for Node, etc... none of those code explicitly say things may fail or skip even though they would. I don’t think this iterator function is any different from that.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>382736</attachid>
            <date>2019-11-04 07:18:42 -0800</date>
            <delta_ts>2019-11-04 13:55:15 -0800</delta_ts>
            <desc>Patch</desc>
            <filename>bug-203811-20191104151840.patch</filename>
            <type>text/plain</type>
            <size>1641</size>
            <attacher name="Alex Christensen">achristensen</attacher>
            
              <data encoding="base64">SW5kZXg6IFNvdXJjZS9XZWJDb3JlL0NoYW5nZUxvZwo9PT09PT09PT09PT09PT09PT09PT09PT09
PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09Ci0tLSBTb3VyY2UvV2Vi
Q29yZS9D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