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
Issue with nativeViewProtected to get 'imageWidth' of null #43
System.err: An uncaught Exception occurred on "main" thread.
System.err: Calling js method onFinalImageSet failed
System.err: TypeError: Cannot set property 'imageWidth' of null
System.err:
System.err: StackTrace:
System.err: updateViewSize(file: node_modules/@nativescript-community/ui-image/image.android.js:252:40)
System.err: at onFinalImageSet(file: node_modules/@nativescript-community/ui-image/image.android.js:396:39)
System.err: at com.tns.Runtime.callJSMethodNative(Native Method)
System.err: at com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1302)
System.err: at com.tns.Runtime.callJSMethodImpl(Runtime.java:1188)
System.err: at com.tns.Runtime.callJSMethod(Runtime.java:1175)
System.err: at com.tns.Runtime.callJSMethod(Runtime.java:1153)
System.err: at com.tns.Runtime.callJSMethod(Runtime.java:1149)
System.err: at com.tns.gen.com.facebook.drawee.controller.ControllerListener.onFinalImageSet(ControllerListener.java:31)
System.err: at com.facebook.drawee.controller.AbstractDraweeController.reportSuccess(AbstractDraweeController.java:810)
System.err: at com.facebook.drawee.controller.AbstractDraweeController.onNewResultInternal(AbstractDraweeController.java:633)
System.err: at com.facebook.drawee.controller.AbstractDraweeController.access$100(AbstractDraweeController.java:56)
System.err: at com.facebook.drawee.controller.AbstractDraweeController$2.onNewResultImpl(AbstractDraweeController.java:567)
System.err: at com.facebook.datasource.BaseDataSubscriber.onNewResult(BaseDataSubscriber.java:49)
System.err: at com.facebook.datasource.AbstractDataSource$1.run(AbstractDataSource.java:197)
System.err: at android.os.Handler.handleCallback(Handler.java:907)
System.err: at android.os.Handler.dispatchMessage(Handler.java:105)
System.err: at android.os.Looper.loop(Looper.java:216)
System.err: at android.app.ActivityThread.main(ActivityThread.java:7625)
System.err: at java.lang.reflect.Method.invoke(Native Method)
System.err: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:524)
System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:987)
Solution
I found a solution for it. Add if query in file ...\node_modules@nativescript-community\ui-image\image.android.js in function updateViewSize() to check, if variable this.nativeViewProtected is set befor it is used.
updateViewSize(imageInfo) {
if (this.nativeViewProtected) {
const draweeView = this.nativeViewProtected;
if (imageInfo != null) {
draweeView.imageWidth = imageInfo.getWidth();
draweeView.imageHeight = imageInfo.getHeight();
}
if (!this.aspectRatio && imageInfo != null) {
const ratio = imageInfo.getWidth() / imageInfo.getHeight();
draweeView.setAspectRatio(ratio);
} else if (this.aspectRatio) {
draweeView.setAspectRatio(this.aspectRatio);
} else {
draweeView.setAspectRatio(0);
}
}
}
Which platform(s) does your issue occur on?
Android
9
on device
Please, provide the following version numbers that your issue occurs with:
CLI: 11.2.12
NS 7.2.1
Anyone else had this problems before? Are you able to reproduce it?
Thanks in advance
I have the same issue described here https://github.com/nativescript-community/ui-image/issues/42.
Solution
I found a solution for it. Add if query in file
...\node_modules@nativescript-community\ui-image\image.android.js
in functionupdateViewSize()
to check, if variablethis.nativeViewProtected
is set befor it is used.Which platform(s) does your issue occur on?
Please, provide the following version numbers that your issue occurs with:
Anyone else had this problems before? Are you able to reproduce it? Thanks in advance