diff --git a/docker/skia-build-tools/Dockerfile b/docker/skia-build-tools/Dockerfile index 085095a317..e081f37bfa 100644 --- a/docker/skia-build-tools/Dockerfile +++ b/docker/skia-build-tools/Dockerfile @@ -11,6 +11,7 @@ RUN apt-get update && apt-get upgrade -y && apt-get install -y \ && groupadd -g 2000 skia \ && useradd -u 2000 -g 2000 skia +# TODO(kjlubick): Try a shallow clone of depot_tools RUN cd /tmp \ && git clone 'https://chromium.googlesource.com/chromium/tools/depot_tools.git' diff --git a/infra/bots/recipe_modules/build/canvaskit.py b/infra/bots/recipe_modules/build/canvaskit.py index 0a8f1867e4..d04b03b532 100644 --- a/infra/bots/recipe_modules/build/canvaskit.py +++ b/infra/bots/recipe_modules/build/canvaskit.py @@ -2,7 +2,7 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. -DOCKER_IMAGE = 'gcr.io/skia-public/canvaskit-emsdk:1.38.47_v1' +DOCKER_IMAGE = 'gcr.io/skia-public/canvaskit-emsdk:1.39.6_v1' INNER_BUILD_SCRIPT = '/SRC/skia/infra/canvaskit/build_canvaskit.sh' diff --git a/infra/bots/recipe_modules/build/examples/full.expected/Build-Debian9-EMCC-asmjs-Debug-PathKit.json b/infra/bots/recipe_modules/build/examples/full.expected/Build-Debian9-EMCC-asmjs-Debug-PathKit.json index 261f879457..b5a713637d 100644 --- a/infra/bots/recipe_modules/build/examples/full.expected/Build-Debian9-EMCC-asmjs-Debug-PathKit.json +++ b/infra/bots/recipe_modules/build/examples/full.expected/Build-Debian9-EMCC-asmjs-Debug-PathKit.json @@ -23,7 +23,7 @@ "[START_DIR]/cache/work:/SRC", "--volume", "[START_DIR]/cache/docker/pathkit:/OUT", - "gcr.io/skia-public/emsdk-base:1.38.47_v1", + "gcr.io/skia-public/emsdk-base:1.39.6_v1", "/SRC/skia/infra/pathkit/build_pathkit.sh", "debug", "asm.js" diff --git a/infra/bots/recipe_modules/build/examples/full.expected/Build-Debian9-EMCC-asmjs-Release-PathKit.json b/infra/bots/recipe_modules/build/examples/full.expected/Build-Debian9-EMCC-asmjs-Release-PathKit.json index f02b19320d..b4afc8d802 100644 --- a/infra/bots/recipe_modules/build/examples/full.expected/Build-Debian9-EMCC-asmjs-Release-PathKit.json +++ b/infra/bots/recipe_modules/build/examples/full.expected/Build-Debian9-EMCC-asmjs-Release-PathKit.json @@ -23,7 +23,7 @@ "[START_DIR]/cache/work:/SRC", "--volume", "[START_DIR]/cache/docker/pathkit:/OUT", - "gcr.io/skia-public/emsdk-base:1.38.47_v1", + "gcr.io/skia-public/emsdk-base:1.39.6_v1", "/SRC/skia/infra/pathkit/build_pathkit.sh", "asm.js" ], diff --git a/infra/bots/recipe_modules/build/examples/full.expected/Build-Debian9-EMCC-wasm-Debug-CanvasKit.json b/infra/bots/recipe_modules/build/examples/full.expected/Build-Debian9-EMCC-wasm-Debug-CanvasKit.json index 99b6feaea3..69b66f56ae 100644 --- a/infra/bots/recipe_modules/build/examples/full.expected/Build-Debian9-EMCC-wasm-Debug-CanvasKit.json +++ b/infra/bots/recipe_modules/build/examples/full.expected/Build-Debian9-EMCC-wasm-Debug-CanvasKit.json @@ -23,7 +23,7 @@ "[START_DIR]/cache/work:/SRC", "--volume", "[START_DIR]/cache/docker/canvaskit:/OUT", - "gcr.io/skia-public/canvaskit-emsdk:1.38.47_v1", + "gcr.io/skia-public/canvaskit-emsdk:1.39.6_v1", "/SRC/skia/infra/canvaskit/build_canvaskit.sh", "debug" ], diff --git a/infra/bots/recipe_modules/build/examples/full.expected/Build-Debian9-EMCC-wasm-Debug-PathKit.json b/infra/bots/recipe_modules/build/examples/full.expected/Build-Debian9-EMCC-wasm-Debug-PathKit.json index 432e6e7f5c..12b0ceaed7 100644 --- a/infra/bots/recipe_modules/build/examples/full.expected/Build-Debian9-EMCC-wasm-Debug-PathKit.json +++ b/infra/bots/recipe_modules/build/examples/full.expected/Build-Debian9-EMCC-wasm-Debug-PathKit.json @@ -23,7 +23,7 @@ "[START_DIR]/cache/work:/SRC", "--volume", "[START_DIR]/cache/docker/pathkit:/OUT", - "gcr.io/skia-public/emsdk-base:1.38.47_v1", + "gcr.io/skia-public/emsdk-base:1.39.6_v1", "/SRC/skia/infra/pathkit/build_pathkit.sh", "debug" ], diff --git a/infra/bots/recipe_modules/build/examples/full.expected/Build-Debian9-EMCC-wasm-Release-CanvasKit_CPU.json b/infra/bots/recipe_modules/build/examples/full.expected/Build-Debian9-EMCC-wasm-Release-CanvasKit_CPU.json index 29e50b5c19..ca8510c35d 100644 --- a/infra/bots/recipe_modules/build/examples/full.expected/Build-Debian9-EMCC-wasm-Release-CanvasKit_CPU.json +++ b/infra/bots/recipe_modules/build/examples/full.expected/Build-Debian9-EMCC-wasm-Release-CanvasKit_CPU.json @@ -23,7 +23,7 @@ "[START_DIR]/cache/work:/SRC", "--volume", "[START_DIR]/cache/docker/canvaskit:/OUT", - "gcr.io/skia-public/canvaskit-emsdk:1.38.47_v1", + "gcr.io/skia-public/canvaskit-emsdk:1.39.6_v1", "/SRC/skia/infra/canvaskit/build_canvaskit.sh", "cpu" ], diff --git a/infra/bots/recipe_modules/build/examples/full.expected/Build-Debian9-EMCC-wasm-Release-PathKit.json b/infra/bots/recipe_modules/build/examples/full.expected/Build-Debian9-EMCC-wasm-Release-PathKit.json index b9c007172a..aec107dd13 100644 --- a/infra/bots/recipe_modules/build/examples/full.expected/Build-Debian9-EMCC-wasm-Release-PathKit.json +++ b/infra/bots/recipe_modules/build/examples/full.expected/Build-Debian9-EMCC-wasm-Release-PathKit.json @@ -23,7 +23,7 @@ "[START_DIR]/cache/work:/SRC", "--volume", "[START_DIR]/cache/docker/pathkit:/OUT", - "gcr.io/skia-public/emsdk-base:1.38.47_v1", + "gcr.io/skia-public/emsdk-base:1.39.6_v1", "/SRC/skia/infra/pathkit/build_pathkit.sh" ], "env": { diff --git a/infra/bots/recipe_modules/build/pathkit.py b/infra/bots/recipe_modules/build/pathkit.py index 01acae8dad..82dbca3749 100644 --- a/infra/bots/recipe_modules/build/pathkit.py +++ b/infra/bots/recipe_modules/build/pathkit.py @@ -2,7 +2,7 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. -DOCKER_IMAGE = 'gcr.io/skia-public/emsdk-base:1.38.47_v1' +DOCKER_IMAGE = 'gcr.io/skia-public/emsdk-base:1.39.6_v1' INNER_BUILD_SCRIPT = '/SRC/skia/infra/pathkit/build_pathkit.sh' def compile_fn(api, checkout_root, _ignore): diff --git a/infra/canvaskit/build_canvaskit.sh b/infra/canvaskit/build_canvaskit.sh index c7daddecd9..fffc6653b9 100755 --- a/infra/canvaskit/build_canvaskit.sh +++ b/infra/canvaskit/build_canvaskit.sh @@ -9,7 +9,7 @@ # is mounted at /OUT # For example: -# docker run -v $SKIA_ROOT:/SRC -v $SKIA_ROOT/out/canvaskit:/OUT gcr.io/skia-public/emsdk-base:1.38.47_v1 /SRC/infra/canvaskit/build_canvaskit.sh +# docker run -v $SKIA_ROOT:/SRC -v $SKIA_ROOT/out/canvaskit:/OUT gcr.io/skia-public/emsdk-base:1.39.6_v1 /SRC/infra/canvaskit/build_canvaskit.sh set +e set -x diff --git a/infra/canvaskit/docker/Makefile b/infra/canvaskit/docker/Makefile index 453230e86f..e5a2bfae6a 100644 --- a/infra/canvaskit/docker/Makefile +++ b/infra/canvaskit/docker/Makefile @@ -1,4 +1,4 @@ -EMSDK_VERSION=1.38.47_v1 +EMSDK_VERSION=1.39.6_v1 publish_canvaskit_emsdk: docker build -t canvaskit-emsdk ./canvaskit-emsdk/ diff --git a/infra/canvaskit/docker/canvaskit-emsdk/Dockerfile b/infra/canvaskit/docker/canvaskit-emsdk/Dockerfile index 6abd49f4f8..27658f4c9c 100644 --- a/infra/canvaskit/docker/canvaskit-emsdk/Dockerfile +++ b/infra/canvaskit/docker/canvaskit-emsdk/Dockerfile @@ -1,7 +1,7 @@ # A Docker image that augments the Emscripten SDK Docker image # with anything needed to build Canvaskit -FROM gcr.io/skia-public/emsdk-base:1.38.47_v1 +FROM gcr.io/skia-public/emsdk-base:1.39.6_v1 RUN apt-get update && apt-get upgrade -y && apt-get install -y \ libfreetype6-dev \ No newline at end of file diff --git a/infra/pathkit/build_pathkit.sh b/infra/pathkit/build_pathkit.sh index ad9ee730c2..b644f2cc15 100755 --- a/infra/pathkit/build_pathkit.sh +++ b/infra/pathkit/build_pathkit.sh @@ -9,7 +9,7 @@ # is mounted at /OUT # For example: -# docker run -v $SKIA_ROOT:/SRC -v $SKIA_ROOT/out/dockerpathkit:/OUT gcr.io/skia-public/emsdk-base:1.38.47_v1 /SRC/infra/pathkit/build_pathkit.sh +# docker run -v $SKIA_ROOT:/SRC -v $SKIA_ROOT/out/dockerpathkit:/OUT gcr.io/skia-public/emsdk-base:1.39.6_v1 /SRC/infra/pathkit/build_pathkit.sh set +e set -x diff --git a/infra/wasm-common/docker/Makefile b/infra/wasm-common/docker/Makefile index 4f75f21017..d47d2c6efc 100644 --- a/infra/wasm-common/docker/Makefile +++ b/infra/wasm-common/docker/Makefile @@ -1,4 +1,4 @@ -EMSDK_VERSION=1.38.47_v1 +EMSDK_VERSION=1.39.6_v1 # Can check CHROME_VERSION with # docker run karma-chrome-tests /usr/bin/google-chrome-stable --version diff --git a/infra/wasm-common/docker/emsdk-base/Dockerfile b/infra/wasm-common/docker/emsdk-base/Dockerfile index e0e9a7a8fa..27c0829796 100644 --- a/infra/wasm-common/docker/emsdk-base/Dockerfile +++ b/infra/wasm-common/docker/emsdk-base/Dockerfile @@ -1,11 +1,14 @@ # A Docker image that has the Emscripten SDK installed to /opt/emsdk # Use this image to compile C/C++ code to WASM. +# It has the Java Runtime to allow the use of the Closure JS compiler/minifier. +# TODO(kjlubick): add an ARG to make it easier to pass in the version number. FROM gcr.io/skia-public/skia-build-tools:latest RUN apt-get update && apt-get upgrade -y && apt-get install -y \ nodejs \ default-jre +# TODO(kjlubick): Try a shallow clone RUN cd /opt \ && git clone https://github.com/emscripten-core/emsdk.git @@ -13,9 +16,9 @@ WORKDIR /opt/emsdk RUN ./emsdk update-tags -RUN ./emsdk install sdk-1.38.47-64bit +RUN ./emsdk install sdk-1.39.6-64bit -RUN ./emsdk activate sdk-1.38.47-64bit +RUN ./emsdk activate sdk-1.39.6-64bit RUN /bin/bash -c "source ./emsdk_env.sh" diff --git a/modules/canvaskit/CHANGELOG.md b/modules/canvaskit/CHANGELOG.md index a7f446f787..d84035c5b8 100644 --- a/modules/canvaskit/CHANGELOG.md +++ b/modules/canvaskit/CHANGELOG.md @@ -9,6 +9,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - `SkSurface.drawOnce` for drawing a single frame (in addition to already existing `SkSurface.requestAnimationFrame` for animation logic). +### Changed + - We now compile/ship with Emscripten v1.39.6. + ## [0.12.0] - 2020-01-22 ### Added diff --git a/modules/canvaskit/Makefile b/modules/canvaskit/Makefile index 4202004ecb..4159969b73 100644 --- a/modules/canvaskit/Makefile +++ b/modules/canvaskit/Makefile @@ -72,5 +72,5 @@ docker-compile: mkdir -p ${SKIA_ROOT}/out/canvaskit_wasm_docker docker run --rm --volume ${SKIA_ROOT}:/SRC \ --volume ${SKIA_ROOT}/out/canvaskit_wasm_docker:/OUT \ - gcr.io/skia-public/canvaskit-emsdk:1.38.27_v1 \ + gcr.io/skia-public/canvaskit-emsdk:1.39.6_v1 \ /SRC/infra/canvaskit/build_canvaskit.sh diff --git a/modules/canvaskit/README.md b/modules/canvaskit/README.md index f260b71183..32e5e1097d 100644 --- a/modules/canvaskit/README.md +++ b/modules/canvaskit/README.md @@ -7,7 +7,7 @@ compilation. # Compile and Test Locally ``` -make release +make release # make debug is much faster and has better error messages make local-example ``` @@ -24,3 +24,41 @@ any of the "extras", one might run: Such a stripped-down version is about half the size of the default release build. [1]: https://emscripten.org/docs/getting_started/downloads.html + + +# Infrastructure Playbook + +When dealing with CanvasKit (or PathKit) on our bots, we use Docker. Check out +$SKIA_ROOT/infra/wasm-common/docker/README.md for more on building/editing the +images used for building and testing. + +## Updating the version of Emscripten we build/test with + +This presumes you have updated emscripten locally to a newer version of the +sdk and verified/fixed any build issues that have arisen. + + 1. Edit `$SKIA_ROOT/infra/wasm-common/docker/emsdk-base/Dockerfile` to install + and activate the desired version of Emscripten. + 2. Edit `$SKIA_ROOT/infra/wasm-common/docker/Makefile` to have `EMSDK_VERSION` be + set to that desired version. If there is a suffix that is not `_v1`, reset + it to be `_v1`. If testing the image later does not work and edits are made + to the emsdk-base Dockerfile to correct that, increment to `_v2`,`_v3`, etc + to force the bots to pick up the new image. + 3. In `$SKIA_ROOT/infra/wasm-common/docker/`, run `make publish_emsdk_base` + 4. Edit `$SKIA_ROOT/infra/canvaskit/docker/canvaskit-emsdk/Dockerfile` to be based + off the new version from step 2. CanvasKit has its own docker image because + it needs a few extra dependencies to build with font support. + 5. Edit `$SKIA_ROOT/infra/canvaskit/docker/Makefile` to have the same version + from step 2. It's easiest to keep the `emsdk-base` and `canvaskit-emsdk` versions + be in lock-step. + 6. In `$SKIA_ROOT/infra/canvaskit/docker/`, make `publish_canvaskit_emsdk`. + 7. In `$SKIA_ROOT/infra/bots/recipe_modules/build/`, update `canvaskit.py` + and `pathkit.py` to have `DOCKER_IMAAGE` point to the desired tagged Docker + containers from steps 2 and 5 (which should be the same). + 9. In `$SKIA_ROOT/infra/bots/`, run `make train` to re-train the recipes. + 10. Optional: Run something like `git grep 1\\.38\\.` in `$SKIA_ROOT` to see if + there are any other references that need updating. + 11. Upload a CL with all the changes. Run all Test.+CanvasKit, Perf.+CanvasKit, + Test.+PathKit, Perf.+PathKit jobs to make sure the new builds pass all + tests and don't crash the perf harnesses. + 12. Send out CL for review. Feel free to point the reviewer at these steps. \ No newline at end of file diff --git a/modules/canvaskit/compile.sh b/modules/canvaskit/compile.sh index 3dd6c3c793..fe8a660ca8 100755 --- a/modules/canvaskit/compile.sh +++ b/modules/canvaskit/compile.sh @@ -212,9 +212,10 @@ echo "Compiling bitcode" cxx=\"${EMCXX}\" \ ar=\"${EMAR}\" \ extra_cflags_cc=[\"-frtti\"] \ - extra_cflags=[\"-s\", \"WARN_UNALIGNED=1\", + extra_cflags=[\"-s\", \"WARN_UNALIGNED=1\", \"-s\", \"MAIN_MODULE=1\", \"-DSKNX_NO_SIMD\", \"-DSK_DISABLE_AAA\", \"-DSK_DISABLE_EFFECT_DESERIALIZATION\", + \"-DSK_FORCE_8_BYTE_ALIGNMENT\", ${GN_GPU_FLAGS} ${GN_SKP_FLAGS} ${EXTRA_CFLAGS} @@ -275,12 +276,13 @@ ${EMCXX} \ -Ithird_party/skcms \ -Ithird_party/externals/icu/source/common/ \ -DSK_DISABLE_AAA \ + -DSK_FORCE_8_BYTE_ALIGNMENT \ $WASM_GPU \ $WASM_PATHOPS \ $WASM_RT_SHADER \ $WASM_SKP \ $FONT_CFLAGS \ - -std=c++14 \ + -std=c++17 \ --bind \ --pre-js $BASE_DIR/preamble.js \ --pre-js $BASE_DIR/helper.js \ diff --git a/modules/pathkit/CHANGELOG.md b/modules/pathkit/CHANGELOG.md index 9a9ff50e3e..dc0b62811c 100644 --- a/modules/pathkit/CHANGELOG.md +++ b/modules/pathkit/CHANGELOG.md @@ -7,7 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] ### Changed - - Updated to emscripten 1.38.47 + - Updated to emscripten 1.39.6 ## [0.6.0] 2019-02-25 diff --git a/modules/pathkit/compile.sh b/modules/pathkit/compile.sh index 9f1bdbb6a8..fbf8aa0751 100755 --- a/modules/pathkit/compile.sh +++ b/modules/pathkit/compile.sh @@ -10,6 +10,9 @@ BASE_DIR=`cd $(dirname ${BASH_SOURCE[0]}) && pwd` HTML_SHELL=$BASE_DIR/shell.html BUILD_DIR=${BUILD_DIR:="out/pathkit"} mkdir -p $BUILD_DIR +# sometimes the .a files keep old symbols around - cleaning them out makes sure +# we get a fresh build. +rm -f $BUILD_DIR/*.a # This expects the environment variable EMSDK to be set if [[ ! -d $EMSDK ]]; then @@ -73,7 +76,7 @@ OUTPUT="-o $BUILD_DIR/pathkit.js" source $EMSDK/emsdk_env.sh EMCC=`which emcc` EMCXX=`which em++` - +EMAR=`which emar` # Turn off exiting while we check for ninja (which may not be on PATH) set +e @@ -91,7 +94,9 @@ echo "Compiling bitcode" ./bin/gn gen ${BUILD_DIR} \ --args="cc=\"${EMCC}\" \ cxx=\"${EMCXX}\" \ + ar=\"${EMAR}\" \ extra_cflags=[\"-DSK_DISABLE_READBUFFER=1\",\"-s\", \"WARN_UNALIGNED=1\", + \"-s\", \"MAIN_MODULE=1\", ${EXTRA_CFLAGS} ] \ is_debug=false \ @@ -104,10 +109,8 @@ ${NINJA} -C ${BUILD_DIR} libpathkit.a echo "Generating WASM" -${EMCXX} $RELEASE_CONF -std=c++14 \ +${EMCXX} $RELEASE_CONF -std=c++17 \ -I. \ --Ithird_party/skcms \ --std=c++14 \ --bind \ --pre-js $BASE_DIR/helper.js \ --pre-js $BASE_DIR/chaining.js \ diff --git a/src/gpu/GrMemoryPool.h b/src/gpu/GrMemoryPool.h index 5e063e4da6..e487b04d4e 100644 --- a/src/gpu/GrMemoryPool.h +++ b/src/gpu/GrMemoryPool.h @@ -26,8 +26,17 @@ */ class GrMemoryPool { public: +#ifdef SK_FORCE_8_BYTE_ALIGNMENT + // This is an issue for WASM builds using emscripten, which had + // std::max_align_t = 16, but was returning pointers only aligned to 8 + // bytes. https://github.com/emscripten-core/emscripten/issues/10072 + // Since Skia does not use "long double" (16 bytes), we should be ok to + // force it back to 8 bytes until emscripten is fixed. + static constexpr size_t kAlignment = 8; +#else // Guaranteed alignment of pointer returned by allocate(). static constexpr size_t kAlignment = alignof(std::max_align_t); +#endif // Minimum size this class will allocate at once. static constexpr size_t kMinAllocationSize = 1 << 10; diff --git a/src/shaders/SkImageShader.cpp b/src/shaders/SkImageShader.cpp index 2e3bba5332..b8fd426e13 100755 --- a/src/shaders/SkImageShader.cpp +++ b/src/shaders/SkImageShader.cpp @@ -89,7 +89,7 @@ static bool legacy_shader_can_handle(const SkMatrix& inv) { const SkRect src = inv.mapRect(SkRect::MakeWH(max_dev_coord, max_dev_coord)); // take 1/4 of max signed 32bits so we have room to subtract local values - const SkScalar max_fixed32dot32 = SK_MaxS32 * 0.25f; + const SkScalar max_fixed32dot32 = float(SK_MaxS32) * 0.25f; if (!SkRect::MakeLTRB(-max_fixed32dot32, -max_fixed32dot32, +max_fixed32dot32, +max_fixed32dot32).contains(src)) { return false;