blob: 06f13dc351d6a88e3f4c70a5b099cef7686958a1 [file] [log] [blame] [view]
Brian Sheedy49f3942552019-06-13 22:19:011# GPU Pixel Testing With Gold
2
3This page describes in detail the GPU pixel tests that utilize Skia Gold for
4storing and comparing images (the `pixel_skia_gold_test` type). This includes
5information such as how Skia Gold works, how to triage images produced by these
6tests, and working on Gold itself.
7
8[TOC]
9
10## Skia Gold
11
12[Gold][gold documentation] is an image diff service developed by the Skia team.
13It was originally developed solely for Skia's usage and only supported
14post-submit tests, but has been picked up by other projects such as Chromium and
15PDFium and now supports trybots. Unlike other image diff solutions in Chromium,
16comparisons are done in an external service instead of locally on the testing
17machine.
18
19[gold documentation]: https://skia.org/dev/testing/skiagold
20
21### Why Gold
22
23Gold has three main advantages over the traditional local image comparison
24historically used by Chromium:
25
261. Triage time can be much lower. Because triaging is handled by an external
27service, new golden images don't need to go through the CQ and wait for
28waterfall bots to pick up the CL. Once an image is triaged in Gold, it
29becomes immediately available for future test runs.
302. Gold supports multiple approved images per test. It is not uncommon for
31tests to produce images that are visually indistinguishable, but differ in
32a handful of pixels by a small RGB value. Fuzzy image diffing can solve this
33problem, but introduces its own set of issues such as possibly causing a test
34to erroneously pass. Since most tests that exhibit this behavior only actually
35produce 2 or 3 possible valid images, being able to say that any of those
36images are acceptable is simpler and less error-prone.
373. Better image storage. Traditionally, images had to either be included
38directly in the repository or uploaded to a Google Storage bucket and pulled in
39using the image's hash. The former allowed users to easily see which images were
40currently approved, but storing large sized or numerous binary files in git is
41generally discouraged due to the way git's history works. The latter worked
42around the git issues, but made it much more difficult to actually see what was
43being used since the only thing the user had to go on was a hash. Gold moves the
44images out of the repository, but provides a GUI interface for easily seeing
45which images are currently approved for a particular test.
46
47### How It Works
48
49Gold consists of two main parts: the Gold instance/service and the `goldctl`
50binary. A Gold instance in turn consists of two parts: a Google Storage bucket
51that data is uploaded to and a server running on GCE that ingests the data and
52provides a way to triage diffs. `goldctl` simply provides a standardized way
53of interacting with Gold - uploading data to the correct place, retrieving
54baselines/golden information, etc.
55
56In general, the following order of events occurs when running a Gold-enabled
57test:
58
591. The test produces an image and passes it to `goldctl`, along with some
60information about the hardware and software configuration that the image was
61produced on, the test name, etc.
622. `goldctl` checks whether the hash of the produced image is in the list of
63approved hashes.
64 1. If it is, `goldctl` exits with a non-failing return code and nothing else
65 happens. At this point, the test is finished.
66 2. If it is not, `goldctl` uploads the image and metadata to the storage
67 bucket and exits with a failing return code.
683. The server sees the new data in the bucket and ingests it, showing a new
69untriaged image in the GUI.
704. A user approves the new image in the GUI, and the server adds the image's
71hash to the baselines. See the [Waterfall Bots](#Waterfall-Bots) and
72[Trybots](#Trybots) sections for specifics on this.
735. The next time the test is run, the new image is in the baselines, and
74assuming the test produces the same image again, the test passes.
75
76While this is the general order of events, there are several differences between
77waterfall/CI bots and trybots.
78
79#### Waterfall Bots
80
81Waterfall bots are the simpler of the two bot types. There is only a single
82set of baselines to worry about, which is whatever baselines were approved for
83a git revision. Additionally, any new images that are produced on waterfalls are
84all lumped into the same group of "untriaged images on master", and any images
85that are approved from here will immediately be added to the set of baselines
86for master.
87
88Since not all waterfall bots have a trybot counterpart that can be relied upon
89to catch newly produced images before a CL is committed, it is likely that a
90change that produces new goldens on the CQ will end up making some of the
91waterfall bots red for a bit, particularly those on chromium.gpu.fyi. They will
92remain red until the new images are triaged as positive or the tests stop
93producing the untriaged images. So, it is best to keep an eye out for a few
94hours after your CL is committed for any new images from the waterfall bots that
95need triaging.
96
97#### Trybots
98
99Trybots are a little more complicated when it comes to retrieving and approving
100images. First, the set of baselines that are provided when requested by a test
101is the union of the master baselines for the current revision and any baselines
102that are unique to the CL. For example, if an image with the hash `abcd` is in
103the master baselines for `FooTest` and the CL being tested has also approved
104an image with the hash `abef` for `FooTest`, then the provided baselines will
105contain both `abcd` and `abef` for `FooTest`.
106
107When an image associated with a CL is approved, the approval only applies to
108that CL until the CL is merged. Once this happens, any baselines produced by the
109CL are automatically merged into the master baselines for whatever git revision
110the CL was merged as. In the above example, if the CL was merged as commit
111`ffff`, then both `abcd` and `abef` would be approved images on master from
112`ffff` onward.
113
114## Triaging Failures
115
116### Standard Workflow
117
118The current approach to getting the triage links for new images is:
119
1201. Navigate to the failed build.
1212. Search for the failed step for the `pixel_skia_gold_test` test.
Brian Sheedy697b20072019-07-09 21:59:361223. Look for either:
123 1. One or more links named `gold_triage_link for <test name>`. This will be
124 the case if there are fewer than 10 links.
125 2. A single link named
126 `Too many artifacts produced to link individually, click for links`. This
127 will be the case if there are 10 or more links.
1284. In either case, follow the link(s) to the triage page for the image the
129failing test produced.
1305. Triage images on those pages (typically by approving them, but you can also
Brian Sheedy49f3942552019-06-13 22:19:01131mark them as a negative if it is an image that should not be produced). In the
132case of a negative image, a bug should be filed on [crbug] to investigate and
133fix the cause of the that particular image being produced, as future
134occurrences of it will cause the test to fail. Such bugs should include the
135`Internals>GPU>Testing` component and whatever component is suitable for the
Brian Sheedy697b20072019-07-09 21:59:36136type of failing test (likely `Blink>WebGL` or `Blink>Canvas`). The test should
137also be marked as failing or skipped in
138`//content/test/gpu/gpu_tests/test_expectations/pixel_expectations.txt` so that
139the test failure doesn't show up as a builder failure. If the failure is
140consistent, prefer to skip instead of mark as failing so that the failure links
141don't pile up. If the failure occurs on the trybots, include the change to the
142expectations in your CL.
Brian Sheedy49f3942552019-06-13 22:19:01143
144[crbug]: https://crbug.com
145
Brian Sheedy697b20072019-07-09 21:59:36146In the future, a comment will also be automatically posted to CLs that produce
147new images with a link to triage them.
Brian Sheedy49f3942552019-06-13 22:19:01148
Brian Sheedy697b20072019-07-09 21:59:36149In addition, you can see all currently untriaged images that are currently
150being produced on ToT on the [GPU Gold instance's main page][gpu gold instance]
151and currently untriaged images for a CL by substituting the Gerrit CL number
152into
Brian Sheedy49f3942552019-06-13 22:19:01153`https://chrome-gpu-gold.skia.org/search?issue=[CL Number]&unt=true&master=true`.
154
155[gpu gold instance]: https://chrome-gpu-gold.skia.org
156
Brian Sheedy697b20072019-07-09 21:59:36157It's possible, particularly if a test is regularly producing multiple images,
158for an image to be untriaged but not show up on the front page of the Gold
159instance (for details, see [this crbug comment][non tot untriaged comment]). To
160see all such images, visit [this link][untriaged non tot].
161
162[untriaged non tot comment]: https://bugs.chromium.org/p/skia/issues/detail?id=9189#c4
163[untriaged non tot]: https://chrome-gpu-gold.skia.org/search?fdiffmax=-1&fref=false&frgbamax=255&frgbamin=0&head=false&include=false&limit=50&master=false&match=name&metric=combined&neg=false&offset=0&pos=false&query=source_type%3Dchrome-gpu&sort=desc&unt=true
164
Brian Sheedy49f3942552019-06-13 22:19:01165### Triaging A Specific Image
166
167If for some reason an image is not showing up in Gold but you know the hash, you
168can manually navigate to the page for it by filling in the correct information
169to `https://chrome-gpu-gold.skia.org/detail?test=[test_name]&digest=[hash]`.
170From there, you should be able to triage it as normal.
171
172If this happens, please also file a bug in [Skia's bug tracker][skia crbug] so
173that the root cause can be investigated and fixed. It's likely that you will
174be unable to directly edit the owner, CC list, etc. directly, in which case
175ping kjlubick@ with a link to the filed bug to help speed up triaging. Include
176as much detail as possible, such as a links to the failed swarming task and
177the triage link for the problematic image.
178
179[skia crbug]: https://bugs.chromium.org/p/skia
180
181## Working On Gold
182
183### Modifying Gold And goldctl
184
185Although uncommon, changes to the Gold service and `goldctl` binary may be
186needed. To do so, simply get a checkout of the
187[Skia infrastructure repo][skia infra repo] and go through the same steps as
188a Chromium CL (`git cl upload`, etc.).
189
190[skia infra repo]: https://skia.googlesource.com/buildbot/
191
192The Gold service code is located in the `//golden/` directory, while `goldctl`
193is located in `//gold-client/`. Once your change is merged, you will have to
194either contact [email protected] to roll the service version or follow the
195steps in [Rolling goldctl](#Rolling-goldctl) to roll the `goldctl` version used
196by Chromium.
197
198### Rolling goldctl
199
200`goldctl` is available as a CIPD package and is DEPSed in as part of `gclient
201sync` To update the binary used in Chromium, perform the following steps:
202
2031. (One-time only) get an [infra checkout][infra repo]
2042. Run `infra $ ./go/env.py` and run each of the commands it outputs to change
205your GOPATH and other environment variables for your terminal
2063. Update the Skia revision in [`deps.yaml`][deps yaml] to match the revision
207of your `goldctl` CL (or some revision after it)
2084. Run `infra $ ./go/deps.py update` and copy the list of repos it updated
209(include this in your CL description)
2105. Upload the changelist ([sample CL][sample roll cl])
2116. Once the CL is merged, wait until the git revision of your merged CL shows
212up in the tags of one of the instances for the [CIPD package][goldctl package]
2137. Update the [revision in DEPS][goldctl deps entry] to be the merged CL's
214revision
215
216[infra repo]: https://chromium.googlesource.com/infra/infra/
217[deps yaml]: https://chromium.googlesource.com/infra/infra/+/91333d832a4d871b4219580dfb874b49a97e6da4/go/deps.yaml#432
218[sample roll cl]: https://chromium-review.googlesource.com/c/infra/infra/+/1493426
219[goldctl package]: https://chrome-infra-packages.appspot.com/p/skia/tools/goldctl/linux-amd64/+/
220[goldctl deps entry]: https://chromium.googlesource.com/chromium/src/+/6b7213a45382f01ac0a2efec1015545bd051da89/DEPS#1304
221
222If you want to make sure that `goldctl` builds after the update before
223committing (e.g. to ensure that no extra third party dependencies were added),
224run the following after the `./go/deps.py update` step:
225
2261. `infra $ ./go/deps.py install`
2272. `infra $ go install go.skia.org/infra/gold-client/cmd/goldctl`
2283. `infra $ which goldctl` which should point to a binary in `infra/go/bin/`
2294. `infra $ goldctl` to make sure it actually runs