Diff
Modified: trunk/Source/WebCore/ChangeLog (142745 => 142746)
--- trunk/Source/WebCore/ChangeLog 2013-02-13 15:25:00 UTC (rev 142745)
+++ trunk/Source/WebCore/ChangeLog 2013-02-13 15:27:48 UTC (rev 142746)
@@ -1,3 +1,43 @@
+2013-02-13 Yury Semikhatsky <[email protected]>
+
+ Web Inspector: add experimental native heap graph to Timeline panel
+ https://bugs.webkit.org/show_bug.cgi?id=109687
+
+ Reviewed by Alexander Pavlov.
+
+ Added experimentatl support for native heap graph on the Timeline panel.
+ Native memory usage data is collected after each top level task and can
+ be displayed instead of DOM counters graph on the Timeline panel if
+ corresponding experiment is enabled in the inspector settings.
+
+ * inspector/Inspector.json:
+ * inspector/InspectorController.cpp:
+ (WebCore::InspectorController::InspectorController):
+ * inspector/InspectorTimelineAgent.cpp:
+ (TimelineAgentState):
+ (WebCore::InspectorTimelineAgent::setIncludeDomCounters):
+ (WebCore):
+ (WebCore::InspectorTimelineAgent::setIncludeNativeMemoryStatistics):
+ (WebCore::InspectorTimelineAgent::innerAddRecordToTimeline):
+ (WebCore::InspectorTimelineAgent::setDOMCounters):
+ (WebCore::InspectorTimelineAgent::setNativeHeapStatistics):
+ (WebCore::InspectorTimelineAgent::InspectorTimelineAgent):
+ * inspector/InspectorTimelineAgent.h:
+ (WebCore):
+ (WebCore::InspectorTimelineAgent::create):
+ (InspectorTimelineAgent):
+ * inspector/WorkerInspectorController.cpp:
+ (WebCore::WorkerInspectorController::WorkerInspectorController):
+ * inspector/front-end/MemoryStatistics.js:
+ (WebInspector.MemoryStatistics):
+ * inspector/front-end/NativeMemoryGraph.js:
+ (WebInspector.NativeMemoryGraph):
+ (WebInspector.NativeMemoryGraph.prototype._onRecordAdded.addStatistics):
+ (WebInspector.NativeMemoryGraph.prototype._onRecordAdded):
+ * inspector/front-end/Settings.js:
+ (WebInspector.ExperimentsSettings):
+ * inspector/front-end/TimelinePanel.js:
+
2013-02-13 Vladislav Kaznacheev <[email protected]>
Web Inspector: Fixed colorpicker editing and scrolling.
Modified: trunk/Source/WebCore/inspector/Inspector.json (142745 => 142746)
--- trunk/Source/WebCore/inspector/Inspector.json 2013-02-13 15:25:00 UTC (rev 142745)
+++ trunk/Source/WebCore/inspector/Inspector.json 2013-02-13 15:27:48 UTC (rev 142746)
@@ -2621,14 +2621,22 @@
"description": "Stops capturing instrumentation events."
},
{
- "name": "setIncludeMemoryDetails",
+ "name": "setIncludeDomCounters",
"parameters": [
- { "name": "enabled", "type": "boolean", "description": "True to start collecting DOM counters." }
+ { "name": "enabled", "type": "boolean", "description": "Whether DOM counters data should be included into timeline events." }
],
"hidden": true,
- "description": "Starts calculating various DOM statistics and sending them as part of timeline events."
+ "description": "Controls if DOM counters should be send as part of timeline events."
},
{
+ "name": "setIncludeNativeMemoryStatistics",
+ "parameters": [
+ { "name": "enabled", "type": "boolean", "description": "Whether native memory usage statistics should be reported as part of timeline events." }
+ ],
+ "hidden": true,
+ "description": "Controls whether statistics on native memory usage is sent with timeline events."
+ },
+ {
"name": "supportsFrameInstrumentation",
"returns": [
{ "name": "result", "type": "boolean", "description": "True if timeline supports frame instrumentation." }
Modified: trunk/Source/WebCore/inspector/InspectorController.cpp (142745 => 142746)
--- trunk/Source/WebCore/inspector/InspectorController.cpp 2013-02-13 15:25:00 UTC (rev 142745)
+++ trunk/Source/WebCore/inspector/InspectorController.cpp 2013-02-13 15:27:48 UTC (rev 142746)
@@ -125,7 +125,7 @@
m_memoryAgent = memoryAgentPtr.get();
m_agents.append(memoryAgentPtr.release());
- m_agents.append(InspectorTimelineAgent::create(m_instrumentingAgents.get(), pageAgent, m_state.get(), InspectorTimelineAgent::PageInspector,
+ m_agents.append(InspectorTimelineAgent::create(m_instrumentingAgents.get(), pageAgent, m_memoryAgent, m_state.get(), InspectorTimelineAgent::PageInspector,
inspectorClient));
m_agents.append(InspectorApplicationCacheAgent::create(m_instrumentingAgents.get(), m_state.get(), pageAgent));
Modified: trunk/Source/WebCore/inspector/InspectorTimelineAgent.cpp (142745 => 142746)
--- trunk/Source/WebCore/inspector/InspectorTimelineAgent.cpp 2013-02-13 15:25:00 UTC (rev 142745)
+++ trunk/Source/WebCore/inspector/InspectorTimelineAgent.cpp 2013-02-13 15:27:48 UTC (rev 142746)
@@ -42,10 +42,12 @@
#include "InspectorCounters.h"
#include "InspectorFrontend.h"
#include "InspectorInstrumentation.h"
+#include "InspectorMemoryAgent.h"
#include "InspectorPageAgent.h"
#include "InspectorState.h"
#include "InstrumentingAgents.h"
#include "IntRect.h"
+#include "MemoryUsageSupport.h"
#include "RenderObject.h"
#include "RenderView.h"
#include "ResourceRequest.h"
@@ -59,7 +61,8 @@
namespace TimelineAgentState {
static const char timelineAgentEnabled[] = "timelineAgentEnabled";
static const char timelineMaxCallStackDepth[] = "timelineMaxCallStackDepth";
-static const char includeMemoryDetails[] = "includeMemoryDetails";
+static const char includeDomCounters[] = "includeDomCounters";
+static const char includeNativeMemoryStatistics[] = "includeNativeMemoryStatistics";
}
// Must be kept in sync with WebInspector.TimelineModel.RecordType in TimelineModel.js
@@ -187,11 +190,16 @@
m_state->setBoolean(TimelineAgentState::timelineAgentEnabled, false);
}
-void InspectorTimelineAgent::setIncludeMemoryDetails(ErrorString*, bool value)
+void InspectorTimelineAgent::setIncludeDomCounters(ErrorString*, bool value)
{
- m_state->setBoolean(TimelineAgentState::includeMemoryDetails, value);
+ m_state->setBoolean(TimelineAgentState::includeDomCounters, value);
}
+void InspectorTimelineAgent::setIncludeNativeMemoryStatistics(ErrorString*, bool value)
+{
+ m_state->setBoolean(TimelineAgentState::includeNativeMemoryStatistics, value);
+}
+
void InspectorTimelineAgent::canMonitorMainThread(ErrorString*, bool* result)
{
*result = m_client && m_client->canMonitorMainThread();
@@ -497,8 +505,10 @@
record->setString("type", type);
if (!frameId.isEmpty())
record->setString("frameId", frameId);
- if (type != program)
- setHeapSizeStatistics(record.get());
+ if (type == program)
+ setNativeHeapStatistics(record.get());
+ else
+ setDOMCounters(record.get());
if (m_recordStack.isEmpty()) {
// FIXME: runtimeCast is a hack. We do it because we can't build TimelineEvent directly now.
@@ -517,11 +527,11 @@
return info.usedJSHeapSize;
}
-void InspectorTimelineAgent::setHeapSizeStatistics(InspectorObject* record)
+void InspectorTimelineAgent::setDOMCounters(InspectorObject* record)
{
record->setNumber("usedHeapSize", getUsedHeapSize());
- if (m_state->getBoolean(TimelineAgentState::includeMemoryDetails)) {
+ if (m_state->getBoolean(TimelineAgentState::includeDomCounters)) {
RefPtr<InspectorObject> counters = InspectorObject::create();
counters->setNumber("nodes", (m_inspectorType == PageInspector) ? InspectorCounters::counterValue(InspectorCounters::NodeCounter) : 0);
counters->setNumber("documents", (m_inspectorType == PageInspector) ? InspectorCounters::counterValue(InspectorCounters::DocumentCounter) : 0);
@@ -530,6 +540,24 @@
}
}
+void InspectorTimelineAgent::setNativeHeapStatistics(InspectorObject* record)
+{
+ if (!m_memoryAgent)
+ return;
+ if (!m_state->getBoolean(TimelineAgentState::includeNativeMemoryStatistics))
+ return;
+ HashMap<String, size_t> map;
+ m_memoryAgent->getProcessMemoryDistributionMap(&map);
+ RefPtr<InspectorObject> stats = InspectorObject::create();
+ for (HashMap<String, size_t>::iterator it = map.begin(); it != map.end(); ++it)
+ stats->setNumber(it->key, it->value);
+ size_t privateBytes = 0;
+ size_t sharedBytes = 0;
+ MemoryUsageSupport::processMemorySizesInBytes(&privateBytes, &sharedBytes);
+ stats->setNumber("PrivateBytes", privateBytes);
+ record->setObject("nativeHeapStatistics", stats.release());
+}
+
void InspectorTimelineAgent::didCompleteCurrentRecord(const String& type)
{
// An empty stack could merely mean that the timeline agent was turned on in the middle of
@@ -554,9 +582,10 @@
}
}
-InspectorTimelineAgent::InspectorTimelineAgent(InstrumentingAgents* instrumentingAgents, InspectorPageAgent* pageAgent, InspectorCompositeState* state, InspectorType type, InspectorClient* client)
+InspectorTimelineAgent::InspectorTimelineAgent(InstrumentingAgents* instrumentingAgents, InspectorPageAgent* pageAgent, InspectorMemoryAgent* memoryAgent, InspectorCompositeState* state, InspectorType type, InspectorClient* client)
: InspectorBaseAgent<InspectorTimelineAgent>("Timeline", instrumentingAgents, state)
, m_pageAgent(pageAgent)
+ , m_memoryAgent(memoryAgent)
, m_frontend(0)
, m_timestampOffset(0)
, m_id(1)
Modified: trunk/Source/WebCore/inspector/InspectorTimelineAgent.h (142745 => 142746)
--- trunk/Source/WebCore/inspector/InspectorTimelineAgent.h 2013-02-13 15:25:00 UTC (rev 142745)
+++ trunk/Source/WebCore/inspector/InspectorTimelineAgent.h 2013-02-13 15:27:48 UTC (rev 142746)
@@ -48,6 +48,7 @@
class Frame;
class InspectorClient;
class InspectorFrontend;
+class InspectorMemoryAgent;
class InspectorPageAgent;
class InspectorState;
class InstrumentingAgents;
@@ -67,9 +68,9 @@
public:
enum InspectorType { PageInspector, WorkerInspector };
- static PassOwnPtr<InspectorTimelineAgent> create(InstrumentingAgents* instrumentingAgents, InspectorPageAgent* pageAgent, InspectorCompositeState* state, InspectorType type, InspectorClient* client)
+ static PassOwnPtr<InspectorTimelineAgent> create(InstrumentingAgents* instrumentingAgents, InspectorPageAgent* pageAgent, InspectorMemoryAgent* memoryAgent, InspectorCompositeState* state, InspectorType type, InspectorClient* client)
{
- return adoptPtr(new InspectorTimelineAgent(instrumentingAgents, pageAgent, state, type, client));
+ return adoptPtr(new InspectorTimelineAgent(instrumentingAgents, pageAgent, memoryAgent, state, type, client));
}
~InspectorTimelineAgent();
@@ -80,7 +81,8 @@
virtual void start(ErrorString*, const int* maxCallStackDepth);
virtual void stop(ErrorString*);
- virtual void setIncludeMemoryDetails(ErrorString*, bool);
+ virtual void setIncludeDomCounters(ErrorString*, bool);
+ virtual void setIncludeNativeMemoryStatistics(ErrorString*, bool);
virtual void canMonitorMainThread(ErrorString*, bool*);
virtual void supportsFrameInstrumentation(ErrorString*, bool*);
@@ -179,10 +181,11 @@
size_t usedHeapSizeAtStart;
};
- InspectorTimelineAgent(InstrumentingAgents*, InspectorPageAgent*, InspectorCompositeState*, InspectorType, InspectorClient*);
+ InspectorTimelineAgent(InstrumentingAgents*, InspectorPageAgent*, InspectorMemoryAgent*, InspectorCompositeState*, InspectorType, InspectorClient*);
void pushCurrentRecord(PassRefPtr<InspectorObject>, const String& type, bool captureCallStack, Frame*, bool hasLowLevelDetails = false);
- void setHeapSizeStatistics(InspectorObject* record);
+ void setDOMCounters(InspectorObject* record);
+ void setNativeHeapStatistics(InspectorObject* record);
void didCompleteCurrentRecord(const String& type);
void commitFrameRecord();
@@ -197,6 +200,7 @@
double timestampFromMicroseconds(double microseconds);
InspectorPageAgent* m_pageAgent;
+ InspectorMemoryAgent* m_memoryAgent;
InspectorFrontend::Timeline* m_frontend;
double m_timestampOffset;
Modified: trunk/Source/WebCore/inspector/WorkerInspectorController.cpp (142745 => 142746)
--- trunk/Source/WebCore/inspector/WorkerInspectorController.cpp 2013-02-13 15:25:00 UTC (rev 142745)
+++ trunk/Source/WebCore/inspector/WorkerInspectorController.cpp 2013-02-13 15:27:48 UTC (rev 142746)
@@ -113,7 +113,7 @@
m_agents.append(InspectorProfilerAgent::create(m_instrumentingAgents.get(), consoleAgent.get(), workerContext, m_state.get(), m_injectedScriptManager.get()));
m_agents.append(InspectorHeapProfilerAgent::create(m_instrumentingAgents.get(), m_state.get(), m_injectedScriptManager.get()));
#endif
- m_agents.append(InspectorTimelineAgent::create(m_instrumentingAgents.get(), 0, m_state.get(), InspectorTimelineAgent::WorkerInspector, 0));
+ m_agents.append(InspectorTimelineAgent::create(m_instrumentingAgents.get(), 0, 0, m_state.get(), InspectorTimelineAgent::WorkerInspector, 0));
m_agents.append(consoleAgent.release());
m_injectedScriptManager->injectedScriptHost()->init(0
Modified: trunk/Source/WebCore/inspector/front-end/MemoryStatistics.js (142745 => 142746)
--- trunk/Source/WebCore/inspector/front-end/MemoryStatistics.js 2013-02-13 15:25:00 UTC (rev 142745)
+++ trunk/Source/WebCore/inspector/front-end/MemoryStatistics.js 2013-02-13 15:27:48 UTC (rev 142746)
@@ -68,7 +68,7 @@
this._memorySidebarView.sidebarElement.createChild("div", "sidebar-tree sidebar-tree-section").textContent = WebInspector.UIString("COUNTERS");
this._counterUI = this._createCounterUIList();
- TimelineAgent.setIncludeMemoryDetails(true);
+ TimelineAgent.setIncludeDomCounters(true);
}
/**
Modified: trunk/Source/WebCore/inspector/front-end/NativeMemoryGraph.js (142745 => 142746)
--- trunk/Source/WebCore/inspector/front-end/NativeMemoryGraph.js 2013-02-13 15:25:00 UTC (rev 142745)
+++ trunk/Source/WebCore/inspector/front-end/NativeMemoryGraph.js 2013-02-13 15:27:48 UTC (rev 142746)
@@ -38,6 +38,7 @@
WebInspector.NativeMemoryGraph = function(timelinePanel, model, sidebarWidth)
{
WebInspector.MemoryStatistics.call(this, timelinePanel, model, sidebarWidth);
+ TimelineAgent.setIncludeNativeMemoryStatistics(true);
}
/**
@@ -136,10 +137,7 @@
var statistics = this._counters;
function addStatistics(record)
{
- var counters = record["counters"];
- if (!counters)
- return;
- var nativeCounters = counters["native"];
+ var nativeCounters = record["nativeHeapStatistics"];
if (!nativeCounters)
return;
Modified: trunk/Source/WebCore/inspector/front-end/Settings.js (142745 => 142746)
--- trunk/Source/WebCore/inspector/front-end/Settings.js 2013-02-13 15:25:00 UTC (rev 142745)
+++ trunk/Source/WebCore/inspector/front-end/Settings.js 2013-02-13 15:27:48 UTC (rev 142746)
@@ -204,6 +204,7 @@
this.snippetsSupport = this._createExperiment("snippetsSupport", "Snippets support");
this.nativeMemorySnapshots = this._createExperiment("nativeMemorySnapshots", "Native memory profiling");
this.liveNativeMemoryChart = this._createExperiment("liveNativeMemoryChart", "Live native memory chart");
+ this.nativeMemoryTimeline = this._createExperiment("nativeMemoryTimeline", "Native memory timeline");
this.fileSystemInspection = this._createExperiment("fileSystemInspection", "FileSystem inspection");
this.canvasInspection = this._createExperiment("canvasInspection ", "Canvas inspection");
this.sass = this._createExperiment("sass", "Support for Sass");
Modified: trunk/Source/WebCore/inspector/front-end/TimelinePanel.js (142745 => 142746)
--- trunk/Source/WebCore/inspector/front-end/TimelinePanel.js 2013-02-13 15:25:00 UTC (rev 142745)
+++ trunk/Source/WebCore/inspector/front-end/TimelinePanel.js 2013-02-13 15:27:48 UTC (rev 142746)
@@ -76,7 +76,10 @@
this._timelineMemorySplitter.id = "timeline-memory-splitter";
WebInspector.installDragHandle(this._timelineMemorySplitter, this._startSplitterDragging.bind(this), this._splitterDragging.bind(this), this._endSplitterDragging.bind(this), "ns-resize");
this._timelineMemorySplitter.addStyleClass("hidden");
- this._memoryStatistics = new WebInspector.MemoryStatistics(this, this._model, this.splitView.sidebarWidth());
+ if (WebInspector.experimentsSettings.nativeMemoryTimeline.isEnabled())
+ this._memoryStatistics = new WebInspector.NativeMemoryGraph(this, this._model, this.splitView.sidebarWidth());
+ else
+ this._memoryStatistics = new WebInspector.MemoryStatistics(this, this._model, this.splitView.sidebarWidth());
WebInspector.settings.memoryCounterGraphsHeight = WebInspector.settings.createSetting("memoryCounterGraphsHeight", 150);
var itemsTreeElement = new WebInspector.SidebarSectionTreeElement(WebInspector.UIString("RECORDS"), {}, true);