Bug 117755

Summary: Web Inspector: Infrequent uncaught exception with debugger popovers breaks inspector
Product: WebKit Reporter: Joseph Pecoraro <joepeck>
Component: Web InspectorAssignee: Joseph Pecoraro <joepeck>
Status: RESOLVED FIXED    
Severity: Normal CC: commit-queue, graouts, joepeck, timothy, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: 528+ (Nightly build)   
Hardware: All   
OS: All   
Attachments:
Description Flags
[PATCH] Proposed Fix none

Description Joseph Pecoraro 2013-06-18 14:23:43 PDT
I've been able to somewhat reliably reproduce an uncaught exception with debugger popovers:

    [Error] TypeError: 'undefined' is not a function (evaluating 'bestFrame.minX()')
	_update (Popover.js, line 228)
	present (Popover.js, line 117)
	_showPopover (SourceCodeTextEditor.js, line 982)
	_showPopoverForUndefined (SourceCodeTextEditor.js, line 1089)
	populate (SourceCodeTextEditor.js, line 952)
	populate
	dispatch (InspectorBackend.js, line 209)
	dispatchNextQueuedMessageFromBackend (Main.js, line 290)
	(anonymous function)

I threw in some logging and caught what was happening:

    // Logging: console.log("FRAME", JSON.stringify(bestFrame), typeof bestFrame.minX);
    [Log] FRAME {"origin":{"x":427,"y":235},"size":{"width":83,"height":51}} function (Popover.js, line 229, x3)
    [Log] FRAME {"origin":{"x":427,"y":67},"size":{"width":83,"height":51}} function (Popover.js, line 229, x10)
    [Log] FRAME {"origin":{"x":0,"y":0},"size":{"width":0,"height":0}} undefined (Popover.js, line 229)
    // ERROR

Because WebInspector.Rect.ZERO_RECT was constructed before we replace the WebInspector.Rect.prototype it didn't get the methods we expected it to have!

    js> WebInspector.Rect.ZERO_RECT instanceof WebInspector.Rect
    false
Comment 1 Radar WebKit Bug Importer 2013-06-18 14:24:24 PDT
<rdar://problem/14194615>
Comment 2 Joseph Pecoraro 2013-06-18 14:26:52 PDT
Doing a quick search through the code base, ZERO_SIZE and ZERO_RECT were the only 2 objects being initialized before we reassigned the prototype. There were only a few other objects, all safe.

    shell> ack '^WebInsp.*?= new'
    Geometry.js
    87:WebInspector.Size.ZERO_SIZE = new WebInspector.Size(0, 0);
    178:WebInspector.Rect.ZERO_RECT = new WebInspector.Rect(0, 0, 0, 0);

    Object.js
    235:WebInspector.notifications = new WebInspector.Object;

    Popover.js
    56:WebInspector.Popover.AnchorSize = new WebInspector.Size(22, 11);
    57:WebInspector.Popover.ShadowEdgeInsets = new WebInspector.EdgeInsets(WebInspector.Popover.ShadowPadding);
Comment 3 Radar WebKit Bug Importer 2013-06-18 14:27:16 PDT
<rdar://problem/14194674>
Comment 4 Joseph Pecoraro 2013-06-18 14:28:10 PDT
Also the only non-WebInspector namespaced object (InspectorBackend) was correct.
Comment 5 Joseph Pecoraro 2013-06-18 15:23:53 PDT
Created attachment 204948 [details]
[PATCH] Proposed Fix
Comment 6 WebKit Commit Bot 2013-06-18 15:44:46 PDT
Comment on attachment 204948 [details]
[PATCH] Proposed Fix

Clearing flags on attachment: 204948

Committed r151704: <http://trac.webkit.org/changeset/151704>
Comment 7 WebKit Commit Bot 2013-06-18 15:44:48 PDT
All reviewed patches have been landed.  Closing bug.