<?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>39094</bug_id>
          
          <creation_ts>2010-05-13 16:34:55 -0700</creation_ts>
          <short_desc>Web Inspector: Clearing Breakpoints Too Often</short_desc>
          <delta_ts>2010-05-16 13:50:26 -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>Web Inspector (Deprecated)</component>
          <version>528+ (Nightly build)</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="Joseph Pecoraro">joepeck</reporter>
          <assigned_to name="Joseph Pecoraro">joepeck</assigned_to>
          <cc>bweinstein</cc>
    
    <cc>joepeck</cc>
    
    <cc>keishi</cc>
    
    <cc>pfeldman</cc>
    
    <cc>pmuellr</cc>
    
    <cc>rik</cc>
    
    <cc>timothy</cc>
    
    <cc>yurys</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>225566</commentid>
    <comment_count>0</comment_count>
    <who name="Joseph Pecoraro">joepeck</who>
    <bug_when>2010-05-13 16:34:55 -0700</bug_when>
    <thetext>Just like workers, breakpoints should be preserved across simple resets.

Patch to follow.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>225569</commentid>
    <comment_count>1</comment_count>
      <attachid>56033</attachid>
    <who name="Joseph Pecoraro">joepeck</who>
    <bug_when>2010-05-13 16:43:38 -0700</bug_when>
    <thetext>Created attachment 56033
[PATCH] Preserve Breakpoints

Simple fix.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>225570</commentid>
    <comment_count>2</comment_count>
    <who name="Joseph Pecoraro">joepeck</who>
    <bug_when>2010-05-13 16:46:17 -0700</bug_when>
    <thetext>I&apos;ll have reproduction steps up in a minute. I could eventually see adding tests for reset on all panels eventually. I can open a bug for that.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>225575</commentid>
    <comment_count>3</comment_count>
    <who name="Joseph Pecoraro">joepeck</who>
    <bug_when>2010-05-13 17:03:07 -0700</bug_when>
    <thetext>Committed r59417
	M	WebCore/ChangeLog
	M	WebCore/inspector/front-end/ScriptsPanel.js
r59417 = 5a397efce539fa89f7b448e5b9aecc1ecdf1ca71 (refs/remotes/trunk)
http://trac.webkit.org/changeset/59417

Thanks!</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>225664</commentid>
    <comment_count>4</comment_count>
    <who name="Pavel Feldman">pfeldman</who>
    <bug_when>2010-05-13 22:07:02 -0700</bug_when>
    <thetext>Guys, is there a user scenario for this? My concern is that breakpoints were cleared intentionally and restored from the backend side upon reload based on the breakpoint &lt;-&gt; url mapping. Or is it some other kind of reset you are talking about?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>225666</commentid>
    <comment_count>5</comment_count>
    <who name="Joseph Pecoraro">joepeck</who>
    <bug_when>2010-05-13 22:11:43 -0700</bug_when>
    <thetext>User Scenario:

  1. User Opens Inspector
  2. Goes to Resources Panel
  3. Sets Breakpoint in Resource
  4. Goes to Scripts Panel (lazy loading will trigger reset())

This only fails if the Scripts Panel wasn&apos;t open yet.
And when it fails, its hard to diagnose. The Breakpoint
still appears on the SourceFrame/View however, the
Breakpoints SidebarPane does not show the breakpoint
and the debugger will not actually stop on it!

The example I forgot to put up was very basic html.

  &lt;button id=&quot;x&quot;&gt;Click Me&lt;p&gt;
  &lt;script&gt;
  document.getElementById(&apos;x&apos;).addEventListener(&apos;click&apos;, function() {
    1+1; // &lt;-- Put breakpoint here
  }, false);
  &lt;/script&gt;

If you follow the above scenario, you should trigger
the issue.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>225667</commentid>
    <comment_count>6</comment_count>
    <who name="Joseph Pecoraro">joepeck</who>
    <bug_when>2010-05-13 22:13:10 -0700</bug_when>
    <thetext>(In reply to comment #5)
Another common Scenario:
 
  1. User Opens Inspector
  2. Goes to Resources Panel
  3. Sets Breakpoint in Resource
  4. Triggers action causing Breakpoint
  5. Debugger Automatically Enabled =&gt; triggers reset() destroys breakpoint

Also possible to show with the test case in the prev.
comment&apos;s test code.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>225670</commentid>
    <comment_count>7</comment_count>
    <who name="Joseph Pecoraro">joepeck</who>
    <bug_when>2010-05-13 22:23:30 -0700</bug_when>
    <thetext>Arg. It looks like you might be right. Although I did
test with refreshing the page on my test case, I just
tested on another website and I&apos;m seeing duplicate
breakpoint entires after refresh. I have to leave the
office now, but I can take a look at this when I get home.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>225671</commentid>
    <comment_count>8</comment_count>
    <who name="Pavel Feldman">pfeldman</who>
    <bug_when>2010-05-13 22:29:45 -0700</bug_when>
    <thetext>Why I think this scenario is complex:
- When a breakpoint is set, it is being added into the &apos;m_stickyBreakpoints&apos; list in inspector controller by url and line.
- When debugging gets enabled, it adds a listener to jsc debugger and recompiles the scripts
- If scripts have matching url, frontend&apos;s restoredBreakpoint is called and the breakpoint should get propagated to the front-end.

So something is wrong with the order of cleanups here, but cleaning might still be necessary.

Reason underlying behavior is complex:
Imagine you make a reload and you have a breakpoint in the &lt;script&gt; tag of main resource. You won&apos;t have a chance to restore this breakpoint from the front-end since it is asynchronous. Front-end only knows about your page after main resource has been loaded, but we are actually supposed to stop on a breakpoint before that. So we restore these breakpoints synchronously in the inspector controller upon parse. 

So I guess the problem might be with the order of debuggerWasEnabled and restoredBreakpoint. It is worth checking at least. Scenario that I think might fail and is worth testing is whether disabling and further enabling scripts panel creates dupe breakpoints.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>225675</commentid>
    <comment_count>9</comment_count>
    <who name="Joseph Pecoraro">joepeck</who>
    <bug_when>2010-05-13 23:06:30 -0700</bug_when>
    <thetext>&gt; So I guess the problem might be with the order of debuggerWasEnabled
&gt; and restoredBreakpoint. It is worth checking at least. Scenario that I think
&gt; might fail and is worth testing is whether disabling and further enabling
&gt; scripts panel creates dupe breakpoints.

My patch seems to work fine with these scenarios. Where I was hitting
multiple breakpoints is in fact an issue that exists in the nightly and
is unchanged by this patch. You hint at why this could be happening.

Set a breakpoint on a minified line, such as line 8 of google.com and
disable/enable debugging or refresh the page. Many duplicates emerge.
This might even be desired behavior but with a poor UI. If you think
it is another bug we should open up another bugzilla bug.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>225681</commentid>
    <comment_count>10</comment_count>
    <who name="Pavel Feldman">pfeldman</who>
    <bug_when>2010-05-14 00:01:50 -0700</bug_when>
    <thetext>&gt; My patch seems to work fine with these scenarios. Where I was hitting
&gt; multiple breakpoints is in fact an issue that exists in the nightly and
&gt; is unchanged by this patch. You hint at why this could be happening.
&gt; 

Although the user-visible behavior is now correct, I still have reservations wrt fix. What happens does not meet my expectations (the whole story with restoring breakpoints). They should have been &apos;restored&apos; and hence get into the scripts panel after enabling. So there is another bug preventing this from happening.

What I don&apos;t like is that script debug server&apos;s breakpoints map is being populated even when debugger is disabled. Then, upon enabling, dupe breakpoints are likely to be created. Is this happening? So I&apos;d say that the fix is simply short-sighted.

This area is especially fragile since we have two different debugger implementations (jsc and v8). They use same front-end, so we need to keep them aligned. A fix that is working for one, may break the other unless we keep a picture of how debugger should interact with the front-end in mind. I did not check v8 yet, but I think this fix might be breaking it.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>225684</commentid>
    <comment_count>11</comment_count>
    <who name="Joseph Pecoraro">joepeck</who>
    <bug_when>2010-05-14 00:27:50 -0700</bug_when>
    <thetext>&gt; Although the user-visible behavior is now correct, I still have
&gt; reservations wrt fix. What happens does not meet my expectations
&gt; (the whole story with restoring breakpoints).

The bug in both of my user scenarios was front-end only.
Both times ScriptsPanel.reset(true) was getting called, delegating
down to the Script&apos;s panel&apos;s breakpoints.reset(). This clears the
visible breakpoints, but makes no effort to actually remove the
breakpoints. Now, in cases where the the user adds breakpoints
in the UI, those breakpoints are not removed from the UI
during common operations:

  1. selecting the Scripts panel
  2. hitting a breakpoint

The BreakpointsSidebarPane seems to prevent against
obvious UI duplicates (I haven&apos;t debugged this to see
what the breakpoint id&apos;s are when the duplicates appear)
but I find it unlikely that in case 1 there would be an issue.

    // Inside addBreakpoint:
    if (this.breakpoints[breakpoint.id])
        return;

The same basic stuff applies to case 2. I haven&apos;t
investigated deeply, but debuggerWasEnabled() calls
the reset(true), removing breakpoints from the UI.
Why when the debugger was enabled would we
want to remove the breakpoints we just potentially
set? =)

