fix(🐛): scale SkMatrix uniformly when y is omitted - #4016
Merged
wcandillon merged 5 commits intoAug 23, 2026
Conversation
SkMatrix.scale() and postScale() take an optional y. The CanvasKit backend falls back to x for a uniform scale, but the JSI bindings fell back to 1, so matrix.scale(0.5) halved only the x axis on iOS and Android while halving both on Web. The renderer's own "Scale with origin using a matrix" test pins the uniform result ([0.5, 0, 192, 0, 0.5, 192, 0, 0, 1]), but it runs on CanvasKit only, so the native path was never covered.
wcandillon
self-requested a review
August 22, 2026 09:05
wcandillon
requested changes
Aug 22, 2026
Contributor
There was a problem hiding this comment.
@dennytosp Thank You for catching this. Can you update the test to use:
const result = await surface.eval((Skia) => {
that way it will run both against native and canvaskit. In its current form it only runs against canvaskit.
Move it to renderer/__tests__/e2e and go through surface.eval, so the JSI bindings this fixes are actually exercised. As a plain unit test it only ever ran against CanvasKit, which was already correct.
Contributor
Author
|
@wcandillon good catch, thank you — I had missed that the unit spec never touched the JSI side at all. It goes through |
wcandillon
approved these changes
Aug 22, 2026
Contributor
|
🎉 This PR is included in version 2.11.1 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
SkMatrix.scale()andpostScale()declareyas optional:The two backends disagree on what omitting it means.
CanvasKit (
JsiSkMatrix.ts) falls back tox— a uniform scale:JSI (
JsiSkMatrix.h) falls back to1— the y axis is left untouched:So
matrix.scale(0.5)halves both axes on Web and only the x axis on iOS and Android.Which one is right
The renderer's own test pins the uniform result:
That spec is not under
e2e/, so it only ever runs against CanvasKit — which is why the native path was never covered. It also renders intosnapshots/transform/scale-origin.png, the same baseline thetransform={[{ scale: 0.5 }]}test uses, so the intent is unambiguous.Fix
Default
ytoxin the JSI bindings. Not a recent regression — the1default predates the typed-bindings refactor in 6c95fc6.Tests
packages/skia/src/skia/__tests__/Matrix.spec.tscoversscale,postScale, and the explicit two-argument form.To be upfront: this spec exercises the CanvasKit backend, so it passes on
maintoo — it pins the contract the JSI side now matches rather than reproducing the failure. I have no Skia build here to exerciseJsiSkMatrix.hdirectly, so the C++ side rests onSkMatrix::preScale/postScalesemantics and the expectation above. Worth a native run on your side before merging.Full suite green: 749 passed,
tsc --noEmitandeslint --max-warnings 0clean,clang-format -n -Werrorclean on the changed header.