Skip to content

Commit a8352cc

Browse files
Nathaniel NifongSkia Commit-Bot
authored andcommitted
Write a debugger user guide.
No-Try: true Docs-Preview: https://skia.org/?cl=261088 Change-Id: I5d049ca0ee71a7bb10ff70c71b2a92604a034831 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/261088 Commit-Queue: Nathaniel Nifong <nifong@google.com> Reviewed-by: Joe Gregorio <jcgregorio@google.com>
1 parent 3e5e2f2 commit a8352cc

13 files changed

Lines changed: 152 additions & 2 deletions

site/dev/tools/buttons.png

1.14 KB
Loading

site/dev/tools/calendar.mskp

15.4 MB
Binary file not shown.

site/dev/tools/crosshair.png

28 KB
Loading

site/dev/tools/debugger.md

Lines changed: 152 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,158 @@ The Skia Debugger is a graphical tool used to step through and analyze the
88
contents of the Skia picture format. The tool is available online at
99
[https://debugger.skia.org](https://debugger.skia.org/) or can be run locally.
1010

11+
Features:
12+
13+
* Draw command and multiple frame playback
14+
* Shows the current clip and matrix at any step
15+
* Zoomed viewer with crosshair for selecting pixels.
16+
* Breakpoints that stop playback when a pixel's color changes.
17+
* GPU or CPU backed execution.
18+
* GPU op bounds visualization
19+
* Android offscreen layer visualization
20+
* Shared resource viewer
21+
22+
![Debugger interface](/dev/tools/onlinedebugger.png)
23+
24+
User Guide
25+
-----------
26+
27+
SKP files can contain a single frame or multiple frames. Single frame files have the .skp extension
28+
and Multi-frame files have the .mskp extension. In the online debugger linked above, Open a
29+
[sample mskp file](/dev/tools/calendar.mskp)
30+
or capture one from an android device using the
31+
[instructions here](https://sites.google.com/a/google.com/skia/android/skp-from-framework).
32+
33+
### Command Playback and Filters
34+
35+
Try playing back the commands within the current frame using the lower play button
36+
![play](/dev/tools/playcommands.png), (the one not
37+
in a circle) You should see the image built up one draw at a time.
38+
39+
Many commands manipulate the matrix or clip but don't make any visible change when run. Try filtering
40+
these out by pasting `!drawannotation save restore concat setmatrix cliprect` in to the filter
41+
textbox just below the command playback controls. Press enter to apply the filter, and resume
42+
playback if it was paused. This will have the effect of making the playback appear to be much faster
43+
as there are only 29 commands in the first frame of the sample file that pass this filter.
44+
45+
Try pausing command playback and stepping forward and back through the commands using `,` (comma)
46+
and `.` (period).
47+
48+
> Filters are case insensitive, and the only supported logical operator is ! (not) which applies to
49+
> the entire filter and is only recognised when it occurs at the beginning.
50+
51+
Any command can be expanded using the
52+
![expand](/dev/tools/expand.png) icon to see all of the
53+
parameters that were recorded with that command.
54+
55+
Commands can be disabled or enabled with the checkbox that becomes available after expanding the
56+
command's detail view.
57+
58+
Jog the command playhead to the end of the list with the
59+
![end](/dev/tools/end.png) button.
60+
61+
### Frame playback
62+
63+
![frame playback](/dev/tools/frameplayback.png)
64+
65+
The sample file contains multiple frames. Use the encircled play button to play back the frames.
66+
The current frame is indictated by the slider position, and the slider can be set manually. Frames
67+
can be stepped through with `w` (back) and `s` forward. `p` pauses or unpauses the frame playback.
68+
69+
Not all frames in a file will have the same number of commands. When the command playhead is left at
70+
the end of the list the debugger will play every frame to the end of its list. If the command
71+
playhead is somewhere in the middle, say 155, the debugger will try to play every frame to its
72+
155th command.
73+
74+
### Resources Tab
75+
76+
![resources](/dev/tools/resources.png)
77+
78+
Any resources that were referenced by commands in the file appear here.
79+
As of Dec 2019, this only shows images.
80+
81+
Any resource can be selected and viewed. You may find it helpful to toggle the Light/Dark setting if
82+
you cannot see an image.
83+
84+
Images' names are formatted as `7 @24205864 (99, 99)` where `7` is the index of the image as it was
85+
saved in the file, `@24205864` is it's address in wasm memory, for cross referencing with DrawImage*
86+
commands in the command list which also show this address, and `(99, 99)` is the size of the image.
87+
88+
The resource viewer allows a user to determine if an image was not effectively shared between frames
89+
or draw commands. If it occurs more than once in the resource tab, then there were multiple copies
90+
of it with different generation ids in the process that recorded the SKP.
91+
92+
### Android Layers
93+
94+
![layers](/dev/tools/layers.png)
95+
96+
When MSKPs are recorded in Android, Extra information about offscreen hardware layers is recorded.
97+
The sample google calendar mskp linked above contains this information. You will find two layers on
98+
frame 3.
99+
100+
There are two kinds of events relevant to recorded android layer use.
101+
1. Draw Events - points when an offscreen surface was drawn to. They may be complete, meaning the
102+
clip equalled the surface's size, or partial, meaning the clip was smaller.
103+
2. Use events - points when the offscreen surface was used as an SkImage in the main surface.
104+
105+
Layers are shown as boxes in the bottom right of the interface when viewing a frame where a layer
106+
draw event occurred. Each Layer box has two buttons: `Show Use` will cycle through use events for that
107+
layer in the current frame if there are any, and `Inspector` will open the draw event as if it were
108+
a single frame SKP. you can play back it's commands, enable or disabled them, inspect GPU op bounds
109+
or anything else you could do with an ordinary SKP. Exit the inspector by clicking the `Exit` button
110+
on the layer box.
111+
112+
### Crosshair and Breakpoints
113+
114+
![crosshair](/dev/tools/crosshair.png)
115+
116+
Clicking any point in the main view will toggle a red crosshair for selecting pixels. the selected
117+
pixel's color is shown in several formats on the right pane. A zoomed view centered on the selected
118+
pixel is shown below it. The position can be moved precicely by either clicking neighbooring pixels
119+
in the zoom view, or using `H` (left) `L` (right) `J` (down) `K` (up).
120+
121+
When "Break on change" is selected, command playback will pause on any command which changes the
122+
color of the selected pixel. this can be used to find the command that draws something you see
123+
in the viewer.
124+
125+
### GPU Op Bounds and Other settings
126+
127+
![settings](/dev/tools/settings.png)
128+
129+
Each of the filtered commands from above has a colored number to its right
130+
![gpu op](/dev/tools/gpuop.png). This is the GPU
131+
operation id. When multiple commands share a GPU op id, this indicates that they were batched
132+
together when sent to the GPU. In the WASM debugger, this goes though WebGL.
133+
134+
There is a "Display GPU Op Bounds" toggle in the upper right of the interface. Turning this on will
135+
show a colored rectangle to represent the bounds of the GPU op of the currently selected command.
136+
137+
GPU - Controls which backend Skia uses to draw to the screen. GPU in the online wasm debugger means
138+
WebGL. CPU means skia draws into a surface in memory which is copied into an HTML canvas without
139+
using the GPU.
140+
141+
Light/Dark - this toggle changes the appearance of the checkerboard behind the main view and zoom
142+
views to assist in viewing content with transparency.
143+
144+
Display Overdraw Viz - This vizualization shows a red overlay that is darker in propertion to how
145+
much overdraw has occurred on a pixel. Overdraw meaning that the pixel was drawn to more than once.
146+
* As of Dec 2019, this feature may not be working correctly.
147+
148+
### Image fit and download buttons.
149+
150+
![buttons](/dev/tools/settings.png)
151+
152+
These buttons resize the main view.
153+
they are, from left to right:
154+
155+
Original size - the natural size of the canvas, when it was recorded.
156+
Fit to page - shrink enough that the whole canvas fits in the center pane.
157+
Fit to page width - make the canvas fit horizontally but allow scrolling vertically
158+
Fit to page height - make the canvas fit vertically but allow scrolling horizontally.
159+
160+
next to these is a 5th, unrelated download button which saves the current canvas as a PNG file.
161+
162+
11163
Building and running locally
12164
--------------------
13165

@@ -25,5 +177,3 @@ Begin by following the instructions to
25177

26178
After running `skiaserve`, follow the instructions to open the debugger in your
27179
local browser. By default the address will be `http://127.0.0.1:8888`.
28-
29-
![Debugger interface](/dev/tools/onlinedebugger.png)

site/dev/tools/end.png

228 Bytes
Loading

site/dev/tools/expand.png

225 Bytes
Loading

site/dev/tools/frameplayback.png

1.88 KB
Loading

site/dev/tools/gpuop.png

678 Bytes
Loading

site/dev/tools/layers.png

23.6 KB
Loading

site/dev/tools/onlinedebugger.png

311 KB
Loading

0 commit comments

Comments
 (0)