New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
After upgrading too Xamarin.Forms 4 Or Using Fast Renderer getting exception #45
Comments
@PWaliaDev does this happen if you navigate to a page and stay there? Or does it only happen at some point after you have navigated away from a page that has an image? |
This is happening when pressing back button and app finishing activity. All screen have images. This is blocking and stoping to upgrade packages and uploading to play store so need solution as soon as possible |
I'm having the same issue, but not when navigating to/from pages. It happens when hundreds of images are shown in a list view and scrolling rapidly through the list. ViewCells contain an image and the viewcells are recycled (which is the default for ListView). |
@activa if you can get a project to show the problem that would help so much! You could also add a page to the sample in this repo if that is easy enough. |
@jonathanpeppers I haven't had time to do that yet. However, after playing with our app a little bit, I noticed that I have never been able to trigger the exception in debug mode. In release mode it's very easy to reproduce though. |
@activa my example seems to work in If I fixed this bug, it would be enough to push out another release of glidex.forms. |
@jonathanpeppers I finally have some time this afternoon to try and reproduce it. I will try to make it fail using your "ListView of doom" sample. |
It was pretty easy to reproduce (almost 100% reproducible): In your ListView Of Doom sample, change the ListView to use larger images and use a standard ViewCell:
When running this, scroll through the list very fast and tap the "Back" button while it's still scrolling. 90% of the time it will crash with the exception mentioned in this issue. |
Fixes: #45 Thanks @activa! I could finally reproduce this! The problem here is we need to cancel any in-flight Glide requests when the `ImageRenderer` is disposed. Otherwise, Java completes the request against a C# object that is no longer alive. There may be a future fix needed here for `ImageCell`, but I wasn't able to reproduce a problem there.
Fixes: #45 Thanks @activa! I could finally reproduce this! The problem here is we need to cancel any in-flight Glide requests when the `ImageRenderer` is disposed. Otherwise, Java completes the request against a C# object that is no longer alive. There may be a future fix needed here for `ImageCell`, but I wasn't able to reproduce a problem there.
@jonathanpeppers I pulled the latest code from the master branch and the issue still remains. It's 100% reproducible and it throws the exact same exception:
I'm simply running your ListView of Doom sample, scroll quickly and while it's scrolling, tap back. |
Ok, never mind. For some reason pulling the latest code didn't update the glidex.forms.csproj file so the new FastRenderer class was not added to the project. It seems to work fine now. |
2.0.0.236 is also on NuGet now, so you should be able to start using it in your app. |
Everything's working great with 2.0.0.236. Thanks for the quick fix! |
I upgraded Xamarin.Forms to 4.0.0 service request and then getting exception
No constructor found for Xamarin.Forms.Platform.Android.FastRenderers.ImageRenderer::.ctor(System.IntPtr, Android.Runtime.JniHandleOwnership)
Unable to activate instance of type Xamarin.Forms.Platform.Android.FastRenderers.ImageRenderer from native handle 0xbfd3900c (key_handle 0xcbe3ef).
StackTrace:
at Java.Interop.TypeManager.CreateInstance (System.IntPtr handle, Android.Runtime.JniHandleOwnership transfer, System.Type targetType) [0x00182] in :0
at Java.Lang.Object.GetObject (System.IntPtr handle, Android.Runtime.JniHandleOwnership transfer, System.Type type) [0x000c1] in :0
at Java.Lang.Object._GetObject[T] (System.IntPtr handle, Android.Runtime.JniHandleOwnership transfer) [0x00017] in :0
at Java.Lang.Object.GetObject[T] (System.IntPtr handle, Android.Runtime.JniHandleOwnership transfer) [0x00000] in :0
at Java.Lang.Object.GetObject[T] (System.IntPtr jnienv, System.IntPtr handle, Android.Runtime.JniHandleOwnership transfer) [0x00006] in :0
at Android.Views.View.n_Invalidate (System.IntPtr jnienv, System.IntPtr native__this) [0x00000] in :0
at (wrapper dynamic-method) Android.Runtime.DynamicMethodNameCounter.76(intptr,intptr)
Source: Mono.Android
System.NotSupportedException: Unable to activate instance of type Xamarin.Forms.Platform.Android.FastRenderers.ImageRenderer from native handle 0xbfd3900c (key_handle 0xcbe3ef). ---> System.MissingMethodException: No constructor found for Xamarin.Forms.Platform.Android.FastRenderers.ImageRenderer::.ctor(System.IntPtr, Android.Runtime.JniHandleOwnership) ---> Java.Interop.JavaLocationException: Exception of type 'Java.Interop.JavaLocationException' was thrown.
at Java.Lang.Error: Exception of type 'Java.Lang.Error' was thrown.
at java.lang.Error: Java callstack:
at at md5f92e0daf340890c9667469657ee2ece8.ImageRenderer.n_invalidate(Native Method)
at at md5f92e0daf340890c9667469657ee2ece8.ImageRenderer.invalidate(:54)
at at android.widget.ImageView.invalidateDrawable(ImageView.java:281)
at at android.graphics.drawable.Drawable.invalidateSelf(Drawable.java:450)
at at android.graphics.drawable.Drawable.setVisible(Drawable.java:859)
at at android.widget.ImageView.updateDrawable(ImageView.java:1011)
at at android.widget.ImageView.setImageDrawable(ImageView.java:567)
at at com.bumptech.glide.request.target.DrawableImageViewTarget.setResource(:28)
at at com.bumptech.glide.request.target.DrawableImageViewTarget.setResource(:10)
at at com.bumptech.glide.request.target.ImageViewTarget.setResourceInternal(:127)
at at com.bumptech.glide.request.target.ImageViewTarget.onResourceReady(:104)
at at com.bumptech.glide.request.SingleRequest.onResourceReady(:579)
at at com.bumptech.glide.request.SingleRequest.onResourceReady(:549)
at at com.bumptech.glide.load.engine.EngineJob.handleResultOnMainThread(:218)
at at com.bumptech.glide.load.engine.EngineJob$MainThreadCallback.handleMessage(:324)
at at android.os.Handler.dispatchMessage(Handler.java:102)
at at android.os.Looper.loop(Looper.java:164)
at at android.app.ActivityThread.main(ActivityThread.java:6494)
at at java.lang.reflect.Method.invoke(Native Method)
at at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
--- End of inner exception stack trace ---
at Java.Interop.TypeManager.CreateProxy (System.Type type, System.IntPtr handle, Android.Runtime.JniHandleOwnership transfer) [0x00055] in :0
at Java.Interop.TypeManager.CreateInstance (System.IntPtr handle, Android.Runtime.JniHandleOwnership transfer, System.Type targetType) [0x00116] in :0
--- End of inner exception stack trace ---
at Java.Interop.TypeManager.CreateInstance (System.IntPtr handle, Android.Runtime.JniHandleOwnership transfer, System.Type targetType) [0x00182] in :0
at Java.Lang.Object.GetObject (System.IntPtr handle, Android.Runtime.JniHandleOwnership transfer, System.Type type) [0x000c1] in :0
at Java.Lang.Object._GetObject[T] (System.IntPtr handle, Android.Runtime.JniHandleOwnership transfer) [0x00017] in :0
at Java.Lang.Object.GetObject[T] (System.IntPtr handle, Android.Runtime.JniHandleOwnership transfer) [0x00000] in :0
at Java.Lang.Object.GetObject[T] (System.IntPtr jnienv, System.IntPtr handle, Android.Runtime.JniHandleOwnership transfer) [0x00006] in :0
at Android.Views.View.n_Invalidate (System.IntPtr jnienv, System.IntPtr native__this) [0x00000] in :0
at at (wrapper dynamic-method) Android.Runtime.DynamicMethodNameCounter.76(intptr,intptr)
I was also getting this issue when I was using FastRenderer so I skipped to use them but as now FastRenderers are default so getting this issue.
Version with issue:
Last known good version: 3.0.1
IDE:
Platform Target Frameworks:
Android: Xamarin.Android 8.1
Nuget Packages: 4.0.0 Service Request 4
Affected Devices: Android
The text was updated successfully, but these errors were encountered: