react-native-skia icon indicating copy to clipboard operation
react-native-skia copied to clipboard

fix: Avoid crashes when calling JNI method fails

Open Titozzz opened this issue 3 years ago • 5 comments

While the proper fix would be to understand why there is an NPE, this mitigates the crash

Titozzz avatar Sep 07 '22 15:09 Titozzz

(CLA signed)

Titozzz avatar Sep 08 '22 08:09 Titozzz

Hi @Titozzz! Thanks for the PR! Could you describe which NPEs you're expecting to catch with this fix? I'm positive to merge / include this try..catch, but just wanted to get some more information about the reason behind it.

chrfalch avatar Sep 09 '22 10:09 chrfalch

@chrfalch Sometime when the screens unmount and I used a canvas the view would just crash. I've setup some breakpoints on the JNI side and when the crash occur they do not trigger so somehow theses function just de-bind or don't exist anymore when the crash occurs. Happy to help fix it in a better way if you want. I have patched package on my side in the meantime

Titozzz avatar Sep 09 '22 15:09 Titozzz

Hi. @Titozzz - I've created a PR containing a huge refactor of the base C++ classes where we've also cleaned up a few memory leaks and crashes from Android - #899 - which you might like to try. It is basically making it super easy to extend and create new Skia based views and native components.

chrfalch avatar Sep 16 '22 10:09 chrfalch

I've made a refactoring in our codebase to depend less on skia but I'll revert back to the commit and try reproducing with the latest version of skia if you want

Titozzz avatar Sep 16 '22 11:09 Titozzz

Closing due to inactivity.

chrfalch avatar Feb 13 '23 12:02 chrfalch