Skip to content

Conversation

github-actions[bot]
Copy link
Contributor

@github-actions github-actions bot commented Sep 22, 2025

Ensure Virtualize renders at least OverscanCount items when OverscanCount > MaxItemCount

Description

Issue #63651 reports incorrect behavior when OverscanCount exceeds MaxItemCount: the component could under‑render (large blank area, late loads) because the effective maximum item window was clamped too low, causing excessive “unused capacity” and spacer translation anomalies.

  • Updates Virtualize.cs (CalculateItemDistribution) to elevate the effective MaxItemCount to at least OverscanCount after applying the (legacy) AppContext override and the MaxItemCount parameter.
  • Adds an end-to-end Razor test component VirtualizationLargeOverscan.razor (in BasicTestApp) exercising OverscanCount="200" with MaxItemCount="5".
  • Adds an E2E test method CanElevateEffectiveMaxItemCount_WhenOverscanExceedsMax in VirtualizationTest.cs verifying:
    • At least 200 items render initially (effective max elevated)
    • Stable item count after scroll (no runaway growth or regression below overscan)
  • Registers the new component in Index.razor so the existing mounting infrastructure can locate it.

No public API surface changes; only internal logic and test assets updated.

Fixes #63651

Customer Impact

Addresses an issue with the Aspire dashboard.

Without the fix, apps that (intentionally or accidentally) configure a small MaxItemCount together with a large OverscanCount can observe:

  • Large blank gaps / delayed loading
  • Unintuitive scrolling behavior (spacers reserving space but items not materializing)
  • Potential perception of a frozen list

After the fix, Virtualize behaves predictably: it always renders enough items to satisfy the overscan window while still honoring the safeguard intent of MaxItemCount for realistic configurations.

Regression?

  • Yes
  • No

From 8.x for the aspire case. We don't believe this issue is common outside of the very specific usage Aspire does.

Risk

  • High
  • Medium
  • Low

Justification:

  • Change is a small, isolated conditional raising an internal working value (maxItemCount = OverscanCount when smaller).
  • Does not reduce correctness for normal cases (when MaxItemCount >= OverscanCount, behavior unchanged).
  • Covered by new targeted E2E test.
  • No API contract changes; no serialization / persistence impacts.

Verification

  • Manual (navigated and scrolled virtualization scenarios)
  • Automated (new E2E test passes; existing virtualization test suite still green)

Packaging changes reviewed?

  • Yes
  • No
  • N/A (No packaging / shipping artifact changes; only source + test updates)

@github-actions github-actions bot requested a review from a team as a code owner September 22, 2025 16:50
@lewing lewing added the Servicing-consider Shiproom approval is required for the issue label Sep 22, 2025
@danmoseley danmoseley added Servicing-approved Shiproom has approved the issue and removed Servicing-consider Shiproom approval is required for the issue labels Sep 22, 2025
@wtgodbe
Copy link
Member

wtgodbe commented Sep 22, 2025

Microsoft.AspNetCore.Components.E2ETest.ServerExecutionTests.ServerVirtualizationTest.CancelsOutdatedRefreshes_Async

OpenQA.Selenium.BrowserAssertFailedException : Xunit.Sdk.EqualException: Assert.Equal() Failure: Values differ
Expected: 1000
Actual:   0
at Xunit.Assert.Equal[T](T expected, T actual, IEqualityComparer1 comparer) in /_/src/xunit.assert/Asserts/EqualityAsserts.cs:line 154    at Microsoft.AspNetCore.E2ETesting.WaitAssert.<>c__DisplayClass20_0.<WaitAssertCore>b__0() in /home/vsts/work/1/s/src/Shared/E2ETesting/WaitAssert.cs:line 91    at Microsoft.AspNetCore.E2ETesting.WaitAssert.<>c__DisplayClass21_01.<WaitAssertCore>b__0(IWebDriver _) in /home/vsts/work/1/s/src/Shared/E2ETesting/WaitAssert.cs:line 109
Screen shot captured at '/home/vsts/work/1/s/src/Components/test/E2ETest/bin/screenshots/49077706fb2148c8bf27938ff90949ed.png'
Encountered browser errors
[2025-09-22T21:41:33Z] [Info] http://127.0.0.1:39991/subdir 66:16 "Blazor server-side"
[2025-09-22T21:41:33Z] [Info] http://127.0.0.1:39991/subdir/_framework/blazor.server.js 0:47991 "[2025-09-22T21:41:33.958Z] Information: Normalizing '_blazor' to 'http://127.0.0.1:39991/subdir/_blazor'."
[2025-09-22T21:41:33Z] [Info] http://127.0.0.1:39991/subdir/_framework/blazor.server.js 0:47991 "[2025-09-22T21:41:33.964Z] Information: WebSocket connected to ws://127.0.0.1:39991/subdir/_blazor?id=gVyZ5eTnHOmLH1S4SkQ4IA."Page content:


<head>
    <meta charset="utf-8">

          

              <BUTTON  aria-label="Copy to clipboard"  class='copy-btn bolt-button bolt-icon-button enabled subtle icon-only bolt-focus-treatment'>
                Copy to clipboard
                
                   
                
              </BUTTON>
              
<base href="/subdir/">
<link href="style.css" rel="stylesheet">
<link rel="icon" href="data:,">

<!-- Used by ExternalContentPackage -->
<link href="_content/TestContentPackage/styles.css" rel="stylesheet">
<link href="Components.TestServer.styles.css" rel="stylesheet">
<!--!--><!--!--><!--!--><title>Basic test app</title><!--!--><!--!--><!--!-->


          

          </head>
<body>
    <root>


    Select test:

@javiercn new E2E test failure, maybe related. At this point you'll need to redirect this PR to the RC2 branch

@wtgodbe wtgodbe merged commit 9ee3a38 into release/10.0 Sep 22, 2025
28 checks passed
@wtgodbe wtgodbe deleted the backport/pr-63765-to-release/10.0 branch September 22, 2025 23:36
@dotnet-policy-service dotnet-policy-service bot added this to the 10.0-rc2 milestone Sep 22, 2025
@javiercn
Copy link
Member

/backport to release/10.0-rc2

Copy link
Contributor Author

Started backporting to release/10.0-rc2: https://github.com/dotnet/aspnetcore/actions/runs/17981191649

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Servicing-approved Shiproom has approved the issue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants