rive-app / rive-wasm

Wasm/JS runtime for Rive
MIT License
660 stars 46 forks source link

[Console Error] Cannot read properties of null #318

Open ecenazelverdi opened 1 year ago

ecenazelverdi commented 1 year ago

image There was a time when I needed to render the animation too much and keep calling the cleanup function but this caused a console error. I tried to use cleanupInstance but it sends another console just by rendering the element once. image There was nothing in the document that addressed this issue and this console error keeps popping. I tried to use eventCleanup not to cause a console error but this causes a memory leak for looped rive animations (noninteractive ones), causing the page to crash. I use Vue2, and these clean functions in the destroyed() hook. (I use version 1.1.8)

zplata commented 1 year ago

Hi @EE539 - do you have a reproducible sandbox you can provide with this scenario so it can be triaged further? Curious if cleanup() is being called twice on the same Rive instance.

ecenazelverdi commented 1 year ago

Hello, I fixed my problem using these functions:
destroyed() { this.rive?.stopRendering(); this.rive?.cleanupInstances(); }, I'm using Vue2, the problem is that when I change something non-stop (because of the way the system was created), our page renders itself (not like F5 or CTRL+shift+R, it just re-renders every element it has). So if anything about an element changes (for example, color), it re-renders every element again. Doing this too much (like changing the color of the element nonstop) created this issue. But when I used stopRendering and cleanupInstances together instead of the cleanup() function, these console errors perished. I don't really know why though. cleanup() also has these functions so I didn't understand what was causing this error (Maybe deleting rive files before it's created but this error comes from the Draw function so I am not sure). I was also wondering if using stopRendering function causes any trouble with the way I used it! (The problem is basically when I create and remove it too fast, and if I am also using the cleanup function, these console errors show up)