nativescript-community / ui-image

Advanced and efficient image display plugin which uses Fresco (Android) and SDWebImage (iOS) to implement caching, placeholders, image effects, and much more.
Apache License 2.0
36 stars 9 forks source link

On IOS Crash - Cannot set property 'image' of null at _setNativeImage #49

Closed louisportalest closed 1 year ago

louisportalest commented 1 year ago

Which platform(s) does your issue occur on?

Please, provide the following version numbers that your issue occurs with:

After i run a full clean build (ns clean), i got this error message and the app crashes whenever i scroll to a picture post with NSImg in a RadListView. Not sure why but before the clean build everything was working fine.

***** Fatal JavaScript exception - application has been terminated.


NativeScript encountered a fatal error: Uncaught TypeError: Cannot set property 'image' of null at _setNativeImage(file: node_modules/@nativescript-community/ui-image /index.ios.js:267:12) at Img.handleImageLoaded(file: node_modules/@nativescript-community /ui-image/index.ios.js:173:21)

I tried updating pod, the ui-image plugin and also nativescript, both also not working. Not sure what causing this.

Here is the code :

farfromrefug commented 1 year ago

@louisportalest does it work outside of radlistview?

louisportalest commented 1 year ago

@louisportalest does it work outside of radlistview?

Yes it works outside of radlistview. But previously it work well on radlistview, not sure why it stops working now. i try to display the error from failure event and here what it says :

Error Domain=SDWebImageErrorDomain Code=2002 "Operation cancelled by user during querying the cache" UserInfo={NSLocalizedDescription=Operation cancelled by user during querying the cache}

farfromrefug commented 1 year ago

can't really see what s going on with this. sadly you need to investigate to see which version of which package broke it for you

msn444 commented 1 year ago

I've started seeing this issue as well. I haven't been able to track down what changed to cause it.

It seems that in my case, the issue occurs on a NSImg element that is in a Vue component that is toggled by a v-if directive. When the Firebase auth state changes to "logged in", the v-if expression resolves to false and the component is destroyed. This is the action that causes the crash. Perhaps similar to the OP, where dynamic mounting and destroying of items in the RadListView causes the crash?

If I change the v-if to a v-show (which keeps the component mounted but just hides it rather than destroying it), the problem goes away. I'm not sure if this is a good solution though.

farfromrefug commented 1 year ago

@msn444 first v-if in listview template should never be done. Though it does not change the fact that you see a bug ;) Could you try to replace with a simple ListView and see if you still have the issue? That would help pinpoint the issue to RadListView or the image plugin. thanks

msn444 commented 1 year ago

@farfromrefug Actually in my case there's no listview, Rad or otherwise. The problematic NSImg was simply in a component sitting on the main page of the app, whose visibility was toggled by the Firebase login state, using the v-if directive. Changing 'v-if' to 'v-show' solves it for me.

In another case, I have NSImg in a component displayed in a list using v-for. I haven't seen any problems with this method.

farfromrefug commented 1 year ago

@msn444 OK i get it. I might have an idea. Will try a fix

farfromrefug commented 1 year ago

@msn444 can you try 4.3.5 ?

msn444 commented 1 year ago

@farfromrefug That seems to have solved it. Thanks for the ultra fast fix!