• Home
Name Date Size #Lines LOC

..--

external_test/03-May-2024-199182

fonts/03-May-2024-42

future_apis/03-May-2024-8157

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

npm_build/03-May-2024-10,2496,560

tests/03-May-2024-6,6885,356

wasm_tools/03-May-2024-529268

.gitignoreD03-May-2024131 66

BUILD.bazelD03-May-202411.7 KiB432406

BUILD.gnD03-May-20248.7 KiB359334

CHANGELOG.mdD03-May-202445.5 KiB974783

MakefileD03-May-20245.6 KiB160118

README.mdD03-May-20245.9 KiB139100

WasmCommon.hD03-May-20244.1 KiB12578

canvaskit.gniD03-May-20241.3 KiB3329

canvaskit_bindings.cppD03-May-2024106.3 KiB2,2191,912

catchExceptionNop.jsD03-May-2024474 146

color.jsD03-May-20246.9 KiB203148

compile.shD03-May-20246.8 KiB248201

compile_gm.shD03-May-20246.8 KiB236182

cpu.jsD03-May-20244.6 KiB10970

debug.jsD03-May-202479 54

externs.jsD03-May-202429.7 KiB1,182951

font.jsD03-May-202411.9 KiB316240

gm.jsD03-May-20241.5 KiB5040

gm_bindings.cppD03-May-202412.6 KiB364267

gpu.jsD03-May-202414.2 KiB333250

interface.jsD03-May-202448.9 KiB1,266923

karma.conf.jsD03-May-20243 KiB9448

karma.google3.conf.jsD03-May-20241.3 KiB2210

matrix.jsD03-May-202417.4 KiB535383

memory.jsD03-May-202413 KiB385231

package-lock.jsonD03-May-2024132.3 KiB3,6523,651

package.jsonD03-May-2024459 2221

paragraph.jsD03-May-202413 KiB312240

paragraph_bindings.cppD03-May-202425.5 KiB640512

paragraph_bindings_gen.cppD03-May-20244.9 KiB10277

particles.jsD03-May-20242.5 KiB7248

particles_bindings.cppD03-May-20246.5 KiB180139

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.2 KiB4527

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

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_particles 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 ##
133TODO(kjlubick)
134
135General Tips:
136 - Make use of the skip lists and start indexes in the run-wasm-gm-tests.html to focus in on
137   problematic tests.
138 - `Uncaught (in promise) RuntimeError: function signature mismatch` tends to mean null was
139   dereferenced somewhere. Add SkASSERT to verify.