Changeset 140332 in webkit


Ignore:
Timestamp:
Jan 21, 2013 7:30:26 AM (11 years ago)
Author:
yurys@chromium.org
Message:

Web Inspector: do not serialize native heap graph when collecting information about memory distribution
https://bugs.webkit.org/show_bug.cgi?id=107450

Reviewed by Pavel Feldman.

Native heap graph is not reported when we need to show only high-level memory distribution.

  • inspector/front-end/NativeMemorySnapshotView.js:

(WebInspector.NativeMemorySnapshotView):
(WebInspector.NativeMemoryProfileType.prototype.buttonClicked.didReceiveMemorySnapshot):
(WebInspector.NativeMemoryProfileType.prototype.buttonClicked):

Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r140331 r140332  
     12013-01-21  Yury Semikhatsky  <yurys@chromium.org>
     2
     3        Web Inspector: do not serialize native heap graph when collecting information about memory distribution
     4        https://bugs.webkit.org/show_bug.cgi?id=107450
     5
     6        Reviewed by Pavel Feldman.
     7
     8        Native heap graph is not reported when we need to show only high-level memory distribution.
     9
     10        * inspector/front-end/NativeMemorySnapshotView.js:
     11        (WebInspector.NativeMemorySnapshotView):
     12        (WebInspector.NativeMemoryProfileType.prototype.buttonClicked.didReceiveMemorySnapshot):
     13        (WebInspector.NativeMemoryProfileType.prototype.buttonClicked):
     14
    1152013-01-21  Alexander Pavlov  <apavlov@chromium.org>
    216
  • trunk/Source/WebCore/inspector/front-end/NativeMemorySnapshotView.js

    r138475 r140332  
    4242    this._containmentDataGrid = new WebInspector.NativeSnapshotDataGrid(profile);
    4343    this._containmentDataGrid.show(this.element);
    44 
    45     this._heapGraphDataGrid = new WebInspector.NativeHeapGraphDataGrid(profile._graph);
    46 
    47     this._viewSelectElement = document.createElement("select");
    48     this._viewSelectElement.className = "status-bar-item";
    49     this._viewSelectElement.addEventListener("change", this._onSelectedViewChanged.bind(this), false);
    50 
    51     this._views = [{title: "Aggregated", view: this._containmentDataGrid},
    52                   {title: "Graph", view: this._heapGraphDataGrid}];
    53     this._currentViewIndex = 0;
    54     for (var i = 0; i < this._views.length; ++i) {
    55         var view = this._views[i];
    56         var option = document.createElement("option");
    57         option.label = WebInspector.UIString(view.title);
    58         this._viewSelectElement.appendChild(option);
    59     }
    6044}
    6145
    6246WebInspector.NativeMemorySnapshotView.prototype = {
    63     _onSelectedViewChanged: function(event)
    64     {
    65         var index = event.target.selectedIndex;
    66         if (index === this._currentViewIndex)
    67             return;
    68 
    69         var currentView = this._views[this._currentViewIndex].view;
    70         currentView.detach();
    71 
    72         this._currentViewIndex = index;
    73         var selectedView = this._views[index].view;
    74         selectedView.show(this.element);
    75     },
    76 
    77     get statusBarItems()
    78     {
    79         var span = document.createElement("span");
    80         span.className = "status-bar-select-container";
    81         span.appendChild(this._viewSelectElement);
    82         return [span];
    83     },
    84 
    8547    __proto__: WebInspector.View.prototype
    8648}
    87 
    8849
    8950
     
    264225        for (var node in this._nodeData.children) {
    265226            var nodeData = this._nodeData.children[node];
    266             this._addChildrenFromGraph(nodeData);
    267227            if (WebInspector.settings.showNativeSnapshotUninstrumentedSize.get() || nodeData.name !== "Other")
    268228                this.appendChild(new WebInspector.NativeSnapshotNode(nodeData, this._rootMemoryBlock));
    269229        }
    270     },
    271 
    272     /**
    273      * @param {MemoryAgent.MemoryBlock} memoryBlock
    274      */
    275     _addChildrenFromGraph: function(memoryBlock)
    276     {
    277         if (memoryBlock.children)
    278             return;
    279         if (memoryBlock.name !== "Image" || this._nodeData.name !== "MemoryCache")
    280             return;
    281 
    282         // Collect objects on the path MemoryCache -> CachedImage -m_image-> BitmapImage -m_frames-> FrameData -m_frame-> SkBitmap -> SkPixelRef
    283         var graph = this.dataGrid._profile._graph;
    284         var roots = graph.root().referencedNodes();
    285         var memoryCache;
    286         for (var i = 0; i < roots.length; i++) {
    287             var root = roots[i];
    288             if (root.className() === "MemoryCache") {
    289                 memoryCache = root;
    290                 break;
    291             }
    292         }
    293         var edges = memoryCache.outgoingEdges();
    294         var cachedImages = [];
    295         for (var i = 0; i < edges.length; i++) {
    296             var target = edges[i].target();
    297             if (target.className() === "CachedImage") {
    298                 var cachedImage = {
    299                     name: target.name(),
    300                     size: target.size(),
    301                     children: []
    302                 };
    303                 cachedImages.push(cachedImage);
    304                 var image = target.targetOfEdge("m_image");
    305                 if (image.className() === "BitmapImage") {
    306                     var frames = image.targetsOfAllEdges("m_frame");
    307                     for (var j = 0; j < frames.length; j++) {
    308                         var pixels = frames[j].targetOfEdge("pixels");
    309                         if (pixels) {
    310                             cachedImage.size += pixels.size();
    311                             cachedImage.children.push({
    312                                 name: "Bitmap pixels",
    313                                 size: pixels.size()
    314                             });
    315                         }
    316                     }
    317                 }
    318             }
    319         }
    320         memoryBlock.children = cachedImages;
    321     },
    322 
    323     __proto__: WebInspector.DataGridNode.prototype
    324 }
    325 
    326 
    327 /**
    328  * @constructor
    329  * @extends {WebInspector.DataGrid}
    330  * @param {WebInspector.NativeHeapGraph} nativeHeapGraph
    331  */
    332 WebInspector.NativeHeapGraphDataGrid = function(nativeHeapGraph)
    333 {
    334     var columns = {
    335         id: { title: WebInspector.UIString("id"), width: "80px", disclosure: true, sortable: true },
    336         type: { title: WebInspector.UIString("Type"), width: "200px", sortable: true },
    337         className: { title: WebInspector.UIString("Class name"), width: "200px", sortable: true },
    338         name: { title: WebInspector.UIString("Name"), width: "200px", sortable: true },
    339         size: { title: WebInspector.UIString("Size"), sortable: true, sort: "descending" },
    340     };
    341     WebInspector.DataGrid.call(this, columns);
    342     this._nativeHeapGraph = nativeHeapGraph;
    343     this._root = new WebInspector.NativeHeapGraphDataGridRoot(this._nativeHeapGraph);
    344     this.setRootNode(this._root);
    345     this._root._populate();
    346 }
    347 
    348 WebInspector.NativeHeapGraphDataGrid.prototype = {
    349     __proto__: WebInspector.DataGrid.prototype
    350 }
    351 
    352 
    353 /**
    354  * @constructor
    355  * @extends {WebInspector.DataGridNode}
    356  * @param {WebInspector.NativeHeapGraph} graph
    357  */
    358 WebInspector.NativeHeapGraphDataGridRoot = function(graph)
    359 {
    360     WebInspector.DataGridNode.call(this, { id: "root" }, true);
    361     this._graph = graph;
    362     this.addEventListener("populate", this._populate, this);
    363 }
    364 
    365 WebInspector.NativeHeapGraphDataGridRoot.prototype = {
    366     _populate: function() {
    367         this.removeEventListener("populate", this._populate, this);
    368         var roots = this._graph.root().referencedNodes();
    369         for (var i = 0; i < roots.length; i++)
    370             this.appendChild(new WebInspector.NativeHeapGraphDataGridNode(roots[i]));
    371     },
    372 
    373     __proto__: WebInspector.DataGridNode.prototype
    374 }
    375 
    376 
    377 /**
    378  * @constructor
    379  * @extends {WebInspector.DataGridNode}
    380  * @param {WebInspector.NativeHeapGraph.Node} node
    381  */
    382 WebInspector.NativeHeapGraphDataGridNode = function(node)
    383 {
    384     var data = {
    385         id: node.id(),
    386         size: node.size(),
    387         type: node.type(),
    388         className: node.className(),
    389         name: node.name(),
    390     };
    391     WebInspector.DataGridNode.call(this, data, node.hasReferencedNodes());
    392     this._node = node;
    393     this.addEventListener("populate", this._populate, this);
    394 }
    395 
    396 WebInspector.NativeHeapGraphDataGridNode.prototype = {
    397     _populate: function() {
    398         this.removeEventListener("populate", this._populate, this);
    399         var children = this._node.referencedNodes();
    400         for (var i = 0; i < children.length; i++)
    401             this.appendChild(new WebInspector.NativeHeapGraphDataGridNode(children[i]));
    402230    },
    403231
     
    459287            }
    460288            profileHeader._memoryBlock = memoryBlock;
    461             profileHeader._graph = new WebInspector.NativeHeapGraph(graph);
    462289            profileHeader.isTemporary = false;
    463290            profileHeader.sidebarElement.subtitle = Number.bytesToString(/** @type{number} */(memoryBlock.size));
    464291        }
    465         MemoryAgent.getProcessMemoryDistribution(true, didReceiveMemorySnapshot.bind(this));
     292        MemoryAgent.getProcessMemoryDistribution(false, didReceiveMemorySnapshot.bind(this));
    466293        return false;
    467294    },
Note: See TracChangeset for help on using the changeset viewer.