Commit e508ef60 authored by commit-queue@webkit.org's avatar commit-queue@webkit.org
Browse files

Web Inspector: Profiles: taking heap snapshot causes error message in console.

https://bugs.webkit.org/show_bug.cgi?id=97890

Patch by Eugene Klyuchnikov <eustas.bug@gmail.com> on 2012-10-03
Reviewed by Yury Semikhatsky.

Actual problem is that proxy loader is closed twice.

"_snapshotReceived" should never try to close receiver,
because it is a callback fired by close.

Also minor glitches fixed:
 - taking snapshot shows "Loading..." status first,
and then "Saving xxx%";
 - after all chunks are sent "Parsing" status is set and
then is replaced with "Saving 100%";
 - removed dead code in proxy;
 - proxy was ignoring callback parameter;
 - "Loading %d\%" is not localized.

* English.lproj/localizedStrings.js: Added missing "Loading %d%" string.
* inspector/front-end/HeapSnapshotProxy.js: Removed dead code.
(WebInspector.HeapSnapshotLoaderProxy):
(WebInspector.HeapSnapshotLoaderProxy.prototype.write): Make this method
interface-conformant.
* inspector/front-end/HeapSnapshotView.js:
(WebInspector.HeapProfileHeader): Fixed update-status and
finish-transfer logic.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@130269 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 98c74958
2012-10-03 Eugene Klyuchnikov <eustas.bug@gmail.com>
Web Inspector: Profiles: taking heap snapshot causes error message in console.
https://bugs.webkit.org/show_bug.cgi?id=97890
Reviewed by Yury Semikhatsky.
Actual problem is that proxy loader is closed twice.
"_snapshotReceived" should never try to close receiver,
because it is a callback fired by close.
Also minor glitches fixed:
- taking snapshot shows "Loading..." status first,
and then "Saving xxx%";
- after all chunks are sent "Parsing" status is set and
then is replaced with "Saving 100%";
- removed dead code in proxy;
- proxy was ignoring callback parameter;
- "Loading %d\%" is not localized.
* English.lproj/localizedStrings.js: Added missing "Loading %d%" string.
* inspector/front-end/HeapSnapshotProxy.js: Removed dead code.
(WebInspector.HeapSnapshotLoaderProxy):
(WebInspector.HeapSnapshotLoaderProxy.prototype.write): Make this method
interface-conformant.
* inspector/front-end/HeapSnapshotView.js:
(WebInspector.HeapProfileHeader): Fixed update-status and
finish-transfer logic.
2012-10-03 Jochen Eisinger <jochen@chromium.org>
Make sure that user gestures can't be consumed twice
......
......@@ -705,6 +705,7 @@ localizedStrings["<Right>"] = "<Right>";
localizedStrings["<Up>"] = "<Up>";
localizedStrings["<Down>"] = "<Down>";
localizedStrings["Events"] = "Events";
localizedStrings["Loading\u2026 %d\%"] = "Loading\u2026 %d\%";
localizedStrings["Saving\u2026 %d\%"] = "Saving\u2026 %d\%";
localizedStrings["Only heap snapshots from files with extension '.whs' can be loaded."] = "Only heap snapshots from files with extension '.whs' can be loaded.";
localizedStrings["Can't load profile when other profile is recording."] = "Can't load profile when other profile is recording.";
......
......@@ -363,21 +363,10 @@ WebInspector.HeapSnapshotProxyObject.prototype = {
WebInspector.HeapSnapshotLoaderProxy = function(worker, objectId)
{
WebInspector.HeapSnapshotProxyObject.call(this, worker, objectId);
this._started = false;
this._pendingSnapshotConsumers = [];
}
WebInspector.HeapSnapshotLoaderProxy.prototype = {
startTransfer: function()
{
this._started = true;
},
isStarted: function()
{
return this._started;
},
/**
* @param {function(WebInspector.HeapSnapshotProxy)} callback
*/
......@@ -388,10 +377,11 @@ WebInspector.HeapSnapshotLoaderProxy.prototype = {
/**
* @param {string} chunk
* @param {function(WebInspector.OutputStream)=} callback
*/
write: function(chunk)
write: function(chunk, callback)
{
this.callMethod(null, "write", chunk);
this.callMethod(callback, "write", chunk);
},
close: function()
......@@ -409,8 +399,6 @@ WebInspector.HeapSnapshotLoaderProxy.prototype = {
{
for (var i = 0; i < this._pendingSnapshotConsumers.length; ++i)
this._pendingSnapshotConsumers[i](snapshotProxy);
this._started = false;
this._pendingSnapshotConsumers = [];
}
this.callMethod(buildSnapshot.bind(this), "close");
......
......@@ -813,7 +813,7 @@ WebInspector.HeapProfileHeader = function(type, title, uid, maxJSObjectId)
WebInspector.ProfileHeader.call(this, type, title, uid);
this.maxJSObjectId = maxJSObjectId;
/**
* @type {WebInspector.FileOutputStream}
* @type {WebInspector.OutputStream}
*/
this._receiver = null;
/**
......@@ -858,6 +858,8 @@ WebInspector.HeapProfileHeader.prototype = {
}
this._numberOfChunks = 0;
this._savedChunks = 0;
this._savingToFile = false;
if (!this._receiver) {
this._setupWorker();
this.sidebarElement.subtitle = WebInspector.UIString("Loading\u2026");
......@@ -890,15 +892,22 @@ WebInspector.HeapProfileHeader.prototype = {
},
/**
* @param {number} savedChunksCount
* @param {number} value
* @param {number} maxValue
*/
_saveStatusUpdate: function(savedChunksCount)
_updateTransferProgress: function(value, maxValue)
{
if (savedChunksCount === this._totalNumberOfChunks) {
this.sidebarElement.subtitle = Number.bytesToString(this._snapshotProxy.totalSize);
this.sidebarElement.wait = false;
} else
this.sidebarElement.subtitle = WebInspector.UIString("Saving\u2026 %d\%", (savedChunksCount * 100 / this._totalNumberOfChunks).toFixed(2));
var percentValue = ((maxValue ? (value / maxValue) : 0) * 100).toFixed(2);
if (this._savingToFile)
this.sidebarElement.subtitle = WebInspector.UIString("Saving\u2026 %d\%", percentValue);
else
this.sidebarElement.subtitle = WebInspector.UIString("Loading\u2026 %d\%", percentValue);
},
_updateSnapshotStatus: function()
{
this.sidebarElement.subtitle = Number.bytesToString(this._snapshotProxy.totalSize);
this.sidebarElement.wait = false;
},
/**
......@@ -910,31 +919,32 @@ WebInspector.HeapProfileHeader.prototype = {
this._receiver.write(chunk, callback.bind(this));
function callback()
{
this._saveStatusUpdate(++this._savedChunks);
if (this._totalNumberOfChunks === this._savedChunks)
this._snapshotReceived(null);
this._updateTransferProgress(++this._savedChunks, this._totalNumberOfChunks);
if (this._totalNumberOfChunks === this._savedChunks) {
if (this._savingToFile)
this._updateSnapshotStatus();
else
this.sidebarElement.subtitle = WebInspector.UIString("Parsing\u2026");
this._receiver.close();
}
}
},
_snapshotReceived: function(snapshotProxy)
{
this._receiver.close();
this._receiver = null;
if (snapshotProxy)
this._snapshotProxy = snapshotProxy;
this.sidebarElement.subtitle = Number.bytesToString(this._snapshotProxy.totalSize);
this.sidebarElement.wait = false;
this._updateSnapshotStatus();
var worker = /** @type {WebInspector.HeapSnapshotWorker} */ this._snapshotProxy.worker;
this.isTemporary = false;
worker.startCheckingForLongRunningCalls();
},
finishHeapSnapshot: function(transferFinished)
finishHeapSnapshot: function()
{
this._totalNumberOfChunks = this._numberOfChunks;
this.sidebarElement.subtitle = WebInspector.UIString("Parsing\u2026");
if (!transferFinished && this._receiver)
this._receiver.close();
},
/**
......@@ -955,9 +965,10 @@ WebInspector.HeapProfileHeader.prototype = {
function onOpen()
{
this._savedChunks = 0;
this._saveStatusUpdate(0);
this._updateTransferProgress(0, this._totalNumberOfChunks);
ProfilerAgent.getProfile(this.profileType().id, this.uid);
}
this._savingToFile = true;
this._fileName = this._fileName || "Heap-" + new Date().toISO8601Compact() + ".heapsnapshot";
this._receiver = new WebInspector.FileOutputStream();
this._receiver.open(this._fileName, onOpen.bind(this));
......@@ -982,6 +993,7 @@ WebInspector.HeapProfileHeader.prototype = {
this.sidebarElement.wait = true;
this._setupWorker();
this._numberOfChunks = 0;
this._savingToFile = false;
var delegate = new WebInspector.HeapSnapshotLoadFromFileDelegate(this);
var fileReader = this._createFileReader(file, delegate);
......@@ -1015,13 +1027,12 @@ WebInspector.HeapSnapshotLoadFromFileDelegate.prototype = {
*/
onChunkTransferred: function(reader)
{
this._snapshotHeader.sidebarElement.subtitle = WebInspector.UIString(
"Loading\u2026 %d%", (reader.loadedSize() * 100 / reader.fileSize()).toFixed(2));
this._snapshotHeader._updateTransferProgress(reader.loadedSize(), reader.fileSize());
},
onTransferFinished: function()
{
this._snapshotHeader.finishHeapSnapshot(true);
this._snapshotHeader.finishHeapSnapshot();
},
/**
......
......@@ -674,7 +674,7 @@ WebInspector.ProfilesPanel.prototype = {
var profile = this._profilesIdMap[this._makeKey(uid, WebInspector.HeapSnapshotProfileType.TypeId)];
if (!profile)
return;
profile.finishHeapSnapshot(false);
profile.finishHeapSnapshot();
},
/**
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment