Incorrect texture resolution allocation when RiveAnimation is wrapped in Transform.rotate (reads ...

When using the rive Flutter package (version ^0.14.5 with the new C++ rive_native backend), wrapping a RiveAnimation widget inside a Transform.rotate causes severe rendering degradation. Depending on the rotation angle, the asset renders extremely blurry or as a black placeholder box.

Root Cause: The issue is located in rive_native_ffi.dart (around lines 954–965). The paint method calculates the global width scale for the native texture allocation by extracting entry(0, 0) from the transform matrix:

final currentTransformTo = getTransformTo(null);      
final newWidthScale = currentTransformTo.entry(0, 0).abs(); 

While this works for scaling matrices, for a rotation matrix with angle $\theta$, entry(0,0) represents cos(θ). The allocated texture size is therefore incorrectly multiplied by the cosine of the rotation angle.

Observable Behavior (e.g., at devicePixelRatio = 3.0):

  • Rotation 0°: cos(0) = 1.0 -> Texture allocated at full size (renders crisp).

  • Rotation 60°: cos(60) = 0.5 -> Texture allocated at 50% size (renders visibly blurry).

  • Rotation 90°: cos(90) = 0.0 -> Texture allocated at 0x0 px (renders as a black box).

Workaround:

Currently, developers must completely avoid using Transform.rotate anywhere in the ancestor chain of a RiveAnimation.

Suggested Fix:

Extract the actual scale factor using proper matrix decomposition instead of directly reading entry(0,0) to ensure that layout rotations do not dynamically destroy the allocated texture resolution.