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

Grouped CollectionView lazy loading does not trigger [RemainingItemsThresholdReached] on iOS and Windows #10078

Open
hbraasch opened this issue Sep 12, 2022 · 13 comments
Labels
area-controls-collectionview CollectionView, CarouselView, IndicatorView platform/android 🤖 platform/iOS 🍎 platform/macOS 🍏 macOS / Mac Catalyst platform/windows 🪟 s/triaged Issue has been reviewed s/verified Verified / Reproducible Issue ready for Engineering Triage t/bug Something isn't working
Milestone

Comments

@hbraasch
Copy link

Description

When populating a CollectionView with grouped data, the [RemainingItemsThresholdReached] event does not trigger for iOS and Windows when the [RemainingItemsThreshold] value is reached.

This works fine under Android.

A simple repro is provided.

See here how Android works (must admit, it throws a low-level exception each time the threshold is reached, but maybe that is by design)

Android.mp4

See here how iOS only loads the first chunk, then never triggers when scrolled down.

iOS.mp4

See here how Windows loads the first chunk, then never triggers when scrolled down.

Windows.mp4

Steps to Reproduce

  1. Load the project in VS from the Github repro
  2. Run the app for the three projects
  3. The applicable code is in file [StartupPage.cs]

Link to public reproduction project repository

https://github.com/hbraasch/ChunkTester.git

Version with bug

6.0.400

Last version that worked well

Unknown/Other

Affected platforms

iOS, Windows

Affected platform versions

Android 12 - API 31, windows10.0.19041.0

Did you find any workaround?

No

Relevant log output

No response

@hbraasch hbraasch added the t/bug Something isn't working label Sep 12, 2022
@jsuarezruiz jsuarezruiz added area-controls-collectionview CollectionView, CarouselView, IndicatorView platform/android 🤖 labels Sep 13, 2022
@PureWeen PureWeen added this to the Backlog milestone Sep 13, 2022
@ghost
Copy link

ghost commented Sep 13, 2022

We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.

@hbraasch
Copy link
Author

I consider this a serious problem. Since your [Image] component does not cache local files, it can take quite a long while to populate a CollectionView with images in its items. Lazy loading is the solution to this. Without a working lazy loading, it makes for a very frustrating user experience. Please reconsider this categorization.

@SophisticatedConsulting
Copy link

SophisticatedConsulting commented Feb 16, 2023

Please have a look at this - it is a show-stopper for Xamarin migration. @PureWeen, @jsuarezruiz

@JiuLing-zhang
Copy link

@hbraasch @SophisticatedConsulting Try this temporary solution in Windows:

<CollectionView Scrolled="CollectionView_Scrolled"/>
    private void CollectionView_Scrolled(object sender, ItemsViewScrolledEventArgs e)
    {
        //TODO WinUI 中,目前无法触发 RemainingItemsThresholdReachedCommand,因此先自己实现一下
        if (DeviceInfo.Current.Platform != DevicePlatform.WinUI)
        {
            return;
        }

        if (sender is CollectionView cv && cv is IElementController element)
        {
            var count = element.LogicalChildren.Count;
            if (e.LastVisibleItemIndex + 1 - count + cv.RemainingItemsThreshold >= 0)
            {
                if (cv.RemainingItemsThresholdReachedCommand.CanExecute(null))
                {
                    cv.RemainingItemsThresholdReachedCommand.Execute(null);
                }
            }
        }
    }

@SophisticatedConsulting

Thanks for the proposal @JiuLing-zhang.

Unfortunately, this does not work with a Grouped CollectionView - the EventArgs passed references the current group in the CollectionView (all of which is always visible). In my case this is a group of 20 items displayed vertically and which should add additional groups when scrolled horizontally. e.LastVisibleItemIndex is always 20 and less than element.LogicalChildren.Count.

It is not possible (as far as I can see) to find out when you have scrolled to the last group in the CollectionView and add the next.

If I remove the check, then the scroll event is called far too often and the CollectionView is populated with too many groups.

Any ideas?

@Zhanglirong-Winnie Zhanglirong-Winnie added s/triaged Issue has been reviewed s/verified Verified / Reproducible Issue ready for Engineering Triage labels May 26, 2023
@Zhanglirong-Winnie
Copy link
Collaborator

Verified this issue with Visual Studio 17.7.0 Preview 1.0. Can repro on windows and iOS platform with above project. Android works fine.
ChunkTester-master.zip
Android:
Android
Windows:
Windows
iOS:
iOS

@naaeef
Copy link

naaeef commented Nov 30, 2023

In #13391 I posted a workaround that fixes the problem for me on iOS.

@raelsonraujo
Copy link

Something worth mentioning, even with the workaround it only worked for me when RemainingItemsThreshold was different from 0.

@kevinxufei
Copy link
Collaborator

kevinxufei commented Dec 21, 2023

The issue also repro on Android platform.
Build version: 17.9.0 Preview 3.0 [34420.99.main]
Microsoft.Maui.Controls: 8.0.6-nightly.9783+sha.4d833eab0d-azdo.8835091
Android Api version: API 34
[ManualMauiTests.zip]

@alpayclsr1
Copy link

alpayclsr1 commented Jan 2, 2024

I am still experiencing this problem on iPad

@kramer-e
Copy link

kramer-e commented Mar 7, 2024

Our little bug is already 4 years old, he grows up so fast. It even learned to do its thing in .NET 8, I am so proud!

Thanks for the updated workaround with handler @naaeef

@AliKarimiENT
Copy link

We faced this issue again while we were on dotNet 8, and I used the @JiuLing-zhang suggestion and solved my issue that on iOS it was not working for static threshold

@plppp2001
Copy link

plppp2001 commented Apr 5, 2024

RemainingItemsThresholdReachedCommand doesn't trigger on Android either (net maui 8 latest). This is a show stopper.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-controls-collectionview CollectionView, CarouselView, IndicatorView platform/android 🤖 platform/iOS 🍎 platform/macOS 🍏 macOS / Mac Catalyst platform/windows 🪟 s/triaged Issue has been reviewed s/verified Verified / Reproducible Issue ready for Engineering Triage t/bug Something isn't working
Projects
None yet
Development

No branches or pull requests