So I think this fix is the right fix for the user-visible side.
In that neither of these cases do we want the UI visible
breakpoints to be removed.


&gt; They should have been &apos;restored&apos; and hence get into the
&gt; scripts panel after enabling. So there is another bug
&gt; preventing this from happening.

Its not that they weren&apos;t getting into the scripts panel,
its that they were getting removed, and the above patch
fixed that. Am I missing something again?




&gt; What I don&apos;t like is that script debug server&apos;s breakpoints
&gt; map is being populated even when debugger is disabled.
&gt; Then, upon enabling, dupe breakpoints are likely to be
&gt; created. Is this happening? So I&apos;d say that the fix is
&gt; simply short-sighted.

So you do not want to allow the user to set a breakpoint
unless they have enabled the Debugger in the Scripts Panel?

Where would dupes come from by enabling the debugger?
The breakpoints that are set are already set, why would the
act of enabling the panel cause new breakpoints to be set?


&gt; This area is especially fragile since we have two different
&gt; debugger implementations (jsc and v8). They use same
&gt; front-end, so we need to keep them aligned. A fix that
&gt; is working for one, may break the other unless we keep
&gt; a picture of how debugger should interact with the
&gt; front-end in mind. I did not check v8 yet, but I think this
&gt; fix might be breaking it.

I&apos;m sorry. I should have waited for some feedback from the
Chrome team on this. However, I still maintain that my
changes are merely cosmetic.

Could you test this in Chrome and let me know if it produces
bad behavior?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>225687</commentid>
    <comment_count>12</comment_count>
    <who name="Joseph Pecoraro">joepeck</who>
    <bug_when>2010-05-14 00:32:12 -0700</bug_when>
    <thetext>&gt; However, I still maintain that my changes are merely cosmetic.

Well, considering earlier that I said: &quot;Breakpoints SidebarPane does
not show the breakpoint and the debugger will not actually stop on it!&quot;
this may not be the case.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>226531</commentid>
    <comment_count>13</comment_count>
    <who name="Joseph Pecoraro">joepeck</who>
    <bug_when>2010-05-16 13:38:12 -0700</bug_when>
    <thetext>It is still the case where when you set a breakpoint before the
debugger is enabled at all that the breakpoint will still show in
the SourceFrame (and now it will show in the BreakpointsSidebarPane)
but not actually have been registered in the backend, so it won&apos;t
actually break. I think that may have been what Pavel was talking
about. I wil file a bug on this.

This fix makes it the blue breakpoints on source lines match the
breakpoints in the BreakpointsSidebarPane. And I feel that is the
desired behavior. But apparently these breakpoints aren&apos;t really
getting registered until the ScriptsPanel (lazy?) loads the debugger.
That should probably happen automatically when the user sets a
breakpoint and had previously set their preference to Always allow
scripts debugging. Because clearly that is the user&apos;s intent.

Otherwise we should probably visually show &quot;this breakpoint won&apos;t
work yet because the Debugger isn&apos;t enabled.&quot;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>226533</commentid>
    <comment_count>14</comment_count>
    <who name="Joseph Pecoraro">joepeck</who>
    <bug_when>2010-05-16 13:50:26 -0700</bug_when>
    <thetext>Filed: https://bugs.webkit.org/show_bug.cgi?id=39185</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>56033</attachid>
            <date>2010-05-13 16:43:38 -0700</date>
            <delta_ts>2010-05-13 16:47:02 -0700</delta_ts>
            <desc>[PATCH] Preserve Breakpoints</desc>
            <filename>fix.patch</filename>
            <type>text/plain</type>
            <size>1498</size>
            <attacher name="Joseph Pecoraro">joepeck</attacher>
            
              <data encoding="base64">ZGlmZiAtLWdpdCBhL1dlYkNvcmUvQ2hhbmdlTG9nIGIvV2ViQ29yZS9DaGFuZ2VMb2cKaW5kZXgg
