ImageView上的SetImageBitmap在垃圾回收后崩溃应用程序

时间:2016-10-27 15:13:30

标签: android xamarin garbage-collection imageview mvvmcross

我有一个显示项目列表的MvxRecyclerView。单击某个项目时,该应用会导航到详细信息页面/活动。详细信息页面包含一些MvxImageView

我的问题是,在重复导航到详细信息页面并返回列表页面后,应用程序崩溃了。

10-27 16:38:57.495 E/mono-rt (21190): Stacktrace:
10-27 16:38:57.495 E/mono-rt (21190): 
10-27 16:38:57.495 E/mono-rt (21190):   at <unknown> <0xffffffff>
10-27 16:38:57.496 E/mono-rt (21190):   at (wrapper managed-to-native) Java.Interop.NativeMethods.java_interop_jnienv_call_nonvirtual_void_method_a (intptr,intptr&,intptr,intptr,intptr,Java.Interop.JniArgumentValue*) <0x00007>
10-27 16:38:57.496 E/mono-rt (21190):   at Java.Interop.JniEnvironment/InstanceMethods.CallNonvirtualVoidMethod (Java.Interop.JniObjectReference,Java.Interop.JniObjectReference,Java.Interop.JniMethodInfo,Java.Interop.JniArgumentValue*) [0x0008f] in /Users/builder/data/lanes/3415/7db2aac3/source/Java.Interop/src/Java.Interop/Java.Interop/JniEnvironment.g.cs:12079
10-27 16:38:57.496 E/mono-rt (21190):   at Java.Interop.JniPeerMembers/JniInstanceMethods.InvokeVirtualVoidMethod (string,Java.Interop.IJavaPeerable,Java.Interop.JniArgumentValue*) [0x00068] in /Users/builder/data/lanes/3415/7db2aac3/source/Java.Interop/src/Java.Interop/Java.Interop/JniPeerMembers.JniInstanceMethods_Invoke.cs:31
10-27 16:38:57.496 E/mono-rt (21190):   at Android.Widget.ImageView.SetImageBitmap (Android.Graphics.Bitmap) [0x0002c] in /Users/builder/data/lanes/3415/7db2aac3/source/monodroid/src/Mono.Android/platforms/android-23/src/generated/Android.Widget.ImageView.cs:1026
10-27 16:38:57.496 E/mono-rt (21190):   at MvvmCross.Binding.Droid.Views.MvxImageView.SetImageBitmap (Android.Graphics.Bitmap) <IL 0x00032, 0x0016f>
10-27 16:38:57.496 E/mono-rt (21190):   at MvvmCross.Binding.Droid.Views.MvxImageView/<>c__DisplayClass19_0.<ImageHelperOnImageChanged>b__0 () <IL 0x00011, 0x000bf>
10-27 16:38:57.496 E/mono-rt (21190):   at Java.Lang.Thread/RunnableImplementor.Run () [0x0000b] in /Users/builder/data/lanes/3415/7db2aac3/source/monodroid/src/Mono.Android/src/Java.Lang/Thread.cs:36
10-27 16:38:57.496 E/mono-rt (21190):   at Java.Lang.IRunnableInvoker.n_Run (intptr,intptr) [0x00009] in /Users/builder/data/lanes/3415/7db2aac3/source/monodroid/src/Mono.Android/platforms/android-23/src/generated/Java.Lang.IRunnable.cs:81
10-27 16:38:57.496 E/mono-rt (21190):   at (wrapper dynamic-method) object.751fdf82-a027-44fc-87ab-b6871a6fff2a (intptr,intptr) <IL 0x00011, 0x0001f>
10-27 16:38:57.496 E/mono-rt (21190):   at (wrapper native-to-managed) object.751fdf82-a027-44fc-87ab-b6871a6fff2a (intptr,intptr) <IL 0x0001e, 0x00087>
10-27 16:38:57.496 E/mono-rt (21190): 
10-27 16:38:57.496 E/mono-rt (21190): Attempting native Android stacktrace:

这导致了崩溃,经过一些研究,我跟随了Xamarin的this debugging guide。在我强迫GC每秒收集垃圾之前,应用程序会随机崩溃。在强制垃圾收集后,它似乎几乎立即在第一次或第二次导航到详细页面时崩溃。

如何解决这个问题?

0 个答案:

没有答案