Commit af9d57b5 authored by aandrey@chromium.org's avatar aandrey@chromium.org

Web Inspector: [Canvas] REGRESSION: stack traces in the replay log are gone

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

Reviewed by Pavel Feldman.

Source/WebCore:

The V8's Error.prepareStackTrace is now called from the Error.captureStackTrace
function instead of the "stack" getter function.

Test: inspector/profiler/canvas2d/canvas-stack-trace.html

* inspector/InjectedScriptCanvasModuleSource.js:
(.):

LayoutTests:

A simple test to dump a canvas 2D trace log with function call stack traces.

* inspector/profiler/canvas-profiler-test.js:
(initialize_CanvasWebGLProfilerTest.):
(initialize_CanvasWebGLProfilerTest.InspectorTest.dumpTraceLog):
* inspector/profiler/canvas2d/canvas-stack-trace-expected.txt: Added.
* inspector/profiler/canvas2d/canvas-stack-trace.html: Added.
* platform/efl/TestExpectations:
* platform/gtk/TestExpectations:
* platform/mac/TestExpectations:
* platform/qt/TestExpectations:
* platform/win/TestExpectations:
* platform/wincairo/TestExpectations:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@140679 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 67df93b3
2013-01-24 Andrey Adaikin <aandrey@chromium.org>
Web Inspector: [Canvas] REGRESSION: stack traces in the replay log are gone
https://bugs.webkit.org/show_bug.cgi?id=107805
Reviewed by Pavel Feldman.
A simple test to dump a canvas 2D trace log with function call stack traces.
* inspector/profiler/canvas-profiler-test.js:
(initialize_CanvasWebGLProfilerTest.):
(initialize_CanvasWebGLProfilerTest.InspectorTest.dumpTraceLog):
* inspector/profiler/canvas2d/canvas-stack-trace-expected.txt: Added.
* inspector/profiler/canvas2d/canvas-stack-trace.html: Added.
* platform/efl/TestExpectations:
* platform/gtk/TestExpectations:
* platform/mac/TestExpectations:
* platform/qt/TestExpectations:
* platform/win/TestExpectations:
* platform/wincairo/TestExpectations:
2013-01-23 Alexis Menard <alexis@webkit.org>
Unreviewed cleanup of comments and a commented test.
......@@ -38,6 +38,46 @@ InspectorTest.disableCanvasAgent = function(callback)
}
};
InspectorTest.dumpTraceLogCall = function(call, indent)
{
indent = indent || "";
function formatSourceURL(url)
{
return url ? "\"" + url.replace(/^.*\/([^\/]+)\/?$/, "$1") + "\"" : "null";
}
var args = (call.arguments || []).map(function(arg) {
return arg.description;
});
var properties = [
"{Call}",
call.functionName ? "functionName:\"" + call.functionName + "\"" : "",
call.arguments ? "arguments:[" + args.join(",") + "]" : "",
call.result ? "result:" + call.result.description : "",
call.property ? "property:\"" + call.property + "\"" : "",
call.value ? "value:" + call.value.description : "",
call.isDrawingCall ? "isDrawingCall:true" : "",
"sourceURL:" + formatSourceURL(call.sourceURL),
"lineNumber:" + call.lineNumber,
"columnNumber:" + call.columnNumber
];
InspectorTest.addResult(indent + properties.filter(Boolean).join(" "));
};
InspectorTest.dumpTraceLog = function(traceLog, indent)
{
indent = indent || "";
var calls = traceLog.calls;
var properties = [
"{TraceLog}",
"alive:" + !!traceLog.alive,
"startOffset:" + (traceLog.startOffset || 0),
"#calls:" + traceLog.totalAvailableCalls
];
InspectorTest.addResult(indent + properties.filter(Boolean).join(" "));
for (var i = 0, n = calls.length; i < n; ++i)
InspectorTest.dumpTraceLogCall(calls[i], indent + " ");
};
};
function createWebGLContext(opt_canvas)
......
Tests stack traces in the Canvas TraceLog results.
Bug 107805
{TraceLog} alive:true startOffset:0 #calls:4
{Call} functionName:"beginPath" arguments:[] sourceURL:"canvas-stack-trace.html" lineNumber:19 columnNumber:13
{Call} functionName:"rect" arguments:[0,0,100,100] sourceURL:"canvas-stack-trace.html" lineNumber:20 columnNumber:13
{Call} property:"fillStyle" value:red sourceURL:"canvas-stack-trace.html" lineNumber:21 columnNumber:23
{Call} functionName:"fill" arguments:[] isDrawingCall:true sourceURL:"canvas-stack-trace.html" lineNumber:22 columnNumber:13
<html>
<head>
<script src="../../../http/tests/inspector/inspector-test.js"></script>
<script src="../canvas-profiler-test.js"></script>
<script>
var canvas;
var context;
function createCanvasContext()
{
canvas = document.getElementById("canvas");
context = canvas.getContext("2d");
console.assert(context, "Failed to create a canvas context");
}
function doSomeCanvasCalls()
{
context.beginPath();
context.rect(0, 0, 100, 100);
context.fillStyle = 'red';
context.fill();
}
function test()
{
var traceLogId;
InspectorTest.enableCanvasAgent(step1);
function step1()
{
InspectorTest.evaluateInConsole("createCanvasContext()", step2);
}
function step2()
{
CanvasAgent.startCapturing(didStartCapturing);
}
function didStartCapturing(error, id)
{
InspectorTest.assertTrue(!error && !!id, "Unexpected error: " + error);
traceLogId = id;
InspectorTest.evaluateInConsole("doSomeCanvasCalls()", didSomeCanvasCalls);
}
function didSomeCanvasCalls()
{
CanvasAgent.getTraceLog(traceLogId, 0, undefined, didReceiveTraceLog);
}
function didReceiveTraceLog(error, traceLog)
{
InspectorTest.assertTrue(!error && !!traceLog, "Unexpected error: " + error);
InspectorTest.addResult("");
InspectorTest.dumpTraceLog(traceLog);
InspectorTest.completeTest();
}
}
</script>
</head>
<body onload="runTest()">
<p>
Tests stack traces in the Canvas TraceLog results.
</p>
<a href="https://bugs.webkit.org/show_bug.cgi?id=107805">Bug 107805</a>
<canvas id="canvas"></canvas>
</body>
</html>
......@@ -1574,6 +1574,7 @@ webkit.org/b/23166 ietestcenter/css3/bordersbackgrounds/border-radius-clip-002.h
# New inspector/profiler/memory-instrumentation-canvas.html fails on JSC platforms
webkit.org/b/99001 inspector/profiler/memory-instrumentation-canvas.html
webkit.org/b/73936 inspector/profiler/canvas2d/canvas-has-uninstrumented-canvases.html
webkit.org/b/73936 inspector/profiler/canvas2d/canvas-stack-trace.html
# EFL port does not support Emacs commands.
Bug(EFL) editing/pasteboard/emacs-cntl-y-001.html [ Missing ]
......
......@@ -981,6 +981,7 @@ webkit.org/b/50485 inspector/profiler/heap-snapshot-summary-sorting-instances.ht
webkit.org/b/99001 inspector/profiler/memory-instrumentation-canvas.html [ Failure ]
webkit.org/b/50485 inspector-protocol/take-heap-snapshot.html [ Skip ]
webkit.org/b/73936 inspector/profiler/canvas2d/canvas-has-uninstrumented-canvases.html [ Failure ]
webkit.org/b/73936 inspector/profiler/canvas2d/canvas-stack-trace.html [ Failure ]
webkit.org/b/37613 webkit.org/b/20011 printing [ Skip ]
webkit.org/b/37613 editing/execCommand/print.html [ Skip ]
......
......@@ -268,6 +268,7 @@ webkit.org/b/50485 inspector-protocol/take-heap-snapshot.html [ Skip ]
# New inspector/profiler/memory-instrumentation-canvas.html fails on JSC platforms
webkit.org/b/99001 inspector/profiler/memory-instrumentation-canvas.html
webkit.org/b/73936 inspector/profiler/canvas2d/canvas-has-uninstrumented-canvases.html
webkit.org/b/73936 inspector/profiler/canvas2d/canvas-stack-trace.html
# Skipping newly added tests while I'm finding out what is wrong.
# https://bugs.webkit.org/show_bug.cgi?id=59706
......
......@@ -2440,6 +2440,7 @@ webkit.org/b/99893 svg/animations/mozilla/animateMotion-mpath-targetChange-1.svg
# New inspector/profiler/memory-instrumentation-canvas.html fails on JSC platforms
webkit.org/b/99001 inspector/profiler/memory-instrumentation-canvas.html
webkit.org/b/73936 inspector/profiler/canvas2d/canvas-has-uninstrumented-canvases.html
webkit.org/b/73936 inspector/profiler/canvas2d/canvas-stack-trace.html
# [Qt] Unidentified pixel failures
webkit.org/b/99306 animations/additive-transform-animations.html [ ImageOnlyFailure ]
......
......@@ -1297,6 +1297,7 @@ webkit.org/b/50485 inspector-protocol/take-heap-snapshot.html [ Skip ]
# New inspector/profiler/memory-instrumentation-canvas.html fails on JSC platforms
webkit.org/b/99001 inspector/profiler/memory-instrumentation-canvas.html
webkit.org/b/73936 inspector/profiler/canvas2d/canvas-has-uninstrumented-canvases.html
webkit.org/b/73936 inspector/profiler/canvas2d/canvas-stack-trace.html
# https://bugs.webkit.org/show_bug.cgi?id=40300
inspector/debugger/live-edit.html
......
......@@ -1823,6 +1823,7 @@ inspector/profiler/heap-snapshot-summary-sorting-instances.html
# New inspector/profiler/memory-instrumentation-canvas.html fails on JSC platforms
webkit.org/b/99001 inspector/profiler/memory-instrumentation-canvas.html
webkit.org/b/73936 inspector/profiler/canvas2d/canvas-has-uninstrumented-canvases.html
webkit.org/b/73936 inspector/profiler/canvas2d/canvas-stack-trace.html
# https://bugs.webkit.org/show_bug.cgi?id=40300
inspector/debugger/live-edit.html
......
2013-01-24 Andrey Adaikin <aandrey@chromium.org>
Web Inspector: [Canvas] REGRESSION: stack traces in the replay log are gone
https://bugs.webkit.org/show_bug.cgi?id=107805
Reviewed by Pavel Feldman.
The V8's Error.prepareStackTrace is now called from the Error.captureStackTrace
function instead of the "stack" getter function.
Test: inspector/profiler/canvas2d/canvas-stack-trace.html
* inspector/InjectedScriptCanvasModuleSource.js:
(.):
2013-01-23 Andrey Adaikin <aandrey@chromium.org>
Web Inspector: [Canvas] UI: add a selector to capture a single canvas frame vs consecutive frames
......@@ -192,7 +192,7 @@ function StackTrace()
StackTrace.prototype = {
/**
* @param {number} index
* @return {{sourceURL: string, lineNumber: number, columnNumber: number}}
* @return {{sourceURL: string, lineNumber: number, columnNumber: number}|undefined}
*/
callFrame: function(index)
{
......@@ -222,52 +222,47 @@ StackTrace.create = function(stackTraceLimit, topMostFunctionToIgnore)
function StackTraceV8(stackTraceLimit, topMostFunctionToIgnore)
{
StackTrace.call(this);
var oldPrepareStackTrace = Error.prepareStackTrace;
var oldStackTraceLimit = Error.stackTraceLimit;
if (typeof stackTraceLimit === "number")
Error.stackTraceLimit = stackTraceLimit;
this._error = /** @type {{stack: Array}} */ ({});
Error.captureStackTrace(this._error, topMostFunctionToIgnore || arguments.callee);
/**
* @param {Object} error
* @param {Array.<CallSite>} structuredStackTrace
* @return {Array.<{sourceURL: string, lineNumber: number, columnNumber: number}>}
*/
Error.prepareStackTrace = function(error, structuredStackTrace)
{
return structuredStackTrace.map(function(callSite) {
return {
sourceURL: callSite.getFileName(),
lineNumber: callSite.getLineNumber(),
columnNumber: callSite.getColumnNumber()
};
});
}
var holder = /** @type {{stack: Array.<{sourceURL: string, lineNumber: number, columnNumber: number}>}} */ ({});
Error.captureStackTrace(holder, topMostFunctionToIgnore || arguments.callee);
this._stackTrace = holder.stack;
Error.stackTraceLimit = oldStackTraceLimit;
Error.prepareStackTrace = oldPrepareStackTrace;
}
StackTraceV8.prototype = {
/**
* @override
* @param {number} index
* @return {{sourceURL: string, lineNumber: number, columnNumber: number}}
* @return {{sourceURL: string, lineNumber: number, columnNumber: number}|undefined}
*/
callFrame: function(index)
{
if (!this._stackTrace)
this._prepareStackTrace();
return this._stackTrace[index];
},
_prepareStackTrace: function()
{
var oldPrepareStackTrace = Error.prepareStackTrace;
/**
* @param {Object} error
* @param {Array.<CallSite>} structuredStackTrace
* @return {Array.<{sourceURL: string, lineNumber: number, columnNumber: number}>}
*/
Error.prepareStackTrace = function(error, structuredStackTrace)
{
return structuredStackTrace.map(function(callSite) {
return {
sourceURL: callSite.getFileName(),
lineNumber: callSite.getLineNumber(),
columnNumber: callSite.getColumnNumber()
};
});
}
this._stackTrace = this._error.stack;
Error.prepareStackTrace = oldPrepareStackTrace;
delete this._error; // No longer needed, free memory.
},
__proto__: StackTrace.prototype
}
......
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