- Revision
- 130269
- Author
- [email protected]
- Date
- 2012-10-03 02:50:06 -0700 (Wed, 03 Oct 2012)
Log Message
Web Inspector: Profiles: taking heap snapshot causes error message in console.
https://bugs.webkit.org/show_bug.cgi?id=97890
Patch by Eugene Klyuchnikov <[email protected]> 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.
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (130268 => 130269)
--- trunk/Source/WebCore/ChangeLog 2012-10-03 09:48:40 UTC (rev 130268)
+++ trunk/Source/WebCore/ChangeLog 2012-10-03 09:50:06 UTC (rev 130269)
@@ -1,3 +1,33 @@
+2012-10-03 Eugene Klyuchnikov <[email protected]>
+
+ 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 <[email protected]>
Make sure that user gestures can't be consumed twice
Modified: trunk/Source/WebCore/English.lproj/localizedStrings.js (130268 => 130269)
--- trunk/Source/WebCore/English.lproj/localizedStrings.js 2012-10-03 09:48:40 UTC (rev 130268)
+++ trunk/Source/WebCore/English.lproj/localizedStrings.js 2012-10-03 09:50:06 UTC (rev 130269)
@@ -705,6 +705,7 @@
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.";
Modified: trunk/Source/WebCore/inspector/front-end/HeapSnapshotProxy.js (130268 => 130269)
--- trunk/Source/WebCore/inspector/front-end/HeapSnapshotProxy.js 2012-10-03 09:48:40 UTC (rev 130268)
+++ trunk/Source/WebCore/inspector/front-end/HeapSnapshotProxy.js 2012-10-03 09:50:06 UTC (rev 130269)
@@ -363,21 +363,10 @@
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 @@
/**
* @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 @@
{
for (var i = 0; i < this._pendingSnapshotConsumers.length; ++i)
this._pendingSnapshotConsumers[i](snapshotProxy);
-
- this._started = false;
this._pendingSnapshotConsumers = [];
}
this.callMethod(buildSnapshot.bind(this), "close");
Modified: trunk/Source/WebCore/inspector/front-end/HeapSnapshotView.js (130268 => 130269)
--- trunk/Source/WebCore/inspector/front-end/HeapSnapshotView.js 2012-10-03 09:48:40 UTC (rev 130268)
+++ trunk/Source/WebCore/inspector/front-end/HeapSnapshotView.js 2012-10-03 09:50:06 UTC (rev 130269)
@@ -813,7 +813,7 @@
WebInspector.ProfileHeader.call(this, type, title, uid);
this.maxJSObjectId = maxJSObjectId;
/**
- * @type {WebInspector.FileOutputStream}
+ * @type {WebInspector.OutputStream}
*/
this._receiver = null;
/**
@@ -858,6 +858,8 @@
}
this._numberOfChunks = 0;
+ this._savedChunks = 0;
+ this._savingToFile = false;
if (!this._receiver) {
this._setupWorker();
this.sidebarElement.subtitle = WebInspector.UIString("Loading\u2026");
@@ -890,17 +892,24 @@
},
/**
- * @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;
+ },
+
/**
* @param {string} chunk
*/
@@ -910,31 +919,32 @@
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 @@
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 @@
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 @@
*/
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();
},
/**
Modified: trunk/Source/WebCore/inspector/front-end/ProfilesPanel.js (130268 => 130269)
--- trunk/Source/WebCore/inspector/front-end/ProfilesPanel.js 2012-10-03 09:48:40 UTC (rev 130268)
+++ trunk/Source/WebCore/inspector/front-end/ProfilesPanel.js 2012-10-03 09:50:06 UTC (rev 130269)
@@ -674,7 +674,7 @@
var profile = "" WebInspector.HeapSnapshotProfileType.TypeId)];
if (!profile)
return;
- profile.finishHeapSnapshot(false);
+ profile.finishHeapSnapshot();
},
/**