Notice (2018-05-24): bugzilla.xamarin.com is now in
Please join us on
Visual Studio Developer Community and in the
Mono organizations on
GitHub to continue tracking issues. Bugzilla will remain
available for reference in read-only mode. We will continue to work
on open Bugzilla bugs, copy them to the new locations
as needed for follow-up, and add the new items under Related
Our sincere thanks to everyone who has contributed on this bug
tracker over the years. Thanks also for your understanding as we
make these adjustments and improvements for the future.
Please create a new report for Bug 60898 on
Developer Community or GitHub if you have new
information to add and do not yet see a matching new report.
If the latest results still closely match this report, you can use the
In special cases on GitHub you might also want the comments:
GitHub Markdown with public comments
This is crashing my Android app 50% of the time, apparently randomly, whenever I navigate between master detail pages. I tried changing the MONO_GC_PARAMS to bridge-implementation=old, but in my diagnostic build, I still see MONO_GC_PARAMS = major=marksweep-conc. I tried adding an environment.txt file with a build action of AndroidEnvironment with the following line:
That didn't work in Windows or Mac OSX - the app crashes whether I've replaced that line with new, old, or tarjan.
I think this has shown up periodically - I can privately provide a copy of my source code if necessary with steps to reproduce, but it's a pretty big project.
11-28 12:47:48.219 12303-12303/... E/AndroidRuntime: FATAL EXCEPTION: main
Process: ..., PID: 12303
android.runtime.JavaProxyThrowable: System.ArgumentException: Handle must be valid.
Parameter name: instance
at Java.Interop.JniEnvironment+InstanceMethods.CallNonvirtualVoidMethod (Java.Interop.JniObjectReference instance, Java.Interop.JniObjectReference type, Java.Interop.JniMethodInfo method, Java.Interop.JniArgumentValue* args) [0x00009] in <7cfbebb561c54efc9010b018c0846c7e>:0
at Android.Runtime.JNIEnv.CallNonvirtualVoidMethod (System.IntPtr jobject, System.IntPtr jclass, System.IntPtr jmethod, Android.Runtime.JValue* parms) [0x00015] in <e975227ac8644a30bb0866117325de0d>:0
at Android.Support.V4.Widget.DrawerLayout.RemoveDrawerListener (Android.Support.V4.Widget.DrawerLayout+IDrawerListener listener) [0x00088] in <fc4222de5c684a9abf7cc4821baac4cd>:0
at Xamarin.Forms.Platform.Android.AppCompat.NavigationPageRenderer.Dispose (System.Boolean disposing) [0x000e4] in <b5b1173f4d49442b898c45e26ae39e48>:0
at Java.Lang.Object.Dispose () [0x00000] in <e975227ac8644a30bb0866117325de0d>:0
at Xamarin.Forms.Platform.Android.AppCompat.Platform+<>c__DisplayClass35_0.<SetPage>b__0 () [0x00015] in <b5b1173f4d49442b898c45e26ae39e48>:0
at Java.Lang.Thread+RunnableImplementor.Run () [0x00008] in <e975227ac8644a30bb0866117325de0d>:0
at Java.Lang.IRunnableInvoker.n_Run (System.IntPtr jnienv, System.IntPtr native__this) [0x00008] in <e975227ac8644a30bb0866117325de0d>:0
at (wrapper dynamic-method) System.Object:3ebd961c-97b4-4369-879b-c2f6c3df7470 (intptr,intptr)
at mono.java.lang.RunnableImplementor.n_run(Native Method)
at java.lang.reflect.Method.invoke(Native Method)
Thanks for your bug report!
This issue looks more related to a dispose call of DrawerLayout's listener based on the stack trace. Specifically it might be related to Xamarin.Forms invoking an object that's already disposed.
As per your observations of each bridge running into this issue, it sounds like a potential Forms or GC bug. I would guess Forms first however based on the Stack Trace.
Some initial things we will need:
1. What version of Xamarin Forms are you using?
2. What version of Support Libraries are you using?
3. Do you have a reproduction project you can attach to this bug report? Ideally if you can produce a minimal example project, that would help us most. We do not need a full project as we would then have to go about a private bug/NDA situation if your company requires one.
It will also be worth enabling GREF logging:
And viewing the lifecycle. Here's a Stack Overflow question somewhat outlining this:
Thanks for the speedy reply!
I was able to reproduce this in a minimalistic project (2 master detail screens with a single button on each, navigating from one to the other by altering the MainPage property in the App class).
Here are the versions:
1) Xamarin.forms 220.127.116.11635
@) Support libs 18.104.22.168
Based on your github reproduuction it looks like you are using Support library version 22.214.171.124 with API 26. This is typically an unsupported scenario which can lead to general "weirdness". Does this happen if you set your TargetFrameworkVersion(aka compileSdkVersion) to API 25 instead? Otherwise you should upgrade to a 26 version if compiling against Oreo.
(In reply to Jon Douglas [MSFT] from comment #3)
> Hi Max,
> Based on your github reproduuction it looks like you are using Support
> library version 126.96.36.199 with API 26. This is typically an unsupported
> scenario which can lead to general "weirdness". Does this happen if you set
> your TargetFrameworkVersion(aka compileSdkVersion) to API 25 instead?
> Otherwise you should upgrade to a 26 version if compiling against Oreo.
In other words, your support library version needs to match your compilation api level.
Yes - you're right about the support libs version - it is 188.8.131.52. But, yes, it still crashes when compiling with API 25. (I had originally been compiling with the corresponding API when I encountered the error, and tried compiling against 26 to see if it'd have any impact.)
Just checking in - I see the status of this bug is still NEEDINFO - are you waiting on any further information from me?
A few quick things:
1. Please update to the latest stable version of Xamarin.Forms. You are on 184.108.40.2060 which is 2 months old compared to the new major 2.5 releases.
Also try the nightly build: https://blog.xamarin.com/try-the-latest-in-xamarin-forms-with-nightly-builds/
2. Ensure that your support library version matches your compilation target (v26 ideally)
Please also mirror these changes in your github repository.
Once you've done that, I will continue my investigation to determine if this is an Android or Forms issue. Feel free to comment when you've done that!
Thank you, Jon.
I updated my Xamarin.Forms version to 220.127.116.11635, my support libraries to 18.104.22.168, and my target framework to API 26 (8.0 - Oreo). I'm still receiving the exception. My github repository is up-to-date. Let me know if I can provide any more information.
I'm testing with a Galaxy Tab A (2016) running Android 5.1.1, if that makes any difference.
I can CONFIRM this behavior based on the updated reproduction. I am redirecting this issue to Forms given the stack trace and initial investigation.
Is there any update on this issue somewhere else?
This behavior is driving me crazy, if there's someone working on fixing it and I can help I'd like to as this is giving me a hard time on a couple of project.
Is that moved into Github? please find a solution for this. it is very crucial bug
My app crashes with
System.ArgumentException: Handle must be valid.
Parameter name: instance
When navigating to a new Activity with RecyclerView, this activity has started showing, not shown yet and there is event to NotifyDataSetChanged from data model.
Started to appear after updating Android support libraries from 23.3 to 27.1, but 25.1 is also problematic.
Sorry for mystification, it was caused by calling manual Dispose on Adapter when setting new adapter to RecyclerView.
Adapter instance was Disposed but not unhooked from Data Source events, and in event method was code working with context.