Bug 144309 - Web Inspector: Exception under ObjectTreeView.js on specific code.tutsplus.com page
Summary: Web Inspector: Exception under ObjectTreeView.js on specific code.tutsplus.co...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Inspector (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: Joseph Pecoraro
URL: http://code.tutsplus.com/tutorials/sa...
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2015-04-27 19:51 PDT by Timothy Hatcher
Modified: 2015-07-30 11:44 PDT (History)
8 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Timothy Hatcher 2015-04-27 19:51:03 PDT
Load http://code.tutsplus.com/tutorials/say-hello-to-webkit-filters--net-23318 with the Inspector open. Didn't do anything special.

TypeError: null is not an object (evaluating 'a.match(chunk)')
comparePropertyDescriptors@file:///Users/Timothy/Work/Safari-TOT.git/OpenSource/WebKitBuild/Release/WebInspectorUI.framework/Resources/Views/ObjectTreeView.js:134:29
sort@[native code]
_updateProperties@file:///Users/Timothy/Work/Safari-TOT.git/OpenSource/WebKitBuild/Release/WebInspectorUI.framework/Resources/Views/ObjectTreeView.js:287:24
_updateChildren@file:///Users/Timothy/Work/Safari-TOT.git/OpenSource/WebKitBuild/Release/WebInspectorUI.framework/Resources/Views/ObjectTreeView.js:257:21
_updateChildren@[native code]
_getPropertyDescriptorsResolver@file:///Users/Timothy/Work/Safari-TOT.git/OpenSource/WebKitBuild/Release/WebInspectorUI.framework/Resources/Protocol/RemoteObject.js:510:17
_getPropertyDescriptorsResolver@[native code]
_dispatchCallback@file:///Users/Timothy/Work/Safari-TOT.git/OpenSource/WebKitBuild/Release/WebInspectorUI.framework/Resources/Protocol/InspectorBackend.js:181:31
dispatch@file:///Users/Timothy/Work/Safari-TOT.git/OpenSource/WebKitBuild/Release/WebInspectorUI.framework/Resources/Protocol/InspectorBackend.js:86:35
dispatchNextQueuedMessageFromBackend@file:///Users/Timothy/Work/Safari-TOT.git/OpenSource/WebKitBuild/Release/WebInspectorUI.framework/Resources/Protocol/MessageDispatcher.js:42:34
file:///Users/Timothy/Work/Safari-TOT.git/OpenSource/WebKitBuild/Release/WebInspectorUI.framework/Resources/Controllers/FormatterContentBuilder.js:156:23: CONSOLE ERROR
Comment 1 Radar WebKit Bug Importer 2015-04-27 19:51:37 PDT
<rdar://problem/20721693>
Comment 2 Joseph Pecoraro 2015-04-27 20:34:54 PDT
I don't understand how this is possible.

Here is the code, annotated with some comments.

        ...

        // By this point, a and b should be strings. If they aren't something else went wrong in surrounding code.

        // 1. Rule out equivalent names.
        if (a === b)
            return 0;

        while (diff === 0) {

            // 2. Rule out one being shorter then the other.
            if (!a && b)
                return -1;
            if (!b && a)
                return 1;

            chunka = a.match(chunk)[0];
            chunkb = b.match(chunk)[0];
            anum = !isNaN(chunka);
            bnum = !isNaN(chunkb);

            // 3. Number versus non number cases.
            if (anum && !bnum)
                return -1;
            if (bnum && !anum)
                return 1;

            // 4. Number differences, if the same we continue.
            if (anum && bnum) {
                diff = chunka - chunkb;
                if (diff === 0 && chunka.length !== chunkb.length) {
                    if (!+chunka && !+chunkb) // chunks are strings of all 0s (special case)
                        return chunka.length - chunkb.length;
                    else
                        return chunkb.length - chunka.length;
                }
            }
            
            // 5. Different strings
            else if (chunka !== chunkb)
                return (chunka < chunkb) ? -1 : 1;

            // 6. Proceed to the next part of the string.
            a = a.substring(chunka.length);
            b = b.substring(chunkb.length);

        }

        ...


For us to have encountered a.match(chunk) and have "a" be null then, I think something must have gone wrong.

I believe Geoff just re-wrote Array.prototype.sort, so maybe that is related?
Comment 3 Joseph Pecoraro 2015-04-27 20:37:48 PDT
Tim, it looks like Geoff's sort changes (r183288) got rolled out a bit later (r183308). My ToT (r183442) was not encountering the issue. Do you know what r### your JavaScriptCore was?
Comment 4 Timothy Hatcher 2015-04-28 09:50:10 PDT
I had Geoff's change at the time. Rebuilding to see if it is better.
Comment 5 Timothy Hatcher 2015-04-28 12:15:01 PDT
Looks fine now.
Comment 6 Geoffrey Garen 2015-04-29 16:55:26 PDT
I see this in TOT, and in 183568, just before the Array.prototype.sort patch re-landed: 

Uncaught exception in inspector page while handling event Network.responseReceived:  (2)
TypeError: undefined is not an object (evaluating 'b.resource.type')
"compareResourceTreeElements@Main.js:6957:63
compareFolderAndResourceTreeElements@Main.js:6968:114
value@Main.js:516:107
insertionIndexForObjectInListSortedByFunction@Main.js:535:96
descendantResourceTreeElementTypeDidChange@Main.js:6825:240
callFirstAncestorFunction@Main.js:6238:130
_typeDidChange@Main.js:6992:112
dispatch@Main.js:100:158
dispatchEventToListeners@Main.js:102:9
updateForResponse@Main.js:3576:30
resourceRequestDidReceiveResponse@Main.js:14444:51
responseReceived@Main.js:797:69
dispatchEvent@Main.js:723:34
_dispatchEvent@Main.js:687:55
dispatch@Main.js:651:20
dispatchNextQueuedMessageFromBackend@Main.js:786:32"
_dispatchEventMain.js:687:105
dispatchMain.js:651
dispatchNextQueuedMessageFromBackend
Comment 7 Timothy Hatcher 2015-05-01 07:49:54 PDT
Geoff, was that loading the same page linked above?
Comment 8 Geoffrey Garen 2015-05-01 11:41:51 PDT
(In reply to comment #7)
> Geoff, was that loading the same page linked above?

Yeah, same page.
Comment 9 Timothy Hatcher 2015-07-30 11:44:52 PDT
Seems to be fine.(In reply to comment #8)
> (In reply to comment #7)
> > Geoff, was that loading the same page linked above?
> 
> Yeah, same page.

Filed new bug about that. Bug 147451.