Closed Bug 1204429 Opened 10 years ago Closed 10 years ago

Counting number of vertices and triangles of a snapshot

Categories

(DevTools Graveyard :: Canvas Debugger, defect)

defect
Not set
normal

Tracking

(firefox46 fixed)

RESOLVED FIXED
Firefox 46
Tracking Status
firefox46 --- fixed

People

(Reporter: daoshengmu, Assigned: daoshengmu)

References

Details

Attachments

(2 files, 8 obsolete files)

11.30 KB, patch
vporof
: review+
Details | Diff | Splinter Review
23.07 KB, patch
daoshengmu
: review+
Details | Diff | Splinter Review
Currently, CanvasDebugger has displayed number of draw-calls and function calls. In order to assist developers to find performance issue, we should add vertices and triangles count to provide them more information.
Blocks: gametool
Part 1: - Counting triangle and vertex number while calling WebGL drawArrays and drawElements functions. Next steps: Part 2: - Add tests. Part 3: - Need to display it at the snapshot list?
Attachment #8664763 - Flags: review?(vporof)
Part 2: - Add draw line, point, and triangle tests for WebGL drawArray and drawElements functions. Next step: - Need to display it at the snapshot list?
Attachment #8667787 - Flags: review?(vporof)
Comment on attachment 8667787 [details] [diff] [review] Part 2: Add tests for counting number of vertices and triangles in WebGL draw functions. r=vporof. Review of attachment 8667787 [details] [diff] [review]: ----------------------------------------------------------------- Victor, do you know how to upload test files to EXAMPLE_URL? ::: browser/devtools/canvasdebugger/test/head.js @@ +39,5 @@ > const SIMPLE_CANVAS_DEEP_STACK_URL = EXAMPLE_URL + "doc_simple-canvas-deep-stack.html"; > const WEBGL_ENUM_URL = EXAMPLE_URL + "doc_webgl-enum.html"; > const WEBGL_BINDINGS_URL = EXAMPLE_URL + "doc_webgl-bindings.html"; > +const WEBGL_DRAW_ARRAYS = "file:///Volumes/Firefox/gecko-dev/browser/devtools/canvasdebugger/test/" + "doc_webgl-drawArrays.html"; > +const WEBGL_DRAW_ELEMENTS = "file:///Volumes/Firefox/gecko-dev/browser/devtools/canvasdebugger/test/" + "doc_webgl-drawElements.html"; In fact, I think I should put my test files to EXAMPLE_URL, "http://example.com/browser/browser/devtools/canvasdebugger/test/", but I don't know how to put my test files to this url link.
Comment on attachment 8664763 [details] [diff] [review] Part 1: Collect triangle and vertex counts information. r=vporof. Review of attachment 8664763 [details] [diff] [review]: ----------------------------------------------------------------- Needs tests. ::: toolkit/devtools/server/actors/canvas.js @@ +133,2 @@ > */ > + initialize: function(conn, { canvas, calls, screenshot, triCount, vertexCount, pointCount, lineCount }) { Nit: put triCount, vertexCount etc. into an object. @@ +505,5 @@ > + > + let { name, args } = functionCall.details; > + > + // Calculate tris and vertices > + if (CanvasFront.DRAW_FUNCS[0] === name) { // drawArrays This is very fragile. Suppose DRAW_FUNCS is changed by an unknown party, this would completely break. Should just test the names directly.
Attachment #8664763 - Flags: review?(vporof) → feedback+
Comment on attachment 8664763 [details] [diff] [review] Part 1: Collect triangle and vertex counts information. r=vporof. Review of attachment 8664763 [details] [diff] [review]: ----------------------------------------------------------------- Oh, I see there's a test patch attached to this bug as well. Will review that separately. In the meantime, let's think of a mechanism that allows primitive counts to be recorded in realtime. Such information would really fit nicely in a graph in the performance tool, and would correlate well with the other graphs there. Be it sharing some code, or relying on a single implementation, could you look into that a bit?
(In reply to Daosheng Mu[:daoshengmu] from comment #3) > Comment on attachment 8667787 [details] [diff] [review] > Part 2: Add tests for counting number of vertices and triangles in WebGL > draw functions. r=vporof. > > Review of attachment 8667787 [details] [diff] [review]: > ----------------------------------------------------------------- > > Victor, do you know how to upload test files to EXAMPLE_URL? > > ::: browser/devtools/canvasdebugger/test/head.js > @@ +39,5 @@ > > const SIMPLE_CANVAS_DEEP_STACK_URL = EXAMPLE_URL + "doc_simple-canvas-deep-stack.html"; > > const WEBGL_ENUM_URL = EXAMPLE_URL + "doc_webgl-enum.html"; > > const WEBGL_BINDINGS_URL = EXAMPLE_URL + "doc_webgl-bindings.html"; > > +const WEBGL_DRAW_ARRAYS = "file:///Volumes/Firefox/gecko-dev/browser/devtools/canvasdebugger/test/" + "doc_webgl-drawArrays.html"; > > +const WEBGL_DRAW_ELEMENTS = "file:///Volumes/Firefox/gecko-dev/browser/devtools/canvasdebugger/test/" + "doc_webgl-drawElements.html"; > > In fact, I think I should put my test files to EXAMPLE_URL, > "http://example.com/browser/browser/devtools/canvasdebugger/test/", but I > don't know how to put my test files to this url link. You don't upload these files anywhere. There is a local server running when you start these tests. Just create a new file in the same dir and add it to browser.ini
Comment on attachment 8667787 [details] [diff] [review] Part 2: Add tests for counting number of vertices and triangles in WebGL draw functions. r=vporof. Postponing review until above comments are addressed.
Attachment #8667787 - Flags: review?(vporof)
Part1: - Collect triangle and vertex counts information. r=vporof. V2: - Adjusting the mechanism of counting primitive. I move them to devtools/server/primitive.js. It will collect primitive counts at every rAF. Therefore, it can support snapshot and timeline mode simultaneously. If we would like to use it in Performance tool, we need to use CallWatcherActor to monitor functioncalls and execute Primitive.handleDrawPrimitive to collect primitive counts.
Attachment #8664763 - Attachment is obsolete: true
Attachment #8674077 - Flags: feedback?(vporof)
Comment on attachment 8674077 [details] [diff] [review] 0001-Bug-1204429-Part-1-Collect-triangle-and-vertex-count.patch Review of attachment 8674077 [details] [diff] [review]: ----------------------------------------------------------------- Nice implementation with the separate actor. I'm not sure why it's also monitoring framerate though. Add a test and we can land this. ::: devtools/server/primitive.js @@ +17,5 @@ > +}; > + > +/** > + * A utility for monitoring WebGL draw primitives. Takes a `tabActor` > + * and monitors primitive over time. nit: s/primitive/primitive draws/ @@ +22,5 @@ > + */ > +const WebGLDrawArrays = "drawArrays"; > +const WebGLDrawElements = "drawElements"; > + > +var Primitive = exports.Primitive = Class({ Nit: I'd rename this to WebGLDrawWatcher or something similar. @@ +37,5 @@ > + this.stopRecording(); > + }, > + > + /** > + * Starts monitoring primitive, storing the primitive count per tick. typo: primitives. @@ +44,5 @@ > + if (this._recording) { > + return; > + } > + this._recording = true; > + this._ticks = []; Why are we also storing ticks here? We have a separate framerate actor for that. @@ +98,5 @@ > + > + /** > + * Gets the refresh driver ticks recorded so far. > + */ > + getPendingTicks: function(beginAt = 0, endAt = Number.MAX_SAFE_INTEGER) { No need for this method, right? Why measure framerate too?
Attachment #8674077 - Flags: feedback?(vporof) → feedback+
(In reply to Victor Porof [:vporof][:vp] from comment #9) > Comment on attachment 8674077 [details] [diff] [review] > 0001-Bug-1204429-Part-1-Collect-triangle-and-vertex-count.patch > > Review of attachment 8674077 [details] [diff] [review]: > ----------------------------------------------------------------- > > Nice implementation with the separate actor. I'm not sure why it's also > monitoring framerate though. Add a test and we can land this. > > ::: devtools/server/primitive.js > @@ +17,5 @@ > > +}; > > + > > +/** > > + * A utility for monitoring WebGL draw primitives. Takes a `tabActor` > > + * and monitors primitive over time. > > nit: s/primitive/primitive draws/ > Do you mean moving it to server/primitive/draws ? > @@ +22,5 @@ > > + */ > > +const WebGLDrawArrays = "drawArrays"; > > +const WebGLDrawElements = "drawElements"; > > + > > +var Primitive = exports.Primitive = Class({ > > Nit: I'd rename this to WebGLDrawWatcher or something similar. > > @@ +37,5 @@ > > + this.stopRecording(); > > + }, > > + > > + /** > > + * Starts monitoring primitive, storing the primitive count per tick. > > typo: primitives. > > @@ +44,5 @@ > > + if (this._recording) { > > + return; > > + } > > + this._recording = true; > > + this._ticks = []; > > Why are we also storing ticks here? We have a separate framerate actor for > that. > > @@ +98,5 @@ > > + > > + /** > > + * Gets the refresh driver ticks recorded so far. > > + */ > > + getPendingTicks: function(beginAt = 0, endAt = Number.MAX_SAFE_INTEGER) { > > No need for this method, right? Why measure framerate too? getPendingTicks and _ticks that are used for displaying information in a graph in performance tool. IIUC, Performance tool is a timeline-based tool. _ticks helps us collect the drawcall data per tick.
Flags: needinfo?(vporof)
(In reply to Daosheng Mu[:daoshengmu] from comment #10) > (In reply to Victor Porof [:vporof][:vp] from comment #9) > > Comment on attachment 8674077 [details] [diff] [review] > > 0001-Bug-1204429-Part-1-Collect-triangle-and-vertex-count.patch > > > > Review of attachment 8674077 [details] [diff] [review]: > > ----------------------------------------------------------------- > > > > Nice implementation with the separate actor. I'm not sure why it's also > > monitoring framerate though. Add a test and we can land this. > > > > ::: devtools/server/primitive.js > > @@ +17,5 @@ > > > +}; > > > + > > > +/** > > > + * A utility for monitoring WebGL draw primitives. Takes a `tabActor` > > > + * and monitors primitive over time. > > > > nit: s/primitive/primitive draws/ > > > Do you mean moving it to server/primitive/draws ? Rename "primitive" to "primitive draws" > > > @@ +22,5 @@ > > > + */ > > > +const WebGLDrawArrays = "drawArrays"; > > > +const WebGLDrawElements = "drawElements"; > > > + > > > +var Primitive = exports.Primitive = Class({ > > > > Nit: I'd rename this to WebGLDrawWatcher or something similar. > > > > @@ +37,5 @@ > > > + this.stopRecording(); > > > + }, > > > + > > > + /** > > > + * Starts monitoring primitive, storing the primitive count per tick. > > > > typo: primitives. > > > > @@ +44,5 @@ > > > + if (this._recording) { > > > + return; > > > + } > > > + this._recording = true; > > > + this._ticks = []; > > > > Why are we also storing ticks here? We have a separate framerate actor for > > that. > > > > @@ +98,5 @@ > > > + > > > + /** > > > + * Gets the refresh driver ticks recorded so far. > > > + */ > > > + getPendingTicks: function(beginAt = 0, endAt = Number.MAX_SAFE_INTEGER) { > > > > No need for this method, right? Why measure framerate too? > > getPendingTicks and _ticks that are used for displaying information in a > graph in performance tool. IIUC, Performance tool is a timeline-based tool. > _ticks helps us collect the drawcall data per tick.
Flags: needinfo?(vporof)
(In reply to Daosheng Mu[:daoshengmu] from comment #10) > > > > No need for this method, right? Why measure framerate too? > > getPendingTicks and _ticks that are used for displaying information in a > graph in performance tool. IIUC, Performance tool is a timeline-based tool. > _ticks helps us collect the drawcall data per tick. But this is a different actor. Why have this functionality duplicated in another actor?
Comment on attachment 8674077 [details] [diff] [review] 0001-Bug-1204429-Part-1-Collect-triangle-and-vertex-count.patch Review of attachment 8674077 [details] [diff] [review]: ----------------------------------------------------------------- I am ok to remove it if you think it is not appropriate. ::: devtools/server/primitive.js @@ +125,5 @@ > + lines: this._lines > + } > + } > + > + this._ticks.push(tick); Actually, _ticks in this actor stores primitive info not framerate.
Victor, please help me review it. Thanks a lot. V3: Refer to Comment 9 to correct typos.
Attachment #8674077 - Attachment is obsolete: true
Attachment #8686506 - Flags: review?(vporof)
Victor, please help me review it. Thanks a lot. V4: Refer to Comment 9 to correct typos. Same as to V3 but adjust patch lines.
Attachment #8686506 - Attachment is obsolete: true
Attachment #8686506 - Flags: review?(vporof)
Attachment #8686508 - Flags: review?(vporof)
V2: Making some adjustments because part 1 is changed.
Attachment #8667787 - Attachment is obsolete: true
Attachment #8686594 - Flags: review?(vporof)
V3: Making some adjustments because part 1 is changed.
Attachment #8686594 - Attachment is obsolete: true
Attachment #8686594 - Flags: review?(vporof)
Attachment #8686604 - Flags: review?(vporof)
Comment on attachment 8686508 [details] [diff] [review] Part 1: Collect primitive counts information (V4) Review of attachment 8686508 [details] [diff] [review]: ----------------------------------------------------------------- ::: devtools/server/actors/canvas.js @@ +380,5 @@ > return; > } > if (CanvasFront.DRAW_CALLS.has(name) && this._animationStarted) { > this._handleDrawCall(functionCall); > + this._drawWatcher.handleDrawPrimitive(functionCall); Looks like the drawWatcher isn't really watching anything. It's more of a helper. Rename the class and this member to WebGLPrimitiveCounter. ::: devtools/server/primitive.js @@ +32,5 @@ > + this.stopRecording(); > + }, > + > + /** > + * Starts monitoring primitive draws, storing the primitives count per tick. This isn't monitoring anything by itself. @@ +34,5 @@ > + > + /** > + * Starts monitoring primitive draws, storing the primitives count per tick. > + */ > + startRecording: function() { This is incorrectly named, it doesn't actually start recording anything. Should rename it to `resetCounts` or something. @@ +35,5 @@ > + /** > + * Starts monitoring primitive draws, storing the primitives count per tick. > + */ > + startRecording: function() { > + if (this._recording) { Is _recording really necessary? @@ +47,5 @@ > + this._startTime = this.tabActor.docShell.now(); > + }, > + > + /** > + * Stops monitoring primitive draws, returning the recorded values. Bad comment. This helper doesn't monitor anything by itself. @@ +49,5 @@ > + > + /** > + * Stops monitoring primitive draws, returning the recorded values. > + */ > + stopRecording: function(beginAt = 0, endAt = Number.MAX_SAFE_INTEGER) { Should rename this to getCounts. @@ +62,5 @@ > + > + this._tris = 0; > + this._vertices = 0; > + this._points = 0; > + this._lines = 0; This method does more than it should. Using `resetCounts` is enough. @@ +63,5 @@ > + this._tris = 0; > + this._vertices = 0; > + this._points = 0; > + this._lines = 0; > + trailing whitespace. @@ +70,5 @@ > + > + /** > + * Stops monitoring primitive draws, without returning the recorded values. > + */ > + cancelRecording: function() { No need for this method. @@ +72,5 @@ > + * Stops monitoring primitive draws, without returning the recorded values. > + */ > + cancelRecording: function() { > + this._recording = false; > + this._ticks = null; Remove _ticks @@ +79,5 @@ > + > + /** > + * Returns whether this instance is currently recording. > + */ > + isRecording: function() { Is this method really necessary?
Attachment #8686508 - Flags: review?(vporof) → feedback+
Comment on attachment 8686604 [details] [diff] [review] Part 2: Add tests for counting number of primitives in WebGL draw functions. (V3) Review of attachment 8686604 [details] [diff] [review]: ----------------------------------------------------------------- ::: devtools/client/canvasdebugger/test/browser_profiling-webgl.js @@ +74,5 @@ > + > + yield removeTab(target.tab); > + > + finish(); > +} Please remove trailing whitespace.
Attachment #8686604 - Flags: review?(vporof) → review+
Victor, thanks for your comments. V5 - Refer to Comment 18, removing redundant functions and correct function naming.
Attachment #8686508 - Attachment is obsolete: true
Attachment #8690415 - Flags: review?(vporof)
V4 - Refer to Comment 19, removing trailing whitespace.
Attachment #8686604 - Attachment is obsolete: true
Attachment #8690418 - Flags: review+
Attachment #8690415 - Flags: review?(vporof) → review+
V5 - Update the patch by removing trailing whitespace and take r+ from Comment 19.
Attachment #8690418 - Attachment is obsolete: true
Attachment #8698348 - Flags: review+
Assignee: nobody → dmu
Keywords: checkin-needed
Status: NEW → RESOLVED
Closed: 10 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 46
Product: Firefox → DevTools
Product: DevTools → DevTools Graveyard
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: