Skip to content

Memory usage only increases when a Canvas and Image are unmounted and remounted #3664

@monsterinacup

Description

@monsterinacup

Description

Hi,

I'm quite stumped by this and would truly appreciate some help!

I'm using expo 54.0.32 and react-native 0.81.5

I was having a memory issue in another app and have reduced it down to this issue.

When unmounting a Cavas with an Image inside it, memory does not appear to be released.
Speculatively, it appears that the underlying objects are not disposed/released and GC'ed.

I have tried with react-native-skia versions: 2.2.12, 2.2.15, 2.4.14, 2.4.15. I have tested with the jsc and hermes jsEngine and the newArchitecture enabled or disabled and I get the same behaviour.
I have tested on emulators and physical devices on Android and iOS and both suffer the same memory usage growth issue.

I have attemped to call dispose manually on SkImage objects and this did not change the behaviour.

Am I doing something wrong?

I have attached a reproduction repository and will attach the App.tsx file here.

Thanks!

App.tsx

React Native Skia Version

2.2.12, 2.2.15, 2.4.14, 2.4.15

React Native Version

0.81.5

Using New Architecture

  • Enabled

Steps to Reproduce

npm run android

Use physical device or emulator

Launch Android Studio, Profiler, Live Telemetry

Click the Show/Hide button in the app.

This will mount, unmount, remount etc the Canvas and Image.

Memory is not released, usage increases until the app crashes.

Snack, Code Example, Screenshot, or Link to Repository

https://github.com/monsterinacup/rn-skia-memory-usage-repro

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions