DylanVann / react-native-fast-image

🚩 FastImage, performant React Native image component.
MIT License
8.09k stars 1.47k forks source link

java.lang.NullPointerException: Attempt to invoke virtual method 'boolean com.dylanvann.fastimage.FastImageSource.isResource()' on a null object reference #952

Open brandonkhy14 opened 1 year ago

brandonkhy14 commented 1 year ago

Describe the bug

The app crashed in release mode for android when run react-native-fast-image with defaultSouce, working well in debug mode.

Remark: iOS working well.

java.lang.NullPointerException: Attempt to invoke virtual method 'boolean com.dylanvann.fastimage.FastImageSource.isResource()' on a null object reference at com.dylanvann.fastimage.FastImageViewConverter.getOptions(FastImageViewConverter.java:111) at com.dylanvann.fastimage.FastImageViewWithUrl.onAfterUpdate(FastImageViewWithUrl.java:143) at com.dylanvann.fastimage.FastImageViewManager.onAfterUpdateTransaction(FastImageViewManager.java:181) at com.dylanvann.fastimage.FastImageViewManager.onAfterUpdateTransaction(FastImageViewManager.java:33) at com.facebook.react.uimanager.ViewManager.updateProperties(ViewManager.java:88) at com.facebook.react.uimanager.ViewManager.createViewInstance(ViewManager.java:188) at com.facebook.react.uimanager.ViewManager.createView(ViewManager.java:115) at com.facebook.react.uimanager.NativeViewHierarchyManager.createView(NativeViewHierarchyManager.java:281) at com.facebook.react.uimanager.UIViewOperationQueue$CreateViewOperation.execute(UIViewOperationQueue.java:194) at com.facebook.react.uimanager.UIViewOperationQueue$DispatchUIFrameCallback.dispatchPendingNonBatchedOperations(UIViewOperationQueue.java:1110) at com.facebook.react.uimanager.UIViewOperationQueue$DispatchUIFrameCallback.doFrameGuarded(UIViewOperationQueue.java:1081) at com.facebook.react.uimanager.GuardedFrameCallback.doFrame(GuardedFrameCallback.java:29) at com.facebook.react.modules.core.ReactChoreographer$ReactChoreographerDispatcher.doFrame(ReactChoreographer.java:175) at com.facebook.react.modules.core.ChoreographerCompat$FrameCallback$1.doFrame(ChoreographerCompat.java:85) at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1010) at android.view.Choreographer.doCallbacks(Choreographer.java:823) at android.view.Choreographer.doFrame(Choreographer.java:755) at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:998) at android.os.Handler.handleCallback(Handler.java:873) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:193) at android.app.ActivityThread.main(ActivityThread.java:6846) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:883)

To Reproduce <FastImage defaultSource={require('./default-images/image-1.jpg')} source={{uri: 'https://pbs.twimg.com/profile_images/1455185376876826625/s1AjSxph_400x400.jpg'}} resizeMode={'cover'} style={{ height: 220, width: PRODUCT_CARD_WIDTH, borderTopLeftRadius: 10, borderTopRightRadius: 10, }} />

Expected behavior Expected to show default picture from defaultSource if source image is unavailable.

Screenshots App crashed directly when screen loaded.

Dependency versions

thegdznet commented 1 year ago

Hi!

Same problem for me.

Juste changed if (imageSource.isResource()) with if ((imageSource != null) && imageSource.isResource()) on line 111 of FastImageViewConverter.java.

justo-admin commented 1 year ago

@thegdznet Thanks that works !!

Hi!

Same problem for me.

Juste changed if (imageSource.isResource()) with if ((imageSource != null) && imageSource.isResource()) on line 111 of FastImageViewConverter.java.

@thegdznet Thanks!! That works

mjooms commented 1 year ago

Same issue here using a resource on defaultSource on prod build on Android. When source is null, I get the error.

hizbullaharif commented 1 year ago

same issue here?

luluanacarla commented 1 year ago

Any news here? I'm facing the same issue.

vksgautam1986 commented 1 year ago

same issue

antoinecaputo commented 1 year ago

null object makes app crash #973 is still open :/

antoinecaputo commented 1 year ago

To fix it in your code, make sure that you always pass to FastImage at least source={{ uri=null }} It will crash when the source property is null.

thegdznet commented 1 year ago

Thanx. Will check in ou code base.