Shopify / react-native-skia

High-performance React Native Graphics using Skia
https://shopify.github.io/react-native-skia
MIT License
6.98k stars 452 forks source link

`WithSkiaWeb` crashing when props are updated #2715

Closed santitopo closed 2 weeks ago

santitopo commented 3 weeks ago

Description

I've been trying to use react-native-skia in my RN web project WITHOUT the deferred registration approach (We can't afford to increase the app loading time because our users often use the app in low-connectivity areas), and I'm seeing the following issue when a prop passed to a component using WithSkiaWeb via componentProps gets updated: Cannot read properties of null (reading 'rangeMin').

image

The issue doesn't happen if skia is loaded up front with the deferred load approach (LoadSkiaWeb), so I guess it must be related to some internal logic of the WithSkiaWeb util.

It's worth mentioning that the feature to pass props down to the wrapped component through WithSkiaWeb was merged not long ago here.

LoadSkiaWeb WithSkiaWeb
Image Image

Version

1.5.0

Steps to reproduce

Created a simple repo where the issue can be reproduced. Follow instructions in the README to reproduce the crash.

Don't defer app registration, and load the component using skia via WithSkiaWeb, with changing props passed down to it via componentProps

Snack, code example, screenshot, or link to a repository

https://github.com/santitopo/withskiaweb-issue/tree/main

santitopo commented 3 weeks ago

@wcandillon any ideas on what may be going on?

wcandillon commented 2 weeks ago

Yes, thank you for sending me the example project. I will update WithSkiaWeb so any updates/rerendering of the component doesn't trigger any side effects. You can update your code to do the same in the meantime.

github-actions[bot] commented 2 weeks ago

:tada: This issue has been resolved in version 1.5.1 :tada:

The release is available on:

Your semantic-release bot :package::rocket:

wcandillon commented 2 weeks ago

@santitopo You can also implement your own component with suspense and implement your own logic there if needed (but I don't think you should or need) but I was just thinking about this.