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

Error while passing wasm file to Runtimeloader #308

Open
MatteoDirenzo opened this issue Apr 21, 2023 · 2 comments
Open

Error while passing wasm file to Runtimeloader #308

MatteoDirenzo opened this issue Apr 21, 2023 · 2 comments

Comments

@MatteoDirenzo
Copy link

MatteoDirenzo commented Apr 21, 2023

Hello everyone, i'm trying to preload rive.wasm file in my next.js project, but i keep getting a binding error in my Rive Component when using RuntimeLoader.setWasmUrl (the link preload in the head tag works fine)

import { useRive, RuntimeLoader, Layout, Fit, Alignment } from "@rive-app/react-canvas";
import riveWASMResource from "@rive-app/canvas/rive.wasm";

RuntimeLoader.setWasmUrl(riveWASMResource);

export const RiveComp = ({  src, artboard, stateMachines, autoplay, ...rest}) => {
  const base_url = process.env.NEXT_PUBLIC_BASE_URL;
  
  const { rive, RiveComponent } = useRive({
      src: `${base_url}${src}.riv`, 
      artboard: artboard,
      stateMachines: stateMachines,
      layout: new Layout({ fit: Fit.Cover }), 
      autoplay: autoplay,
    });
  
  return <RiveComponent {...rest} />
}

I followed the documentation about preloading the wasm file but i keep getting the same error, maybe i'm doing something wrong (when i log my wasm file its the right one and the preload works fine, the problem is related to this RuntimeLoader)

Screenshot 2023-04-21 at 15 23 19

@MatteoDirenzo
Copy link
Author

MatteoDirenzo commented Apr 21, 2023

I fixed it for now, but i don't know if it's the right solution, the import was incorrect.
this one worked for me

import riveWASMResource from "@rive-app/react-canvas/node_modules/@rive-app/canvas/rive.wasm";

@Prasanna-kumar-Patra
Copy link

fixed by changing the url in rive.js file
RuntimeLoader.wasmURL = "./rive.wasm";

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

2 participants