Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Low-level API WebGL nonexistent cleanup function #368

Open
joncardasis opened this issue Sep 5, 2024 · 1 comment
Open

Low-level API WebGL nonexistent cleanup function #368

joncardasis opened this issue Sep 5, 2024 · 1 comment

Comments

@joncardasis
Copy link
Contributor

Description

The @rive-app/webgl2-advanced@2.20.0 renderer (and other webgl renderers) exposes a cleanup function in .d.ts but errors when called: 'rive.cleanup' is not a function. See Repro section for an example usage.

It appears as though the wasm/js/*renderer.js files do not set a Module["cleanup"] function. console.log(Object.keys(rive)) does not contain any reference of cleanup.

This inability to cleanup the wasm allocations leads to memory leaks.

Provide a Repro

import Rive, {AABB, RiveCanvas, SMIInput} from '@rive-app/webgl2-advanced'

const rive = await Rive({
    locateFile: () =>
      `https://unpkg.com/@rive-app/webgl2-advanced@2.20.0/rive.wasm`,
  })
const bytes = await (await fetch(new Request(url))).arrayBuffer()
const file = await rive.load(new Uint8Array(bytes))

const renderer = rive.makeRenderer(canvas, !isFirefox())
const artboard = file.artboardByName("file-artboard-name")

function renderLoop(time: DOMHighResTimeStamp) {
  ...
}

requestFrameId = rive.requestAnimationFrame(renderLoop)

return {
  cleanup: function () { 
    rive.cleanup()
  }
}
@joncardasis
Copy link
Contributor Author

Also to note that https://rive.app/community/doc/low-level-api-usage/doctAfBY6v3P#cleaning-up-instances outlines deleting resources manually, however, renderer.delete(); also throws an error where delete is not a function on the webgl2 renderer.

renderer.delete();  // Error – renderer.delete is not a function
file.delete();
artboard.delete();
animation.delete();
stateMachine.delete();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant