Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
mfeingol opened this issue Jan 21, 2024 · 7 comments
Labels
area/ListView migration-compatibility Xamarin.Forms to .NET MAUI Migration, Upgrade Assistant, Try-Convert platform/android 🤖 s/needs-attention Issue has more information and needs another look t/bug Something isn't working
Milestone

Comments

@mfeingol
Copy link

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 mfeingol added the t/bug Something isn't working label Jan 21, 2024
@jsuarezruiz jsuarezruiz added area/ListView potential-regression This issue described a possible regression on a currently supported version., verification pending platform/android 🤖 labels Jan 22, 2024
@PureWeen PureWeen added the migration-compatibility Xamarin.Forms to .NET MAUI Migration, Upgrade Assistant, Try-Convert label Jan 22, 2024
@PureWeen
Copy link
Member

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

@PureWeen PureWeen added the s/needs-info Issue needs more info from the author label Jan 22, 2024
@ghost
Copy link

ghost commented Jan 22, 2024

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.

@PureWeen PureWeen removed the potential-regression This issue described a possible regression on a currently supported version., verification pending label Jan 22, 2024
@PureWeen PureWeen changed the title [Android] [Regression] ListView items disappear and reappear randomly when removing items from the list [Android] ListView items disappear and reappear randomly when removing items from the list Jan 22, 2024
@mfeingol
Copy link
Author

@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#

@ghost ghost added s/needs-attention Issue has more information and needs another look and removed s/needs-info Issue needs more info from the author labels Jan 22, 2024
@PureWeen
Copy link
Member

We most likely need to apply these same changes here to ListView
#20130

@PureWeen PureWeen added this to the Backlog milestone Feb 10, 2024
@ghost
Copy link

ghost commented Feb 10, 2024

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
Copy link

Cybrosys commented Feb 28, 2024

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 😭

@istvan-convey
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/ListView migration-compatibility Xamarin.Forms to .NET MAUI Migration, Upgrade Assistant, Try-Convert platform/android 🤖 s/needs-attention Issue has more information and needs another look t/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants