rive-app / rive-app/rive-react

Canvas memory leak in Safari

Open
#440 5 comments 4 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
1.2k
Forks
58
Avg merge
3h 23m
Merged PRs (30d)
6

Description

Submission checklist
  • I have confirmed the issue is present in the latest version of @rive-app/react-canvas or @rive-app/react-webgl2 (or the renderer variant I'm using)
  • I have searched the documentation and forums and could not find an answer
  • I have searched existing issues and this is not a duplicate
Description

We are finding instances in our app of dangling references to canvas elements after rive elements have been unmounted. This is causing a growing memory problem that gets worse over time. It's definitely an issue in safari, possibly an issue in chromium based browsers but more difficult to reproduce.

I've created a repo that makes this reproducible - by mounting and un-mounting the rive component about 100 times I end up with two or three extra canvas elements in the memory snapshot. In our actual app with multiple different animations on various routes, we can sometimes see 10s or 100s of canvas elements accruing over time. With large animations this puts a real strain on memory and performance.

https://github.com/melodicdan/rive-memory-leak

Image Image
Reproduction steps / code

https://github.com/melodicdan/rive-memory-leak

Atached are two heap snapshots, one with the single mounted canvas element and one after re-mounting ~100 times

Upload your reproduction files / stack trace

heap snapshot 1.json
heap snapshot 2.json

Rive React package version

"@rive-app/react-canvas": "^4.33.0",

Source .riv / .rev file

No response

Screenshots / video

No response

Browser & version

Safari 26.0.1

Operating system & version

macOS 15.7.1

Additional context

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked rive-memory-leak reproduction and compare the heap snapshots after repeatedly mounting and unmounting @rive-app/react-canvas. Trace the canvas references retained by the React package in Safari; done means repeated remounts no longer leave extra canvas elements accumulating in memory.

Written by the indexing model from the issue text.

Assessment

Tech stack
react, typescript
Domain
frontend, performance
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.