maui icon indicating copy to clipboard operation
maui copied to clipboard

[Android] ListView items disappear and reappear randomly when removing items from the list

Open mfeingol opened this issue 1 year ago • 7 comments

Description

Here's a screenshot. There should be 9 items displayed in the list. Only 3 are actually displayed: image

Steps to Reproduce

  1. Add a few items to a ListView
  2. Remove them one by one
  3. Observe items disappear and reappear from the ListView, along the lines of the screenshot above

Link to public reproduction project repository

https://github.com/mfeingol/repros/tree/master/ListViewItemsDisappearingRepro

Version with bug

8.0.6

Is this a regression from previous behavior?

Yes, this used to work in Xamarin.Forms

Last version that worked well

Unknown/Other

Affected platforms

Android

Affected platform versions

Android 13

Did you find any workaround?

CollectionView works, but does not support ContextActions.

Relevant log output

No response

mfeingol avatar Jan 21 '24 17:01 mfeingol

Can you test with the latest nightly build? https://github.com/dotnet/maui/wiki/Nightly-Builds

PureWeen avatar Jan 22 '24 15:01 PureWeen

Hi @mfeingol. We have added the "s/needs-info" label to this issue, which indicates that we have an open question for you before we can take further action. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.

ghost avatar Jan 22 '24 15:01 ghost

@PureWeen:

I tried out 8.0.7-nightly.9897 and the ListView issue still occurs.

Additionally, I saw the following exception with the debugger attached and hot reload enabled, after which the app would lock up. So with that build I was only able to verify the scenario without the debugger.

System.MissingMethodException: 'Method not found: int Microsoft.Maui.EnumerableExtensions.IndexOf<!0>(System.Collections.Generic.IEnumerable1<!!0>,System.Func2<!!0, bool>)'
 	0xFFFFFFFFFFFFFFFF in Android.Runtime.RuntimeNativeMethods.monodroid_debugger_unhandled_exception	C#
 	0x1A in Android.Runtime.JNINativeWrapper._unhandled_exception at /Users/runner/work/1/s/xamarin-android/src/Mono.Android/Android.Runtime/JNINativeWrapper.g.cs:13,5	C#
 	0x1D in Android.Runtime.JNINativeWrapper.Wrap_JniMarshal_PP_V at /Users/runner/work/1/s/xamarin-android/src/Mono.Android/Android.Runtime/JNINativeWrapper.g.cs:27,26	C#
 	0x83 in Microsoft.Maui.Controls.HotReload.Forms.ElementSelectionManager.Initialize at D:\a\_work\1\s\HotReload\Source\Microsoft.Maui.Controls.HotReload.Forms\Adorners\ElementSelectionManager.cs:76,7	C#
 	0x6 in Microsoft.Maui.Dispatching.Dispatcher. at D:\a\_work\1\s\src\Core\src\Dispatching\Dispatcher.Android.cs:24,24	C#
 	0xE in Java.Lang.Thread.RunnableImplementor.Run at /Users/runner/work/1/s/xamarin-android/src/Mono.Android/Java.Lang/Thread.cs:36,6	C#
 	0x8 in Java.Lang.IRunnableInvoker.n_Run at /Users/runner/work/1/s/xamarin-android/src/Mono.Android/obj/Release/net8.0/android-34/mcw/Java.Lang.IRunnable.cs:84,4	C#
 	0x8 in Android.Runtime.JNINativeWrapper.Wrap_JniMarshal_PP_V at /Users/runner/work/1/s/xamarin-android/src/Mono.Android/Android.Runtime/JNINativeWrapper.g.cs:26,5	C#

mfeingol avatar Jan 22 '24 18:01 mfeingol

We most likely need to apply these same changes here to ListView https://github.com/dotnet/maui/pull/20130

PureWeen avatar Feb 10 '24 00:02 PureWeen

We've added this issue to our backlog, and we will work to address it as time and resources allow. If you have any additional information or questions about this issue, please leave a comment. For additional info about issue management, please read our Triage Process.

ghost avatar Feb 10 '24 00:02 ghost

Fighting with this issue myself at the moment.

  • If I remove an item that is not the last, then cells after the one that was removed disappear/get a height of 0, except the last one which is unaffected.
  • If I rotate the device to landscape and back the cells are "restored".
  • If I remove the last item then nothing strange happens.
  • If I specify HasUnevenRows="False"and RowHeight=72 then the cells after the one I removed become blank but retain their height, except the last one which is unaffected.
  • Specifying CachingStrategy="RecycleElement" seems to mitigate the problem but instead introduce crashing when using SwipeView...

CollectionView seems to be a bit more stable, but using it results in the loss of the default platform separator look & feel as well as the row/item tapping effect...

I'm currently adding Android and iOS specific code in my ViewModels to make sure I don't update the data in a way that breaks ListView on Android 😭

Cybrosys avatar Feb 28 '24 15:02 Cybrosys

I am struggling with the same issue with ListViews on Android. It happens consistently when I'm pushing a new page to the navigation stack (Shell), over the one with the ListView, and then popping it. The outline of the list items and some of the UI elements are visible, but the the rest will only appear if I interact with the ListView in any way (scroll, resize). This is currently the main issue preventing the migration of our apps from Xamarin to MAUI.

istvan-convey avatar May 07 '24 10:05 istvan-convey

I'm getting similar issues with 8.0.21.

john-hollander avatar May 10 '24 11:05 john-hollander

Still getting this same issue on 9.*

corne-ac avatar Jul 15 '24 07:07 corne-ac

This bug still appears occasionally in 8.0.90.

guyvaio avatar Sep 21 '24 13:09 guyvaio