Skip to content

Animate svg using reanimate on Android causes memory pressure #2847

@yuzjia-work

Description

@yuzjia-work

Description

When use const deviceMotion = useAnimatedSensor(SensorType.ROTATION, { interval: "auto", }) to animate a RadialGradient using ReAnimate. Android has a significant amount of memory consumed caused by SvgView being invalid by the sensor data. And a new Bitmap is created on next onDraw.
See detailed call trace. GC runs every few seconds.

Image

Steps to reproduce

Use the useAnimatedSensor to drive a RadialGradient animation on Android

Example:
` const deviceMotion = useAnimatedSensor(SensorType.ROTATION, {
interval: "auto",
});
const derivedValue = useDerivedValue(() => {
return 0.5 * (Math.sin(deviceMotion.sensor.value.roll) + 1);
});

const animatedProps = useAnimatedProps(() => {
return {
cx: (derivedValue.value - 0.5) * 2.4,
fx: (derivedValue.value - 0.5) * 2.4,
};
});`

Snack or a link to a repository

https://snack.expo.io/

SVG version

13.10.0

React Native version

0.74.5

Platforms

Android

JavaScript runtime

Hermes

Workflow

React Native

Architecture

Fabric (New Architecture)

Build type

Release app & production bundle

Device

Real device

Device model

Google Pixel 10Pro

Acknowledgements

Yes

Metadata

Metadata

Assignees

No one assigned

    Labels

    Missing reproThis issue need minimum repro scenario

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions