dotnet / maui

.NET MAUI is the .NET Multi-platform App UI, a framework for building native device applications spanning mobile, tablet, and desktop.
https://dot.net/maui
MIT License
22.2k stars 1.75k forks source link

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

Open mfeingol opened 9 months ago

mfeingol commented 9 months ago

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

PureWeen commented 9 months ago

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

ghost commented 9 months ago

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.

mfeingol commented 9 months ago

@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#
PureWeen commented 8 months ago

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

ghost commented 8 months ago

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.

Cybrosys commented 8 months ago

Fighting with this issue myself at the moment.

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 😭

istvan-convey commented 5 months ago

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.

john-hollander commented 5 months ago

I'm getting similar issues with 8.0.21.

corne-ac commented 3 months ago

Still getting this same issue on 9.*

guyvaio commented 1 month ago

This bug still appears occasionally in 8.0.90.