Bug 30659 - Web Inspector: Leftover Breakpoints in the Sidebar Pane
Summary: Web Inspector: Leftover Breakpoints in the Sidebar Pane
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Inspector (Deprecated) (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-10-21 20:02 PDT by Joseph Pecoraro
Modified: 2009-11-04 14:22 PST (History)
8 users (show)

See Also:


Attachments
[IMAGE] Orphaned Breakpoints in Sidebar (93.20 KB, image/png)
2009-10-21 20:02 PDT, Joseph Pecoraro
no flags Details
proposed patch 2009/11/04 - a (1.59 KB, patch)
2009-11-04 14:10 PST, Patrick Mueller
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Joseph Pecoraro 2009-10-21 20:02:36 PDT
Created attachment 41631 [details]
[IMAGE] Orphaned Breakpoints in Sidebar

I came across this situation where a Breakpoint shows up in the Sidebar, but there is no Tag in the UI.  There appears to be no way to remove this sidebar entry.  It is reproducible, and thus you can have many garbage breakpoints.  I don't know if its just the UI or if there are really orphaned breakpoints somewhere else.

Steps to Reproduce:
1. Open the inspector on a page
2. Add a breakpoint to a line (it can be in either active/disabled states)
3. Refresh the page in the background
4. Go back to the Inspector
5. Remove the breakpoint by clicking the tag enough times

Current Behavior:
The sidebar entry remains but is in an unusable state.  Checking/Unchecking does nothing. It does not jump to the source code when clicked.

Expected Behavior:
When the breakpoint was removed the sidebar entry should have been removed. (In Step 5)
Comment 1 Joseph Pecoraro 2009-10-21 20:05:23 PDT
The Breakpoints Sidebar was added in:
http://trac.webkit.org/changeset/46402
Comment 2 Patrick Mueller 2009-11-02 21:17:35 PST
I have a fix for this that I haven't fully investigated yet.  In ScriptsPanel.addScript(), I changed the logic to not just update the sourceID for existing breakpoints, but to delete the old ones, and add new ones.  Code now looks like this:

        if (sourceURL in this._breakpointsURLMap && sourceID) {
            var breakpoints = this._breakpointsURLMap[sourceURL];
            var breakpointsLength = breakpoints.length;
            for (var i = 0; i < breakpointsLength; ++i) {
                var breakpoint = breakpoints[i];
                var enabled = breakpoint.enabled;
                this.removeBreakpoint(breakpoint);
                
                if (startingLine <= breakpoint.line) {
                    breakpoint = new WebInspector.Breakpoint(breakpoint.url, breakpoint.line, sourceID, breakpoint.condition);
                    this.addBreakpoint(breakpoint);
                    breakpoint.enabled = enabled;
                }
            }
        }

Fixes the problem for me.

Looking at the code, it appears there are bits of breakpoint goop all over the place; it would be nice to have this a little more centralized, somehow.  I would have expected most of the breakpoint logic to actually be in BreakPoint.js, but in fact that class pretty much just handles breakpoint state, and none of the interesting behavior.
Comment 3 Patrick Mueller 2009-11-04 14:10:39 PST
Created attachment 42520 [details]
proposed patch 2009/11/04 - a

The problem is that the sidebar wasn't being cleaned up - still pointed to the sourceID of the original script (sourceIDs for script change on reload).

Easiest thing to do is to call ScriptPanel's removeBreakpoint() on the old one, change the sourceID of the breakpoint to the new sourceID, then call addBreakpoint().   It's a bit overkill, as I >think< all that really needs to be done is to change the sidebar's sourceID.  But that's a bit reach-y.  And untested.

As I mentioned in a previous comment, I think a lot of this breakpoint stuff can be consolidated somehow; too much function spread over too many files.  This bug was an example of the problem of the spread.

I need to get reloading of breakpoint's in named eval()'s working (no simple fix for that).  Thinking a refactoring at that point might be appropriate.  Patching this one for now would be great because this is a bug a lot of people will hit.
Comment 4 Timothy Hatcher 2009-11-04 14:13:48 PST
Comment on attachment 42520 [details]
proposed patch 2009/11/04 - a

I agree, we should clean up this breakpoint logic and get more of it shared and in a nice state.
Comment 5 WebKit Commit Bot 2009-11-04 14:22:07 PST
Comment on attachment 42520 [details]
proposed patch 2009/11/04 - a

Clearing flags on attachment: 42520

Committed r50529: <http://trac.webkit.org/changeset/50529>
Comment 6 WebKit Commit Bot 2009-11-04 14:22:18 PST
All reviewed patches have been landed.  Closing bug.