Skip to main content
D
11mo ago

PNG in rive.riv throws errors

Hello, I am new to Rive and I was wondering if someone could help me out? I have a problem with using a file.riv in my JavaScript. I use a file.riv file that uses a PNG image, but I get the following error when I run my code:

Invalid artboard name or no default artboard and
Uncaught TypeError: Cannot read properties of undefined (reading 'animations')

This makes it that I cannot see my rive art in my webpage. I tried to solve this by explicitly inputting the artboard with the following code (now commented out), but that did not work:

const r = new rive.Rive({
src: "./rive.riv",
canvas: document.getElementById('canvas'),
// artboard: 'Person',
autoplay: true,
stateMachines: 'State Machine 1',
fit: rive.Fit.cover
});

The error does not occur when I do not use imported assets, and this problem also does not occur when I use a SVG file. I thought that png/jpg images used up too much memory, but I used a super small one and it still didn't work. Do you have any suggestions?

I use Windows and the webpage is on Chrome.

4 replies
C
D
C
11mo ago

Hi If you can share your .rev or .riv (.rev is preferred) that contains the PNGs with Support we can take a look.

D
11mo ago

Thank you. Please find them in this repo alongside the code: https://github.com/dbecu/rive-test
Here's also the rive editor: https://rive.app/community/files/10415-19875-rive-test
The only thing that makes the error is having that hat in the hierarchy

C
11mo ago

Hi Looks like you're using our old rive-js package (from ~2 years ago). Please take a look at our JS/WASM runtime docs for how to use our latest package.

D
11mo ago

Yes, I changed it and it works now. Thank you very much for your help!