<DataTemplate>
<ViewCell>
<Grid>
<!-- snip -->
<StackLayout Grid.Column="2" Padding="0,0,5,0" Orientation="Horizontal" VerticalOptions="Start">
<svg:SvgImage Svg="res:Assets.Images.BirthdayCake" IsVisible="{Binding IsInBirthdayPeriod}" HeightRequest="20" />
</StackLayout>
</Grid>
</ViewCell>
</DataTemplate>
This is using library XamSvg.Forms to show the SVG image. It works fine on iOS for both pages. On Android however the page with the static list of persons is just fine but the one which dynamically updates the list of persons crashes as soon as the SvgImage needs to be visible. It crashes with:
Xamarin caused by: android.runtime.JavaProxyThrowable: System.ObjectDisposedException: Cannot access a disposed object.
Object name: 'XamSvg.SvgImageView'.
at Java.Interop.JniPeerMembers.AssertSelf (Java.Interop.IJavaPeerable self) [0x00030] in <a043032cf94a485190047a14918b9f60>:0
at Java.Interop.JniPeerMembers+JniInstanceMethods.InvokeVirtualVoidMethod (System.String encodedMember, Java.Interop.IJavaPeerable self, Java.Interop.JniArgumentValue* parameters) [0x00001] in <a043032cf94a485190047a14918b9f60>:0
at Android.Views.View.RequestLayout () [0x0000a] in <82194ba0d96e4d64b3f1f6b60247af10>:0
at XamSvg.SvgImageView+<>c__DisplayClass51_1.<set_ImageDrawable>b__0 () [0x0003d] in <3c41261deb414f4eba76bf90d664fc04>:0
at Java.Lang.Thread+RunnableImplementor.Run () [0x0000b] in <82194ba0d96e4d64b3f1f6b60247af10>:0
at Java.Lang.IRunnableInvoker.n_Run (System.IntPtr jnienv, System.IntPtr native__this) [0x00009] in <82194ba0d96e4d64b3f1f6b60247af10>:0
at (wrapper dynamic-method) System.Object:5888540f-7cee-47d3-8b47-bfb7f2d5febc (intptr,intptr)
at mono.java.lang.RunnableImplementor.n_run(Native Method)
at mono.java.lang.RunnableImplementor.run(RunnableImplementor.java:30)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:158)
at android.app.ActivityThread.main(ActivityThread.java:7229)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
If I use a standard "Image" control instead of the SVG one, it works fine. Since it works when a static list of persons is provided, I suspect this may have something to do with CachingStrategy.