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