• Home
Name Date Size #Lines LOC

..--

external_test/03-May-2024-199182

fonts/03-May-2024-42

future_apis/03-May-2024-8157

go/gold_test_env/03-May-2024-222152

htmlcanvas/03-May-2024-2,2531,866

npm_build/03-May-2024-13,1959,191

tests/03-May-2024-7,3175,861

wasm_tools/03-May-2024-555293

.gitignoreD03-May-2024131 66

BUILD.bazelD03-May-20249.8 KiB350326

BUILD.gnD03-May-20249.9 KiB403375

CHANGELOG.mdD03-May-202449.4 KiB1,075858

MakefileD03-May-20246.7 KiB198158

README.mdD03-May-20247.2 KiB163117

WasmCommon.hD03-May-20244.1 KiB12780

canvaskit.gniD03-May-20241.4 KiB3632

canvaskit_bindings.cppD03-May-2024118.9 KiB2,4552,113

catchExceptionNop.jsD03-May-2024474 146

color.jsD03-May-20246.9 KiB203148

compile.shD03-May-20247.4 KiB261215

compile_gm.shD03-May-20246.7 KiB235181

cpu.jsD03-May-20244.8 KiB11473

debug.jsD03-May-202479 54

debugger.jsD03-May-20241 KiB2716

debugger_bindings.cppD03-May-202421.2 KiB531360

externs.jsD03-May-202431 KiB1,220984

font.jsD03-May-202412.5 KiB330251

gm.jsD03-May-20241.5 KiB5040

gm_bindings.cppD03-May-202412.8 KiB369271

interface.jsD03-May-202450.5 KiB1,306957

karma.bazel.jsD03-May-20241.6 KiB4822

karma.conf.jsD03-May-20243.1 KiB9548

matrix.jsD03-May-202417.4 KiB535383

memory.jsD03-May-202413.3 KiB396240

package-lock.jsonD03-May-2024133.3 KiB3,6843,683

package.jsonD03-May-2024460 2221

paragraph.jsD03-May-202415.4 KiB366292

paragraph_bindings.cppD03-May-202430.9 KiB738606

paragraph_bindings_gen.cppD03-May-20245.1 KiB10781

pathops.jsD03-May-2024439 1815

postamble.jsD03-May-2024127 31

preamble.jsD03-May-2024376 91

release.jsD03-May-2024205 63

rt_shader.jsD03-May-20242.4 KiB4929

skottie.jsD03-May-20245.2 KiB14596

skottie_bindings.cppD03-May-202414.8 KiB378298

skp.jsD03-May-2024594 1814

util.jsD03-May-2024370 1910

viewer_bindings.cppD03-May-20242.7 KiB7360

webgl.jsD03-May-202417.2 KiB399297

webgpu.jsD03-May-20245.6 KiB142107

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