ListView on android has some bugs,ViewCell with Image like this
Image image = new Image()
{
WidthRequest = 80,HeightRequest = 80
};
image.Source = new FileImageSource() { File = "mango.png" };
When the listview scroll fast, Apps crash, see logs bellow
+++++++++++++++++++++++++++++++++++++++++
Thread started: #2
[0:]
11-19 03:18:49.882 I/mono-stdout(32400): SetValue: Can not convert 14 to type 'System.Double'
SetValue: Can not convert 14 to type 'System.Double'
[0:] SetValue: Can not convert 14 to type 'System.Double'
[0:]
SetValue: Can not convert 24 to type 'System.Double'
[0:] SetValue: Can not convert 24 to type 'System.Double'
11-19 03:18:49.972 I/mono-stdout(32400): SetValue: Can not convert 24 to type 'System.Double'
Loaded assembly: System.Xml.dll [External]
Thread started: #3
Thread started: #4
11-19 03:18:52.922 I/dalvikvm-heap(32400): Grow heap (frag case) to 40.773MB for 12960016-byte allocation
11-19 03:18:53.202 I/dalvikvm-heap(32400): Grow heap (frag case) to 53.173MB for 12960016-byte allocation
11-19 03:18:53.277 I/dalvikvm-heap(32400): Grow heap (frag case) to 65.840MB for 12960016-byte allocation
11-19 03:18:55.707 I/dalvikvm-heap(32400): Grow heap (frag case) to 80.649MB for 12960016-byte allocation
11-19 03:18:55.892 I/dalvikvm-heap(32400): Grow heap (frag case) to 81.564MB for 12960016-byte allocation
11-19 03:18:55.997 I/dalvikvm-heap(32400): Grow heap (frag case) to 93.923MB for 12960016-byte allocation
11-19 03:18:56.067 I/dalvikvm-heap(32400): Grow heap (frag case) to 81.562MB for 12960016-byte allocation
11-19 03:18:56.132 I/dalvikvm-heap(32400): Grow heap (frag case) to 81.563MB for 12960016-byte allocation
11-19 03:18:56.202 I/dalvikvm-heap(32400): Grow heap (frag case) to 93.922MB for 12960016-byte allocation
11-19 03:18:56.277 I/dalvikvm-heap(32400): Grow heap (frag case) to 106.283MB for 12960016-byte allocation
Thread started: #5
11-19 03:18:56.372 I/dalvikvm-heap(32400): Grow heap (frag case) to 118.643MB for 12960016-byte allocation
11-19 03:18:56.437 I/dalvikvm-heap(32400): Grow heap (frag case) to 131.002MB for 12960016-byte allocation
11-19 03:18:56.567 I/dalvikvm-heap(32400): Grow heap (frag case) to 143.363MB for 12960016-byte allocation
11-19 03:18:56.612 I/dalvikvm-heap(32400): Grow heap (frag case) to 155.722MB for 12960016-byte allocation
11-19 03:18:56.732 I/dalvikvm-heap(32400): Grow heap (frag case) to 168.083MB for 12960016-byte allocation
11-19 03:18:56.847 I/dalvikvm-heap(32400): Grow heap (frag case) to 180.445MB for 12960016-byte allocation
11-19 03:18:56.882 I/dalvikvm-heap(32400): Forcing collection of SoftReferences for 12960016-byte allocation
11-19 03:18:56.912 E/dalvikvm-heap(32400): Out of memory on a 12960016-byte allocation.
11-19 03:18:56.912 I/dalvikvm(32400): "Thread-2084" prio=5 tid=15 RUNNABLE
11-19 03:18:56.912 I/dalvikvm(32400): | group="main" sCount=0 dsCount=0 obj=0x432e0870 self=0x7ee61660
11-19 03:18:56.912 I/dalvikvm(32400): | sysTid=32627 nice=0 sched=0/0 cgrp=apps handle=2133905608
11-19 03:18:56.912 I/dalvikvm(32400): | state=R schedstat=( 1279493280 29315936 633 ) utm=106 stm=21 core=4
11-19 03:18:56.912 I/dalvikvm(32400): at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
11-19 03:18:56.912 I/dalvikvm(32400): at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:606)
11-19 03:18:56.912 I/dalvikvm(32400): at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:433)
11-19 03:18:56.912 I/dalvikvm(32400): at android.graphics.BitmapFactory.decodeResource(BitmapFactory.java:464)
11-19 03:18:56.912 I/dalvikvm(32400): at android.graphics.BitmapFactory.decodeResource(BitmapFactory.java:494)
11-19 03:18:56.912 I/dalvikvm(32400): at dalvik.system.NativeStart.run(Native Method)
11-19 03:18:56.912 I/dalvikvm(32400):
11-19 03:18:57.017 I/dalvikvm-heap(32400): Grow heap (frag case) to 180.436MB for 12960016-byte allocation
11-19 03:18:57.147 I/dalvikvm-heap(32400): Grow heap (frag case) to 180.437MB for 12960016-byte allocation
An unhandled exception occured.
11-19 03:20:28.112 I/MonoDroid(32400): UNHANDLED EXCEPTION:
11-19 03:20:28.172 I/MonoDroid(32400): Java.Lang.OutOfMemoryError: Exception of type 'Java.Lang.OutOfMemoryError' was thrown.
11-19 03:20:28.172 I/MonoDroid(32400): at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x00000] in :0
11-19 03:20:28.172 I/MonoDroid(32400): at Android.Runtime.JNIEnv.CallStaticObjectMethod (IntPtr jclass, IntPtr jmethod, Android.Runtime.JValue[] parms) [0x00064] in /Users/builder/data/lanes/monodroid-mlion-monodroid-4.18-series/5474129a/source/monodroid/src/Mono.Android/src/Runtime/JNIEnv.g.cs:1161
11-19 03:20:28.172 I/MonoDroid(32400): at Android.Graphics.BitmapFactory.DecodeResource (Android.Content.Res.Resources res, Int32 id) [0x0002d] in /Users/builder/data/lanes/monodroid-mlion-monodroid-4.18-series/5474129a/source/monodroid/src/Mono.Android/platforms/android-19/src/generated/Android.Graphics.BitmapFactory.cs:580
11-19 03:20:28.172 I/MonoDroid(32400): at Android.Graphics.BitmapFactory+c__AnonStorey6.<>m__0 () [0x00000] in /Users/builder/data/lanes/monodroid-mlion-monodroid-4.18-series/5474129a/source/monodroid/src/Mono.Android/platforms/android-19/src/generated/Android.Graphics.BitmapFactory.cs:586
11-19 03:20:28.172 I/MonoDroid(32400): at System.Threading.Tasks.TaskActionInvoker+FuncInvoke`1[Android.Graphics.Bitmap].Invoke (System.Threading.Tasks.Task owner, System.Object state, System.Threading.Tasks.Task context) [0x00000] in :0
11-19 03:20:28.172 I/MonoDroid(32400): at System.Threading.Tasks.Task.InnerInvoke () [0x00000] in :0
11-19 03:20:28.172 I/MonoDroid(32400): at System.Threading.Tasks.Task.ThreadStart () [0x00000] in :0
An unhandled exception occured.
11-19 03:20:28.172 I/MonoDroid(32400): --- End of stack trace from previous location where exception was thrown ---
11-19 03:20:28.172 I/MonoDroid(32400): at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x00000] in :0
11-19 03:20:28.172 I/MonoDroid(32400): at System.Runtime.CompilerServices.ConfiguredTaskAwaitable
1+ConfiguredTaskAwaiter[Android.Graphics.Bitmap].GetResult () [0x00000] in <filename unknown>:0
11-19 03:20:28.172 I/MonoDroid(32400): at Xamarin.Forms.Platform.Android.FileImageSourceHandler+<LoadImageAsync>d__0.MoveNext () [0x00000] in <filename unknown>:0
11-19 03:20:28.172 I/MonoDroid(32400): --- End of stack trace from previous location where exception was thrown ---
11-19 03:20:28.172 I/MonoDroid(32400): at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x00000] in <filename unknown>:0
11-19 03:20:28.172 I/MonoDroid(32400): at System.Runtime.CompilerServices.TaskAwaiter
1[Android.Graphics.Bitmap].GetResult () [0x00000] in :0 11-19 03:20:28.172 I/MonoDroid(32400): at Xamarin.Forms.Platform.Android.ImageRenderer+d__0.MoveNext () [0x00000] in :0
11-19 03:20:28.172 I/MonoDroid(32400): --- End of managed exception stack trace ---
11-19 03:20:28.172 I/MonoDroid(32400): java.lang.OutOfMemoryError
11-19 03:20:28.172 I/MonoDroid(32400): at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
11-19 03:20:28.172 I/MonoDroid(32400): at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:606)
11-19 03:20:28.172 I/MonoDroid(32400): at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:433)
11-19 03:20:28.172 I/MonoDroid(32400): at android.graphics.BitmapFactory.decodeResource(BitmapFactory.java:464)
11-19 03:20:28.172 I/MonoDroid(32400): at android.graphics.BitmapFactory.decodeResource(BitmapFactory.java:494)
11-19 03:20:28.172 I/MonoDroid(32400): at dalvik.system.NativeStart.run(Native Method)
11-19 03:20:51.532 E/mono (32400):
11-19 03:20:51.532 E/mono (32400): Unhandled Exception:
11-19 03:20:51.532 E/mono (32400): Java.Lang.OutOfMemoryError: Exception of type 'Java.Lang.OutOfMemoryError' was thrown.
11-19 03:20:51.532 E/mono (32400): at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x00000] in :0
11-19 03:20:51.532 E/mono (32400): at Android.Runtime.JNIEnv.CallStaticObjectMethod (IntPtr jclass, IntPtr jmethod, Android.Runtime.JValue[] parms) [0x00064] in /Users/builder/data/lanes/monodroid-mlion-monodroid-4.18-series/5474129a/source/monodroid/src/Mono.Android/src/Runtime/JNIEnv.g.cs:1161
11-19 03:20:51.532 E/mono (32400): at Android.Graphics.BitmapFactory.DecodeResource (Android.Content.Res.Resources res, Int32 id) [0x0002d] in /Users/builder/data/lanes/monodroid-mlion-monodroid-4.18-series/5474129a/source/monodroid/src/Mono.Android/platforms/android-19/src/generated/Android.Graphics.BitmapFactory.cs:580
11-19 03:20:51.532 E/mono (32400): at Android.Graphics.BitmapFactory+c__AnonStorey6.<>m__0 () [0x00000] in /Users/builder/data/lanes/monodroid-mlion-monodroid-4.18-series/5474129a/source/monodroid/src/Mono.Android/platforms/android-19/src/generated/Android.Graphics.BitmapFactory.cs:586
11-19 03:20:51.532 E/mono (32400): at System.Threading.Tasks.TaskActionInvoker+FuncInvoke
1[Android.Graphics.Bitmap].Invoke (System.Threading.Tasks.Task owner, System.Object state, System.Threading.Tasks.Task context) [0x00000] in <filename unknown>:0
11-19 03:20:51.532 E/mono (32400): at System.Threading.Tasks.Task.InnerInvoke () [0x00000] in <filename unknown>:0
11-19 03:20:51.532 E/mono (32400): at System.Threading.Tasks.Task.ThreadStart () [0x00000] in <filename unknown>:0
11-19 03:20:51.532 E/mono (32400): --- End of stack trace from previous location where exception was thrown ---
11-19 03:20:51.532 E/mono (32400): at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x00000] in <filename unknown>:0
11-19 03:20:51.532 E/mono (32400): at System.Runtime.CompilerServices.ConfiguredTaskAwaitable
1+ConfiguredTaskAwaiter[Android.Graphics.Bitmap].GetResult () [0x00000] in :0 11-19 03:20:51.532 E/mono (32400): at Xamarin.Forms.Platform.Android.FileImageSourceHandler+d__0.MoveNext () [0x00000] in :0
11-19 03:20:51.532 E/mono (32400): --- End of stack trace from previous location where exception was thrown ---
11-19 03:20:51.532 E/mono (32400): at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x00000] in :0
11-19 03:20:51.532 E/mono (32400): at System.Runtime.CompilerServices.TaskAwaiter`1[Android.Graphics.Bitmap].GetResult () [0x00000] in :0
11-19 03:20:51.532 E/mono (32400): at Xamarin.Forms.Platform.Android.ImageRenderer+d__0.MoveNext () [0x00000] in :0
程序“Mono”已退出,返回值为 0 (0x0)。