Title: [134926] trunk/Source/WebCore
Revision
134926
Author
commit-qu...@webkit.org
Date
2012-11-16 03:35:19 -0800 (Fri, 16 Nov 2012)

Log Message

Web Inspector: Memory Timeline Crash
https://bugs.webkit.org/show_bug.cgi?id=102390

Patch by Eugene Klyuchnikov <eustas....@gmail.com> on 2012-11-16
Reviewed by Vsevolod Vlasov.

Crash seems to be caused by IPC overflow.
Messages "ParsedScriptSource" are routed to
ResourceScriptMapping.prototype.addScript that process them in time
linear to number of already registered non-anonymous non-inline scripts.

Fixed this with replacing repreated filtering with "on-line" bucketing.

* inspector/front-end/ResourceScriptMapping.js:
(WebInspector.ResourceScriptMapping):
Removed duplicating initialization code.
(WebInspector.ResourceScriptMapping.prototype.addScript):
Added script bucketing by sourceURL/isInline parameters.
(WebInspector.ResourceScriptMapping.prototype._scriptsForSourceURL):
Avoid filterfig.
(WebInspector.ResourceScriptMapping.prototype._createUISourceCode):
Added outgoing muatable array safeguard.
(WebInspector.ResourceScriptMapping.prototype._reset):
Added type information and added two new maps.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (134925 => 134926)


--- trunk/Source/WebCore/ChangeLog	2012-11-16 11:30:23 UTC (rev 134925)
+++ trunk/Source/WebCore/ChangeLog	2012-11-16 11:35:19 UTC (rev 134926)
@@ -1,3 +1,29 @@
+2012-11-16  Eugene Klyuchnikov  <eustas....@gmail.com>
+
+        Web Inspector: Memory Timeline Crash
+        https://bugs.webkit.org/show_bug.cgi?id=102390
+
+        Reviewed by Vsevolod Vlasov.
+
+        Crash seems to be caused by IPC overflow.
+        Messages "ParsedScriptSource" are routed to
+        ResourceScriptMapping.prototype.addScript that process them in time
+        linear to number of already registered non-anonymous non-inline scripts.
+
+        Fixed this with replacing repreated filtering with "on-line" bucketing.
+
+        * inspector/front-end/ResourceScriptMapping.js:
+        (WebInspector.ResourceScriptMapping):
+        Removed duplicating initialization code.
+        (WebInspector.ResourceScriptMapping.prototype.addScript):
+        Added script bucketing by sourceURL/isInline parameters.
+        (WebInspector.ResourceScriptMapping.prototype._scriptsForSourceURL):
+        Avoid filterfig.
+        (WebInspector.ResourceScriptMapping.prototype._createUISourceCode):
+        Added outgoing muatable array safeguard.
+        (WebInspector.ResourceScriptMapping.prototype._reset):
+        Added type information and added two new maps.
+
 2012-11-16  Helder Correia  <helder.corr...@nokia.com>
 
         [CoordGfx] Follow coding style on explicit constructors

Modified: trunk/Source/WebCore/inspector/front-end/ResourceScriptMapping.js (134925 => 134926)


--- trunk/Source/WebCore/inspector/front-end/ResourceScriptMapping.js	2012-11-16 11:30:23 UTC (rev 134925)
+++ trunk/Source/WebCore/inspector/front-end/ResourceScriptMapping.js	2012-11-16 11:35:19 UTC (rev 134926)
@@ -39,14 +39,7 @@
     this._workspace.addEventListener(WebInspector.Workspace.Events.ProjectWillReset, this._reset, this);
     this._workspace.addEventListener(WebInspector.UISourceCodeProvider.Events.UISourceCodeAdded, this._uiSourceCodeAddedToWorkspace, this);
 
-    /** @type {Object.<string, WebInspector.UISourceCode>} */
-    this._temporaryUISourceCodeForScriptId = {};
-    this._scriptIdsForTemporaryUISourceCode = new Map();
-    /** @type {Object.<string, WebInspector.UISourceCode>} */
-    this._originalUISourceCodeForScriptId = {};
-    this._scriptIdsForOriginalUISourceCode = new Map();
-
-    this._scripts = [];
+    this._reset();
 }
 
 WebInspector.ResourceScriptMapping.prototype = {
@@ -119,8 +112,14 @@
      */
     addScript: function(script)
     {
-        if (!script.isAnonymousScript())
+        if (!script.isAnonymousScript()) {
             this._scripts.push(script);
+            var scriptsForSourceURL = script.isInlineScript() ? this._inlineScriptsForSourceURL : this._nonInlineScriptsForSourceURL;
+            var bucket = scriptsForSourceURL[script.sourceURL] || [];
+            scriptsForSourceURL[script.sourceURL] = bucket;
+            bucket.push(script);
+        }
+
         script.setSourceMapping(this);
         var uiSourceCode = this._workspaceUISourceCodeForScript(script);
         if (uiSourceCode) {
@@ -132,7 +131,7 @@
 
         if (this._deleteTemporaryUISourceCodeForScripts(scripts)) {
             this._deleteOriginalUISourceCodeForScripts(scripts);
-            uiSourceCode = this._getOrCreateTemporaryUISourceCode(script);
+            this._getOrCreateTemporaryUISourceCode(script);
         }
     },
 
@@ -201,16 +200,12 @@
     /**
      * @param {string} sourceURL
      * @param {boolean} isInlineScript
-     * @return {Array.<WebInspector.Script>}
+     * @return {!Array.<!WebInspector.Script>}
      */
     _scriptsForSourceURL: function(sourceURL, isInlineScript)
     {
-        function filter(script)
-        {
-            return script.sourceURL === sourceURL && script.isInlineScript() === isInlineScript;
-        }
-
-        return this._scripts.filter(filter.bind(this));
+        var scriptsForSourceURL = isInlineScript ? this._inlineScriptsForSourceURL : this._nonInlineScriptsForSourceURL;
+        return scriptsForSourceURL[sourceURL] || [];
     },
 
     /**
@@ -221,7 +216,7 @@
     _createUISourceCode: function(scripts, divergedVersion)
     {
         var script = scripts[0];
-        var contentProvider = script.isInlineScript() ? new WebInspector.ConcatenatedScriptsContentProvider(scripts) : script;
+        var contentProvider = script.isInlineScript() ? new WebInspector.ConcatenatedScriptsContentProvider(scripts.slice()) : script;
         var isDynamicScript = this._isDynamicScript(script);
         var url = "" ? "" : script.sourceURL;
         var temporaryUISourceCode = this._workspace.addTemporaryUISourceCode(url, contentProvider, !script.isInlineScript() && !divergedVersion, script.isContentScript);
@@ -314,10 +309,16 @@
 
     _reset: function()
     {
+        /** @type {Object.<string, WebInspector.UISourceCode>} */
         this._temporaryUISourceCodeForScriptId = {};
         this._scriptIdsForTemporaryUISourceCode = new Map();
+        /** @type {Object.<string, WebInspector.UISourceCode>} */
         this._originalUISourceCodeForScriptId = {};
         this._scriptIdsForOriginalUISourceCode = new Map();
+        /** @type {!Object.<string, !Array.<!WebInspector.UISourceCode>>} */
+        this._inlineScriptsForSourceURL = {};
+        /** @type {!Object.<string, !Array.<!WebInspector.UISourceCode>>} */
+        this._nonInlineScriptsForSourceURL = {};
         this._scripts = [];
     },
 }
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to