NGY4NDBlOC4uOTBhYmZkMCAxMDA2NDQKLS0tIGEvV2ViQ29yZS9DaGFuZ2VMb2cKKysrIGIvV2Vi
Q29yZS9DaGFuZ2VMb2cKQEAgLTEsMyArMSwxNSBAQAorMjAxMC0wNS0xMyAgSm9zZXBoIFBlY29y
YXJvICA8am9lcGVja0B3ZWJraXQub3JnPgorCisgICAgICAgIFJldmlld2VkIGJ5IE5PQk9EWSAo
T09QUyEpLgorCisgICAgICAgIFdlYiBJbnNwZWN0b3I6IENsZWFyaW5nIEJyZWFrcG9pbnRzIFRv
byBPZnRlbgorICAgICAgICBodHRwczovL2J1Z3Mud2Via2l0Lm9yZy9zaG93X2J1Zy5jZ2k/aWQ9
MzkwOTQKKworICAgICAgICBNaW5vciByZXNldHMgc2hvdWxkIHByZXNlcnZlIGJvdGggd29ya2Vy
cyBhbmQgYnJlYWtwb2ludHMuCisKKyAgICAgICAgKiBpbnNwZWN0b3IvZnJvbnQtZW5kL1Njcmlw
dHNQYW5lbC5qczoKKyAgICAgICAgKFdlYkluc3BlY3Rvci5TY3JpcHRzUGFuZWwucHJvdG90eXBl
LnJlc2V0KToKKwogMjAxMC0wNS0xMyAgU2ltb24gRnJhc2VyICA8c2ltb24uZnJhc2VyQGFwcGxl
LmNvbT4KIAogICAgICAgICBSZXZpZXdlZCBieSBEYXZlIEh5YXR0LgpkaWZmIC0tZ2l0IGEvV2Vi
Q29yZS9pbnNwZWN0b3IvZnJvbnQtZW5kL1NjcmlwdHNQYW5lbC5qcyBiL1dlYkNvcmUvaW5zcGVj
dG9yL2Zyb250LWVuZC9TY3JpcHRzUGFuZWwuanMKaW5kZXggNjM0NDU1NC4uZDE1MzZjZCAxMDA2
NDQKLS0tIGEvV2ViQ29yZS9pbnNwZWN0b3IvZnJvbnQtZW5kL1NjcmlwdHNQYW5lbC5qcworKysg
Yi9XZWJDb3JlL2luc3BlY3Rvci9mcm9udC1lbmQvU2NyaXB0c1BhbmVsLmpzCkBAIC00NzgsNyAr
NDc4LDcgQEAgV2ViSW5zcGVjdG9yLlNjcmlwdHNQYW5lbC5wcm90b3R5cGUgPSB7CiAgICAgICAg
IHRoaXMucmVzZXQodHJ1ZSk7CiAgICAgfSwKIAotICAgIHJlc2V0OiBmdW5jdGlvbihwcmVzZXJ2
ZVdvcmtlcnMpCisgICAgcmVzZXQ6IGZ1bmN0aW9uKHByZXNlcnZlSXRlbXMpCiAgICAgewogICAg
ICAgICB0aGlzLnZpc2libGVWaWV3ID0gbnVsbDsKIApAQCAtNTExLDExICs1MTEsMTIgQEAgV2Vi
SW5zcGVjdG9yLlNjcmlwdHNQYW5lbC5wcm90b3R5cGUgPSB7CiAgICAgICAgIH0KIAogICAgICAg
ICB0aGlzLl9zb3VyY2VJRE1hcCA9IHt9OwotICAgICAgICAKKwogICAgICAgICB0aGlzLnNpZGVi
YXJQYW5lcy53YXRjaEV4cHJlc3Npb25zLnJlZnJlc2hFeHByZXNzaW9ucygpOwotICAgICAgICB0
aGlzLnNpZGViYXJQYW5lcy5icmVha3BvaW50cy5yZXNldCgpOwotICAgICAgICBpZiAoIXByZXNl
cnZlV29ya2VycykKKyAgICAgICAgaWYgKCFwcmVzZXJ2ZUl0ZW1zKSB7CisgICAgICAgICAgICB0
aGlzLnNpZGViYXJQYW5lcy5icmVha3BvaW50cy5yZXNldCgpOwogICAgICAgICAgICAgdGhpcy5z
aWRlYmFyUGFuZXMud29ya2Vycy5yZXNldCgpOworICAgICAgICB9CiAgICAgfSwKIAogICAgIGdl
dCB2aXNpYmxlVmlldygpCg==
</data>
<flag name="review"
          id="40357"
          type_id="1"
          status="+"
          setter="timothy"
    />
          </attachment>
      

    </bug>

</bugzilla>