dotnet / dotnet/aspnetcore

Blazor Wasm: Virtualize component making 3 initial calls to ItemsProvider instead of 1

Open
#27,065 5 comments 5 reactions 0 assignees View on GitHub
affected-most area-blazor enhancement feature-blazor-virtualization Perf Pillar: Technical Debt Priority:2 severity-minor
Dominant language
C#
Stars
38.4k
Forks
10.9k
Avg merge
2d 10h
Merged PRs (30d)
281

Description

When using Virtualize component with ItemsProvider, I have noticed that the ItemsProvider is always called 3 times on the first render. This may be slightly excessive if we are calling an api inside the ItemsProvider.

As an example, I have a collection of 15000 items. On first render, the Virtualize component made 3 calls into the ItemsProvider:
1. Request Count=20, Start Index=0
2. Request Count=21, Start Index=14979 (=15000 - 21)
3. Request Count=21, Start Index=0

I am guessing that the component is doing this for some initial setup calculations of the scroll bar etc...however, the question is whether these 3 calls can be obviated by a single initial call, or is there a way to specify any additional arguments to the component perform its setup without performing 3 calls into ItemsProvider.

Reproduction is here: https://github.com/bancroftway/blazorissuesrepro/tree/dotnet5vscoll

A small video demo is here: https://www.youtube.com/watch?v=5BnRgZTpO0M

Contributor guide

Open the contributing guide

Research direction

Start with the linked dotnet5vscoll reproduction and inspect the Blazor Virtualize component's ItemsProvider calls during first render. Reproduce the three requested ranges, then trace the component's initial measurement and rendering flow. Done means establishing whether the extra calls are expected or changing the behavior with coverage for the reported request sequence.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, wasm
Domain
frontend, web-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.