skia-canvas icon indicating copy to clipboard operation
skia-canvas copied to clipboard

Error: internal error in Neon module: called `Option::unwrap()` on a `None` value

Open stoneyallen opened this issue 1 year ago • 1 comments

const ctx = canvas.getContext('2d');
canvas.gpu = false;
ctx.setTransform(0, 0, 0, 0, 154, 271.60133333333334);
ctx.beginPath();
ctx.arc(0, 0, 2, 0, 6.283185307179586);
ctx.closePath();
ctx.fill();

After executing the above statement, an error will be reported. When setTransform is deleted, the error will disappear.

stoneyallen avatar Sep 24 '23 04:09 stoneyallen

Did you mean to set the scaling terms to zero in your transform matrix?

I saw this recently also when trying to fill/stroke a path with an invalid transform.

The error comes from canvas/mod.rs @ 312 in draw_path() method due to the current transform not being invertable. Fix for error:

-      let inverse = self.state.matrix.invert().unwrap();
+      let inverse = self.state.matrix.invert().unwrap_or_default();

Though it still won't draw anything, just won't throw error 😉

mpaperno avatar Sep 28 '23 08:09 mpaperno