From 3f08a2893e754a4f6577a8a9208097ffff2e826f Mon Sep 17 00:00:00 2001 From: Karim Naaji Date: Thu, 9 Apr 2020 07:47:02 -0700 Subject: [PATCH] Fix for issue 9518 (#9520) * Add regression test for https://github.com/mapbox/mapbox-gl-js/issues/9518 * More thorough input checks for isPatternMissing function Fixes regression introduced by https://github.com/mapbox/mapbox-gl-js/pull/9380 ResolvedImage.fromString may now return null, which potentially leaves CrossFaded with missing image patterns I have traced other code paths using ResolvedImage.fromString and have not seen any other potential offenders --- src/render/painter.js | 1 + .../mapbox-gl-js#9518/expected.png | Bin 0 -> 69 bytes .../regressions/mapbox-gl-js#9518/style.json | 27 ++++++++++++++++++ 3 files changed, 28 insertions(+) create mode 100644 test/integration/render-tests/regressions/mapbox-gl-js#9518/expected.png create mode 100644 test/integration/render-tests/regressions/mapbox-gl-js#9518/style.json diff --git a/src/render/painter.js b/src/render/painter.js index 32fbe08548b..165a1e6e91c 100644 --- a/src/render/painter.js +++ b/src/render/painter.js @@ -589,6 +589,7 @@ class Painter { */ isPatternMissing(image: ?CrossFaded): boolean { if (!image) return false; + if (!image.from || !image.to) return true; const imagePosA = this.imageManager.getPattern(image.from.toString()); const imagePosB = this.imageManager.getPattern(image.to.toString()); return !imagePosA || !imagePosB; diff --git a/test/integration/render-tests/regressions/mapbox-gl-js#9518/expected.png b/test/integration/render-tests/regressions/mapbox-gl-js#9518/expected.png new file mode 100644 index 0000000000000000000000000000000000000000..1ed60094c40c52c61d4fb681d534520df195e0af GIT binary patch literal 69 zcmeAS@N?(olHy`uVBq!ia0vp^93afW1|*O0@9PFqJf1F&Ar*|t608Xf42&EMjBQR= QMSzopr0CnFCO#lD@ literal 0 HcmV?d00001 diff --git a/test/integration/render-tests/regressions/mapbox-gl-js#9518/style.json b/test/integration/render-tests/regressions/mapbox-gl-js#9518/style.json new file mode 100644 index 00000000000..a7d66de5770 --- /dev/null +++ b/test/integration/render-tests/regressions/mapbox-gl-js#9518/style.json @@ -0,0 +1,27 @@ +{ + "version": 8, + "metadata": { + "test": { + "width": 8, + "height": 8 + } + }, + "zoom": 3, + "sources": {}, + "sprite": "local://sprites/emerald", + "layers": [ + { + "id": "background", + "type": "background", + "paint": { + "background-pattern": [ + "step", + ["zoom"], + "", + 5, + "cemetery_icon" + ] + } + } + ] +}