|
Name |
|
Date |
Size |
#Lines |
LOC |
| .. | | - | - |
| external_test/ | | 03-May-2024 | - | 199 | 182 |
| fonts/ | | 03-May-2024 | - | 4 | 2 |
| future_apis/ | | 03-May-2024 | - | 81 | 57 |
| go/gold_test_env/ | | 03-May-2024 | - | 222 | 152 |
| htmlcanvas/ | | 03-May-2024 | - | 2,253 | 1,866 |
| npm_build/ | | 03-May-2024 | - | 13,195 | 9,191 |
| tests/ | | 03-May-2024 | - | 7,317 | 5,861 |
| wasm_tools/ | | 03-May-2024 | - | 555 | 293 |
| .gitignore | D | 03-May-2024 | 131 | 6 | 6 |
| BUILD.bazel | D | 03-May-2024 | 9.8 KiB | 350 | 326 |
| BUILD.gn | D | 03-May-2024 | 9.9 KiB | 403 | 375 |
| CHANGELOG.md | D | 03-May-2024 | 49.4 KiB | 1,075 | 858 |
| Makefile | D | 03-May-2024 | 6.7 KiB | 198 | 158 |
| README.md | D | 03-May-2024 | 7.2 KiB | 163 | 117 |
| WasmCommon.h | D | 03-May-2024 | 4.1 KiB | 127 | 80 |
| canvaskit.gni | D | 03-May-2024 | 1.4 KiB | 36 | 32 |
| canvaskit_bindings.cpp | D | 03-May-2024 | 118.9 KiB | 2,455 | 2,113 |
| catchExceptionNop.js | D | 03-May-2024 | 474 | 14 | 6 |
| color.js | D | 03-May-2024 | 6.9 KiB | 203 | 148 |
| compile.sh | D | 03-May-2024 | 7.4 KiB | 261 | 215 |
| compile_gm.sh | D | 03-May-2024 | 6.7 KiB | 235 | 181 |
| cpu.js | D | 03-May-2024 | 4.8 KiB | 114 | 73 |
| debug.js | D | 03-May-2024 | 79 | 5 | 4 |
| debugger.js | D | 03-May-2024 | 1 KiB | 27 | 16 |
| debugger_bindings.cpp | D | 03-May-2024 | 21.2 KiB | 531 | 360 |
| externs.js | D | 03-May-2024 | 31 KiB | 1,220 | 984 |
| font.js | D | 03-May-2024 | 12.5 KiB | 330 | 251 |
| gm.js | D | 03-May-2024 | 1.5 KiB | 50 | 40 |
| gm_bindings.cpp | D | 03-May-2024 | 12.8 KiB | 369 | 271 |
| interface.js | D | 03-May-2024 | 50.5 KiB | 1,306 | 957 |
| karma.bazel.js | D | 03-May-2024 | 1.6 KiB | 48 | 22 |
| karma.conf.js | D | 03-May-2024 | 3.1 KiB | 95 | 48 |
| matrix.js | D | 03-May-2024 | 17.4 KiB | 535 | 383 |
| memory.js | D | 03-May-2024 | 13.3 KiB | 396 | 240 |
| package-lock.json | D | 03-May-2024 | 133.3 KiB | 3,684 | 3,683 |
| package.json | D | 03-May-2024 | 460 | 22 | 21 |
| paragraph.js | D | 03-May-2024 | 15.4 KiB | 366 | 292 |
| paragraph_bindings.cpp | D | 03-May-2024 | 30.9 KiB | 738 | 606 |
| paragraph_bindings_gen.cpp | D | 03-May-2024 | 5.1 KiB | 107 | 81 |
| pathops.js | D | 03-May-2024 | 439 | 18 | 15 |
| postamble.js | D | 03-May-2024 | 127 | 3 | 1 |
| preamble.js | D | 03-May-2024 | 376 | 9 | 1 |
| release.js | D | 03-May-2024 | 205 | 6 | 3 |
| rt_shader.js | D | 03-May-2024 | 2.4 KiB | 49 | 29 |
| skottie.js | D | 03-May-2024 | 5.2 KiB | 145 | 96 |
| skottie_bindings.cpp | D | 03-May-2024 | 14.8 KiB | 378 | 298 |
| skp.js | D | 03-May-2024 | 594 | 18 | 14 |
| util.js | D | 03-May-2024 | 370 | 19 | 10 |
| viewer_bindings.cpp | D | 03-May-2024 | 2.7 KiB | 73 | 60 |
| webgl.js | D | 03-May-2024 | 17.2 KiB | 399 | 297 |
| webgpu.js | D | 03-May-2024 | 5.6 KiB | 142 | 107 |
README.md
1# Prerequisites
2
3Node v14 or later is required to run tests. We use npm (the Node Package Manager) to install
4test dependencies. Recent installations of Node have npm as well.
5CanvasKit has no other external source dependencies.
6
7## Compiling with GN
8To build with GN, you need to have followed the instructions to download Skia and its deps
9<https://skia.org/user/download>.
10
11To compile CanvasKit, you will first need to [download and activate `emscripten`][1] using the
12script in `//bin/activate-emsdk` (or `//bin/git-sync-deps` which also calls activate-emsdk).
13This places the associated files in `//third_party/externals/emsdk` and the GN[2] build scripts
14will use those by default.
15The compile.sh script automates the default GN settings; users are free to set their own. If users
16want to use their own version of emscripten, they should set the `skia_emsdk_dir` argument
17(see `//skia/gn/toolchain/wasm.gni`). For other available arguments, see
18`//modules/canvaskit/BUILD.gn`.
19
20[1]: https://emscripten.org/
21[2]: https://chromium.googlesource.com/chromium/src/tools/gn/+/48062805e19b4697c5fbd926dc649c78b6aaa138/README.md
22
23### MacOS specific notes
24Make sure you have Python3 installed, otherwise the downloading emscripten toolchain
25can fail with errors about SSL certificates. <https://github.com/emscripten-core/emsdk/pull/273>
26
27See also <https://github.com/emscripten-core/emscripten/issues/9036#issuecomment-532092743>
28for a solution to Python3 using the wrong certificates.
29
30# Compile and Run Local Example
31
32```
33# The following installs all npm dependencies and only needs to be when setting up
34# or if our npm dependencies have changed (rarely).
35npm ci
36
37make release # make debug is much faster and has better error messages
38make local-example
39```
40
41This will print a local endpoint for viewing the example. You can experiment
42with the CanvasKit API by modifying `./npm_build/example.html` and refreshing
43the page. For some more experimental APIs, there's also `./npm_build/extra.html`.
44
45For other available build targets, see `Makefile` and `compile.sh`.
46For example, building a stripped-down version of CanvasKit with no text support or
47any of the "extras", one might run:
48
49 ./compile.sh no_skottie no_font
50
51Such a stripped-down version is about half the size of the default release build.
52
53# Unit tests, performance tests, and coverage.
54
55To run unit tests and compute test coverage on a debug gpu build
56
57```
58make debug
59make test-continuous
60```
61
62This reads karma.conf.js, and opens a Chrome browser and begins running all the test
63in `test/` it will detect changes to the tests in that directory and automatically
64run again, however it will automatically rebuild and reload CanvasKit. Closing the
65chrome window will just cause it to re-opened. Kill the karma process to stop continuous
66monitoring for changes.
67
68The tests are run with whichever build of CanvasKit you last made. be sure to also
69test with `release`, `debug_cpu`, and `release_cpu`. testing with release builds will
70expose problems in closure compilation and usually forgotten externs.
71
72## Coverage
73
74Coverage will be automatically computed when running test-continuous locally. Note that
75the results will only be useful when testing a debug build. Open
76`coverage/<browser version>/index.html` For a summary and detailed line-by-line result.
77
78## Measuring Performance
79
80We use puppeteer to run a Chrome browser to gather performance data in a consistent way.
81See `//tools/perf-canvaskit-puppeteer` for more.
82
83## Adding tests
84
85The tests in `tests/` are grouped into files by topic.
86Within each file there are `describe` blocks further organizing the tests, and within those
87`it()` functions which test particular behaviors. `describe` and `it` are jasmine methods
88which can both be temporarily renamed `fdescribe` and `fit`. Which causes jasmine to only those.
89
90We have also defined `gm` which is a method for defining a test which draws something to a canvas
91that is shapshotted and reported to gold.skia.org, where you can compare it with the snapshot at
92head.
93
94## Testing from Gerrit
95
96When submitting a CL in gerrit, click "choose tryjobs" and type CanvasKit to filter them.
97select all of them, which at the time of this writing is four jobs, for each combination
98of perf/test gpu/cpu.
99
100The performance results are reported to [perf.skia.org] and correctness results are reported to
101[gold.skia.org].
102
103Coverage is not measured while running tests this way.
104
105# Inspecting output WASM
106
107The `wasm2wat` tool from [the WebAssembly Binary Toolkit](https://github.com/WebAssembly/wabt)
108can be used to produce a human-readable text version of a `.wasm` file.
109
110The output of `wasm2wat --version` should be `1.0.13 (1.0.17)`. This version has been checked to
111work with the tools in `wasm_tools/SIMD/`. These tools programmatically inspect the `.wasm` output
112of a CanvasKit build to detect the presence of [wasm SIMD](https://github.com/WebAssembly/simd)
113operations.
114
115# Infrastructure Playbook
116
117When dealing with CanvasKit (or PathKit) on our bots, we use Docker. Check out
118$SKIA_ROOT/infra/wasm-common/docker/README.md for more on building/editing the
119images used for building and testing.
120
121## Updating the version of Emscripten we build/test with
122
123This presumes you have updated emscripten locally to a newer version of the
124sdk and verified/fixed any build issues that have arisen.
125
126 1. Edit `//bin/activate-emsdk` to install and activate the desired version of Emscripten.
127 2. Upload a CL with all the changes. Run all Test.+CanvasKit, Perf.+Puppeteer,
128 Test.+PathKit, Perf.+PathKit jobs to make sure the new builds pass all
129 tests and don't crash the perf harnesses.
130 3. Send out CL for review. Feel free to point the reviewer at these steps.
131
132## Running Skia's GMs and Unit Tests against wasm+WebGL ##
133
134General Tips:
135 - Make use of the skip lists and start indexes in the run-wasm-gm-tests.html to focus in on
136 problematic tests.
137 - `Uncaught (in promise) RuntimeError: function signature mismatch` tends to mean null was
138 dereferenced somewhere. Add SkASSERT to verify.
139
140### Debugging some GMs / Unit Tests
141For faster cycle time, it is recommended to focus on specific GMs instead of re-compiling all
142of them. This can be done by modifying the `compile_gm.sh` script (but not checking this in)
143to set `GMS_TO_BUILD` and/or `TESTS_TO_BUILD` to a minimal set of files. There's an `if false`
144that can be commented out to assist with this.
145
146Run `make gm_tests` or `make_gm_tests_debug` from this folder. This will produce a .js and .wasm
147in a (not checked in) `build` subfolder.
148
149Run `make single-gm` and navigate to <http://localhost:8000/wasm_tools/gms.html>. This will load
150that html file and the freshly built wasm_gm_tests binary and run a single GM and unit test that
151was compiled in. Feel free to modify //modules/canvaskit/wasm_tools/gms.html to run the specific
152GM/unit test or tests that you care about.
153
154### Testing all GMs / Unit Tests
155With the current GN build, this can take quite a while to compile and re-compile (the upcoming
156Bazel build should alleviate this).
157
158Run `make gm_tests` or `make_gm_tests_debug` from this folder. This will produce a .js and .wasm
159in a (not checked in) `build` subfolder.
160
161Change directory to `//tools/run-wasm-gm-tests`. Run `make run_local`, which will put all PNGs
162produced by GMs into `/tmp/wasm-gmtests` and run all unit tests.
163