WindowsCommunityToolkit icon indicating copy to clipboard operation
WindowsCommunityToolkit copied to clipboard

incremental loading keeps calling GetPagedItemAsync infinitely

Open touseefbsb opened this issue 4 years ago • 9 comments

Sample repo to reproduce issue : https://github.com/touseefbsb/IncrementalLoadingBug

Describe the bug

I have a uwp app and I am using Windows Community Toolkit for the Incremental Loading feature on my list. Now the problem I am having it that it keeps calling GetPagedItemsAsync repeatedly without scrolling the list.

Explaination

So on my homepage I have a GridView on top bound to a collection of ModuleConfigurationDto and upon its item being selection I want to show the List of Evidences below the GridView, as each item has its own list of evidences and the selected item should show its list below.

So I used the community toolkit for incremental loading purpose that upon an item being selected it should load first set of items and then only on scrolling it calls the other set of items and so on.

Now the problem I am having it that it keeps calling GetPagedItemsAsync repeatedly even if I return a list with a single item in this method, and if I return an empty list in this method then it doesn't have this issue and UI just remains empty that way.

Steps to Reproduce

Steps to reproduce the behavior:

  1. Close the provided project and open it in visual studio
  2. Run the app.
  3. On top left side you will see 2 gridview items, click 1st of them called "Evidences"
  4. Notice that below in the Listview, Evidence items will keep on adding in a loop because GetPagedItemAsync is being called repeatedly without any scrolling.

Expected behavior

GetPagedItemsAsync method should execute only one on first time loading the list and then only when we actually need more items. i.e : scrolling the list.

Environment

NuGet Package(s): 
Microsoft.Toolkit.Uwp.UI

Package Version(s): 

I am using the latest version right now, i.e : 5.1.1

Windows 10 Build Number:
- [ ] Fall Creators Update (16299)
- [ ] April 2018 Update (17134)
- [ ] October 2018 Update (17763)
- [x ] May 2019 Update (18362)
- [ ] Insider Build (build number: )

App min and target version:
- [ ] Fall Creators Update (16299)
- [ x] April 2018 Update (17134)
- [ x] October 2018 Update (17763)
- [ ] May 2019 Update (18362)
- [ ] Insider Build (xxxxx)

Device form factor:
- [ x] Desktop
- [ ] Xbox
- [ ] Surface Hub
- [ ] IoT

Visual Studio 
- [ ] 2017 (version: )
- [ x] 2019 (version: 16.2.3 ) 
- [ ] 2019 Preview (version: )

Additional context

StackOverflow post : https://stackoverflow.com/questions/57657593/uwp-incremental-loadingkeep-calling-getpageditemasync-infinitely

Update :

Now I tried the exact example from the Windows Community Toolkit Sample App and put a PeopleListView on the lower half of the page, and it is also showing same bug . I have updated the sample app with that code as well, you can see on the bottom half of the page, all 40 people are loaded in 2 times executing of the method without me scrolling it, and when I scroll it it already has all the items so this time it returns 0 items.

if I increase the number of Evidences or people to 200, then for the 1st time it runs the the GetPagedItemAsync 2 times hence getting 40 items and then it stops executing it unless I scroll, so it works as expected only concern is why does it gets me 2 pages the 1st time when it should get me only 1? This is an issue for me because I am getting the data from a webapi so cant call too many useless calls.

if I change pageSize to 2 :

var collection = new IncrementalLoadingCollection<PeopleSource, Person>(itemsPerPage:2);

then it seems the method will keep calling itself until it has loaded about 40 items, which is about the double size of what the UI can show i.e : around 18, but interestingly if I change the pageSize to 40

 var collection = new IncrementalLoadingCollection<PeopleSource, Person>(itemsPerPage:40); 

then then method calls itself 2 times hence loading around 80 items.

touseefbsb avatar Aug 26 '19 18:08 touseefbsb

This issue has been marked as "Needs: Attention 👋" due to no activity for 7 days. Please triage and assign the issue so the fix can be established.

msftbot[bot] avatar Oct 18 '19 19:10 msftbot[bot]

This issue has been marked as "Needs: Attention 👋" due to no activity for 7 days. Please triage the issue so the fix can be established.

msftbot[bot] avatar Oct 25 '19 20:10 msftbot[bot]

This issue has been marked as "Needs: Attention 👋" due to no activity for 7 days. Please triage the issue so the fix can be established.

msftbot[bot] avatar Nov 01 '19 21:11 msftbot[bot]

This issue has been marked as "Needs: Attention 👋" due to no activity for 7 days. Please triage the issue so the fix can be established.

msftbot[bot] avatar Nov 08 '19 22:11 msftbot[bot]

This issue has been marked as "Needs: Attention 👋" due to no activity for 7 days. Please triage the issue so the fix can be established.

msftbot[bot] avatar Nov 15 '19 22:11 msftbot[bot]

This issue has been marked as "needs attention 👋" due to no activity for 15 days. Please triage the issue so the fix can be established.

msftbot[bot] avatar Nov 30 '19 23:11 msftbot[bot]

pls answer this

jeansusgodney avatar Apr 29 '20 13:04 jeansusgodney