<?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>13455</bug_id>
          
          <creation_ts>2007-04-23 11:01:07 -0700</creation_ts>
          <short_desc>FrameView::layout() not always resuming scheduled events</short_desc>
          <delta_ts>2007-07-05 13:47:17 -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>Layout and Rendering</component>
          <version>523.x (Safari 3)</version>
          <rep_platform>All</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Kevin Ollivier">kevino</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>mitz</cc>
    
    <cc>paulgod</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>13188</commentid>
    <comment_count>0</comment_count>
    <who name="Kevin Ollivier">kevino</who>
    <bug_when>2007-04-23 11:01:07 -0700</bug_when>
    <thetext>Recently, the wx port started triggering an assert in FrameView::~FrameView, caused by the fact that d-&gt;m_enqueueEvents &gt; 0. Tracking this down, I&apos;ve found the reason for this appears to be that in FrameView::layout(), while pauseSelectedEvents() is always called, resumeSelectedEvents() is only triggered if root-&gt;needsLayout() (the if statement in line #453) is false. If root-&gt;needsLayout() is true, a layout is scheduled and the function exits without resuming scheduled events.

Since I&apos;m not too familiar with the bugs fixed by pause/resumeSelectedEvents(), I&apos;m not sure how best to fix this problem (though Mitz said on IRC that he might :-), so I thought I&apos;d just file a bug for this so that those familiar with the code can take a look.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>13178</commentid>
    <comment_count>1</comment_count>
    <who name="">mitz</who>
    <bug_when>2007-04-23 11:51:38 -0700</bug_when>
    <thetext>Admittedly, I don&apos;t know how to trigger the early return code path, but I think the fix should be along the lines of calling resumeScheduledEvents from there but also patching resumeScheduledEvents to not fire the events when the counter reaches 0 if a layout is scheduled. When that layout happens, it will call pause/resume again and the events will be fired.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>13069</commentid>
    <comment_count>2</comment_count>
      <attachid>14153</attachid>
    <who name="">mitz</who>
    <bug_when>2007-04-24 01:37:36 -0700</bug_when>
    <thetext>Created attachment 14153
Possible fix

This should fix the pause/resume unbalance. Kevin, I would like to know whether it fixes the bug for you or maybe you hit a different assert down the line. Also, so that I could make a layout test for the patch, can you tell me how you trigger the early return from layout()?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>13070</commentid>
    <comment_count>3</comment_count>
    <who name="Dave Hyatt">hyatt</who>
    <bug_when>2007-04-24 02:01:49 -0700</bug_when>
    <thetext>I actually don&apos;t think it should be possible to have the root still needing layout without having something miscoded somewhere.  I think it might be better to just yank the early return and replace it with an assert that the root doesn&apos;t need layout.

</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>13075</commentid>
    <comment_count>4</comment_count>
    <who name="">mitz</who>
    <bug_when>2007-04-24 02:30:50 -0700</bug_when>
    <thetext>(In reply to comment #3)
&gt; I actually don&apos;t think it should be possible to have the root still needing
&gt; layout without having something miscoded somewhere.  I think it might be better
&gt; to just yank the early return and replace it with an assert that the root
&gt; doesn&apos;t need layout.
&gt; 

I think the client can dirty the layout in its didFirstLayout callback.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>13077</commentid>
    <comment_count>5</comment_count>
    <who name="Dave Hyatt">hyatt</who>
    <bug_when>2007-04-24 03:07:08 -0700</bug_when>
    <thetext>That is completely unsupported and won&apos;t work right now even with the early return.

Many times layout is called as a result of paint.  If you still need layout after a paint, we&apos;re going to assert anyway when we try to paint (and possibly crash if didFirstLayout invalidated table sections).
</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>13078</commentid>
    <comment_count>6</comment_count>
    <who name="Dave Hyatt">hyatt</who>
    <bug_when>2007-04-24 03:08:29 -0700</bug_when>
    <thetext>Also, layout scheduling has been reenabled by the time didFirstLayout gets called, so if it did cause a dirty of the root, the layout would be scheduled already anyway.
</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>13079</commentid>
    <comment_count>7</comment_count>
    <who name="Dave Hyatt">hyatt</who>
    <bug_when>2007-04-24 03:09:34 -0700</bug_when>
    <thetext>(updateDashboardRegions is another possible route through which a rogue layout could be scheduled.)
</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>13080</commentid>
    <comment_count>8</comment_count>
    <who name="Dave Hyatt">hyatt</who>
    <bug_when>2007-04-24 03:14:18 -0700</bug_when>
    <thetext>Basically it&apos;s not clear to me what is dangerous about any of the lines of code that execute after that early return anyway.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>12994</commentid>
    <comment_count>9</comment_count>
    <who name="Kevin Ollivier">kevino</who>
    <bug_when>2007-04-24 11:16:21 -0700</bug_when>
    <thetext>I added the assert, and it is being triggered very early on, even before the page gets displayed. I removed my one client call to setNeedsLayout()/scheduleRelayout() (which is used by wx when the native control&apos;s size changes), but the assert still gets triggered.

The assert is fired from a layout called by FrameView::layoutTimerFired. I put a break in the scheduleRelayout function, and I found that the first three times it is called, it does lead to the assert. (The calls are coming from Document::updateStyleSelector in response to receiving data from the ResourceManager.)

The fourth time the call comes from HTMLBodyElement::InsertIntoDocument (starting from HTMLTokenizer::timerFired), and it is from this code path that it eventually asserts. However, since I&apos;m not too familiar with the rendering engine yet, I&apos;m not sure what exactly I should be looking for in terms of needsLayout() being set incorrectly, or not reset properly. 

Any tips on how I can track this down further? Thanks for all your help!</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>12995</commentid>
    <comment_count>10</comment_count>
    <who name="Kevin Ollivier">kevino</who>
    <bug_when>2007-04-24 11:18:19 -0700</bug_when>
    <thetext>Sorry, typo in my last message. First sentence in the second paragraph should say: 

and I found that the first three times it is called, it does **not** lead to the assert</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>9114</commentid>
    <comment_count>11</comment_count>
    <who name="Kevin Ollivier">kevino</who>
    <bug_when>2007-05-25 10:55:49 -0700</bug_when>
    <thetext>BTW, I wanted to give an update on this. I&apos;ve done some more testing and found that the underlying cause was that I was trying to schedule layouts during size events. I was doing this for performance reasons - we support live resize on Mac and I didn&apos;t want the repaints to cause the resize to be sluggish. In any case, I realize now that this solution wasn&apos;t the correct one, and have corrected my code so that it does not assert. 

Based on that, I think Hyatt&apos;s comment about asserting is a good idea - if it had asserted when I first added the code, I wouldn&apos;t have had to track down what change caused it. I&apos;ll try to take some time out this weekend to prepare a patch and submit it.

Thanks for all your help on this and sorry I mistook a problem with the port for a WebCore issue. :-/</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>5503</commentid>
    <comment_count>12</comment_count>
    <who name="">mitz</who>
    <bug_when>2007-07-05 13:47:17 -0700</bug_when>
    <thetext>Fixed in &lt;http://trac.webkit.org/projects/webkit/changeset/23866&gt;.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>14153</attachid>
            <date>2007-04-24 01:37:36 -0700</date>
            <delta_ts>2007-04-24 01:37:36 -0700</delta_ts>
            <desc>Possible fix</desc>
            <filename>13455_r0.patch</filename>
            <type>text/plain</type>
            <size>2147</size>
            <attacher>mitz</attacher>
            
              <data encoding="base64">SW5kZXg6IFdlYkNvcmUvcGFnZS9GcmFtZVZpZXcuY3BwCj09PT09PT09PT09PT09PT09PT09PT09
PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KLS0tIFd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