Description
There appears to have been a regression in the behaviour of canvas onSize at some point between 2.2.12 and 2.6.2, specifically when the canvas is itself transformed. The width and height supplied by onSize appear to use the size on-screen after the transform has been applied, rather than its "natural" layout size as rendered. This causes anything that is drawn using the canvas size as input to be drawn at the wrong size when there is a canvas transform applied.
React Native Skia Version
2.6.2
React Native Version
0.81.5
Using New Architecture
Steps to Reproduce
Apply a scale transformation to the canvas (either directly or via a parent view), then render a <Rect> with the width and height from the canvas size.
The expected behaviour in the code below is that the red <Rect> fills the canvas and the view behind it (so that no blue appears). However, it renders at half size.
const size = useSharedValue({ width: 0, height: 0 });
const width = useDerivedValue(() => size.value.width);
const height = useDerivedValue(() => size.value.height);
return (
<View style={{transform: [{ scale: 0.5, backgroundColor: 'blue' }]}}>
<Canvas style={{ flex: 1 }} onSize={size}>
<Rect
x={0}
y={0}
width={width}
height={height}
color="red"
style="fill"
></Rect>
</Canvas>
</View>
);
Snack, Code Example, Screenshot, or Link to Repository
The example above can be checked out from https://github.com/donaldharvey/react-native-skia-canvas-size-regression.
Behaviour in 2.6.2:
Behaviour in 2.2.12:

Description
There appears to have been a regression in the behaviour of canvas
onSizeat some point between 2.2.12 and 2.6.2, specifically when the canvas is itself transformed. The width and height supplied byonSizeappear to use the size on-screen after the transform has been applied, rather than its "natural" layout size as rendered. This causes anything that is drawn using the canvas size as input to be drawn at the wrong size when there is a canvas transform applied.React Native Skia Version
2.6.2
React Native Version
0.81.5
Using New Architecture
Steps to Reproduce
Apply a scale transformation to the canvas (either directly or via a parent view), then render a
<Rect>with the width and height from the canvas size.The expected behaviour in the code below is that the red
<Rect>fills the canvas and the view behind it (so that no blue appears). However, it renders at half size.Snack, Code Example, Screenshot, or Link to Repository
The example above can be checked out from https://github.com/donaldharvey/react-native-skia-canvas-size-regression.
Behaviour in 2.6.2:
Behaviour in 2.2.12: