Repository navigation
Keep dashboard views removed while they initialize from ending the circuit - #21995
Conversation
…he circuit Fluent UI's FluentDataGrid can resume OnAfterRenderAsync after it's disposed and call into the JavaScript module that disposal released (microsoft/fluentui-blazor#5580). FluentJSModule.Imported stays true after the module is disposed, so the grid's own check doesn't catch it. The ObjectDisposedException escapes OnAfterRenderAsync, and Blazor Server ends the circuit, which stops every view in the browser tab. It happens when a grid with resizable or reorderable columns is removed right after it rendered, for example by a layout change, and shows up in the dashboard's Playwright runs on main. AspireFluentDataGrid, which every dashboard grid uses, now ignores that exception when it comes from a grid whose disposal has started. The same exception from a grid still in use still surfaces. The workaround points to the issue and says what to remove once Fluent UI fixes it. Tests: a bUnit test removes a resizable grid while its JavaScript initialization is pending, then completes it, and checks that nothing reaches the renderer. A second test does the same with Fluent UI's FluentDataGrid and expects the exception, so it fails once a Fluent UI update fixes the bug, as the signal to remove the workaround.
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 21995Or
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 21995" |
There was a problem hiding this comment.
🟡 Changes recommended
Resizable grids in PropertyGrid and ResourceDetails still bypass the protected subclass, leaving them vulnerable to a circuit-ending initialization race when resource details are recreated across the desktop breakpoint.
1 open issue
What changed in this PR
Adds a disposal-aware workaround to the dashboard’s AspireFluentDataGrid to prevent late JavaScript initialization calls from ending the Blazor circuit.
Changes:
- Suppresses
ObjectDisposedExceptionafter grid disposal starts, while preserving errors from active grids. - Adds regression coverage for the workaround and a test that signals when Fluent UI fixes the underlying bug.
- Extends the shared JavaScript module fake to record calls rejected after disposal.
| File | Description |
|---|---|
| tests/Aspire.Dashboard.Components.Tests/Shared/TestJSObjectReference.cs | Records JavaScript calls rejected after disposal. |
| tests/Aspire.Dashboard.Components.Tests/Controls/AspireFluentDataGridTests.cs | Tests removal during initialization and tracks the upstream bug. |
| src/Aspire.Dashboard/Components/Controls/Grid/AspireFluentDataGrid.cs | Guards late initialization failures with a disposal flag. |
Review effort: Balanced
|
This comment has been minimized.
This comment has been minimized.
Twelve grids used FluentDataGrid directly, so they bypassed the workaround in AspireFluentDataGrid: the resource details' five grids, the span details' two, the property grid, the metric table and its filters, the exemplars dialog and the legacy metrics page. The resource details are recreated when the viewport crosses the desktop breakpoint, so their grids hit the race that ends the circuit. The workaround moves to DisposalSafeFluentDataGrid, which AspireFluentDataGrid derives from and those grids now use. They don't use AspireFluentDataGrid itself: it also turns header titles into dashboard tooltips and adds a loading view, which would change those grids beyond this fix. The class's remarks say what to undo once Fluent UI is fixed. The tests move to DisposalSafeFluentDataGridTests and cover both grids.
…hile loading Switching from Metrics to Traces right after opening an instrument could end the circuit (#21714). MeterOverview's first render imports its module and then asks it to observe the cards. When the overview is removed during the import, its container is gone by the time the module arrives: Blazor passes it to observeCards as null, querySelectorAll throws, and the JSException escapes OnAfterRenderAsync. Disposal also had nothing to release yet, so the module and observer leaked. - observeCards returns an observer that does nothing when it gets no container. - MeterOverview remembers that it was disposed, and releases a module or observer that arrives after disposal instead of observing cards that are gone. A bUnit test removes the overview while its module loads, and checks that the module is released without observing cards and that nothing reaches the renderer. It fails without the fix.
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
🟡 Changes recommended
Disposal during pending initialization can leak the returned grid controller and its document.body listeners; post-render cleanup and a regression test verifying the controller is stopped and disposed are still needed.
1 open issue
1 resolved since last review
Review effort: Balanced
…sposed Fluent UI stops the grid's JavaScript controller when the grid is disposed, but only a controller that has arrived. When disposal ran while the grid's Initialize call was pending, the controller arrived afterwards and kept the removed grid registered in the browser, with its click, mousedown and keydown listeners on document.body. That happened whether or not the late render then failed. DisposalSafeFluentDataGrid runs Fluent UI's controller cleanup, DisposeAsync(IJSObjectReference), again once a render that resumed after disposal completes. The cleanup stops and releases the controller once and does nothing after that. Tests: the shared TestJSObjectReference can return a value from a call, so Initialize returns a controller. The tests check that the late controller is stopped and released, with and without resizable columns, and the Fluent UI test checks that FluentDataGrid alone leaves it running.
Tests selector13 / 101 PR test projects · 2 PR jobs, from 14 changed files. Selected PR test projects (13 / 101)
Selected PR jobs (2)
How these were chosen — grouped by what changed
🔧 📦 affected project 🧪 🧪 🧪 Job reasons
Selection computed for commit |
|
Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt. |
|
✅ No documentation update needed. docs_optional → internal_refactor (proven false positive). Triggered signal: |
|
/backport to release/17.0 |
|
Started backporting to |
…m ending the circuit (#22058) Backport of #21995 to release/17.0 /cc @sebastienros ## Customer Impact ## Testing ## Risk ## Regression? --------- Co-authored-by: Sébastien Ros <1165805+sebastienros@users.noreply.github.com>
|
/backport to release/17.0 |
|
Started backporting to |
|
Sébastien Ros (@sebastienros) backporting to git am output$ git am --3way --empty=keep --ignore-whitespace --keep-non-patch changes.patch
Applying: Keep a dashboard grid removed during its initialization from ending the circuit
Using index info to reconstruct a base tree...
M src/Aspire.Dashboard/Components/Controls/Grid/AspireFluentDataGrid.cs
M tests/Aspire.Dashboard.Components.Tests/Shared/TestJSObjectReference.cs
Falling back to patching base and 3-way merge...
Auto-merging src/Aspire.Dashboard/Components/Controls/Grid/AspireFluentDataGrid.cs
Auto-merging tests/Aspire.Dashboard.Components.Tests/Shared/TestJSObjectReference.cs
Applying: Route the dashboard's other grids through the Fluent UI workaround
Using index info to reconstruct a base tree...
M src/Aspire.Dashboard/Components/Controls/Chart/ChartFilters.razor
M src/Aspire.Dashboard/Components/Controls/Chart/MetricTable.razor
M src/Aspire.Dashboard/Components/Controls/Grid/AspireFluentDataGrid.cs
M src/Aspire.Dashboard/Components/Controls/PropertyGrid.razor
M src/Aspire.Dashboard/Components/Controls/ResourceDetails.razor
M src/Aspire.Dashboard/Components/Controls/SpanDetails.razor
M src/Aspire.Dashboard/Components/Dialogs/ExemplarsDialog.razor
M src/Aspire.Dashboard/Components/Legacy/Pages/Metrics.razor
Falling back to patching base and 3-way merge...
Auto-merging src/Aspire.Dashboard/Components/Controls/Grid/AspireFluentDataGrid.cs
Auto-merging src/Aspire.Dashboard/Components/Controls/Grid/DisposalSafeFluentDataGrid.cs
CONFLICT (add/add): Merge conflict in src/Aspire.Dashboard/Components/Controls/Grid/DisposalSafeFluentDataGrid.cs
Auto-merging src/Aspire.Dashboard/Components/Legacy/Pages/Metrics.razor
Auto-merging tests/Aspire.Dashboard.Components.Tests/Controls/DisposalSafeFluentDataGridTests.cs
CONFLICT (add/add): Merge conflict in tests/Aspire.Dashboard.Components.Tests/Controls/DisposalSafeFluentDataGridTests.cs
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
hint: When you have resolved this problem, run "git am --continue".
hint: If you prefer to skip this patch, run "git am --skip" instead.
hint: To restore the original branch and stop patching, run "git am --abort".
hint: Disable this message with "git config set advice.mergeConflict false"
Patch failed at 0002 Route the dashboard's other grids through the Fluent UI workaround
Error: The process '/usr/bin/git' failed with exit code 128 |
## Description Update both dashboard experiences from FluentUI 5.0.1 to [5.1.0](https://github.com/microsoft/fluentui-blazor/releases/tag/v5.1.0), incorporating upstream fixes for grid disposal, virtualized refresh, tabs, splitters, dialogs, and accessibility. - Remove the DataGrid disposal workaround introduced in #21995 and the redundant virtualized refresh/render helper. The upstream fix now releases controllers that arrive after disposal and prevents subsequent interop calls. - Adapt all four freeform comboboxes to use string values with separate option selection, preserving custom text, option keys and display labels. Without this adjustment, 5.1 attempts to convert freeform text to a wrapper object and ends the Blazor circuit. - Add lifecycle and browser regression coverage, and adjust browser test synchronization for server-rendered tab navigation. Fixes # (issue) ### User-facing usage In either dashboard, users can enter a custom structured-log filter, leave the input, and apply it. Navigating away while a grid is initializing no longer requires the local disposal workaround. ### Screenshots / Recordings     ### Validation - **Passed: 1,454 component tests** (quarantined and outerloop excluded). ```bash dotnet test --project tests/Aspire.Dashboard.Components.Tests/Aspire.Dashboard.Components.Tests.csproj --no-launch-profile -- --filter-not-trait 'quarantined=true' --filter-not-trait 'outerloop=true' ``` - **Passed: 22 targeted Chromium cases**, including grid disposal/navigation, column sizing and sorting, tabs, responsive filters, dialogs, accessibility, and freeform filters in both experiences. These explicitly targeted browser cases are marked outerloop. ```bash dotnet test --project tests/Aspire.Dashboard.Playwright.Tests/Aspire.Dashboard.Playwright.Tests.csproj --no-launch-profile -- --filter-method '*.GridRemovedDuringInitialization_*' --filter-method '*.GridColumn_DoubleClickResizeHandle_*' --filter-method '*.NameColumn_SortsParameters' --filter-method '*.PreviousDashboard_InternalNavigationRemainsInLegacyLayout' --filter-method '*.SelectionAndResize_PreserveAvailableTracesTab' --filter-method '*.DashboardDialog_HasNoSeriousOrCriticalWcagViolations' --filter-method '*.FluentInteractiveControls_ExposeNameRoleAndValue' --filter-method '*.FilterAndGrouping_StayInsideVisualViewportAcrossPaneModesAndResize' --filter-method '*.LegacyDetailsSplitter_ResizesAndReopensAfterDismissal' --filter-method '*.SettingsDialog_ReopensAfterClosing' --filter-method '*.FilterDialog_PreservesFreeformValueOnBlur' --filter-not-trait 'quarantined=true' ``` - The four grid lifecycle cases pass on 5.1.0 without the local workaround and fail as expected on 5.0.1. The browser test delays real grid initialization, navigates away, verifies controller cleanup, and returns to a working grid. - A responsive tooltip timing failure was observed during exploration and reproduced on 5.0.1; the final responsive matrix passed. Firefox, WebKit, and declarative-dialog Escape reopening were not tested. ## Checklist - Is this feature complete? - [ ] Yes. Ready to ship. - [ ] No. Follow-up changes expected. - Are you including unit tests for the changes and scenario tests if relevant? - [x] Yes - [ ] No - Did you add public API? - [ ] Yes - If yes, did you have an API Review for it? - [ ] Yes - [ ] No - Did you add `<remarks />` and `<code />` elements on your triple slash comments? - [ ] Yes - [ ] No - [x] No - Does the change make any security assumptions or guarantees? - [ ] Yes - If yes, have you done a threat model and had a security review? - [ ] Yes - [ ] No - [x] No --------- Co-authored-by: Sébastien Ros <1165805+sebastienros@users.noreply.github.com> Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Co-authored-by: James Newton-King <james@newtonking.com>


Description
Fixes #21714
Two components could end the dashboard's Blazor circuit, which stops every view in the browser tab, when they were removed while their first render was still talking to the browser. Switching tabs or crossing the desktop breakpoint right after a view opened was enough.
Fluent UI grids (workaround for microsoft/fluentui-blazor#5580)
FluentDataGrid.OnAfterRenderAsyncawaits JavaScript calls, such as the grid's initialization. When a grid with resizable or reorderable columns is removed during one of them, it resumes after disposal and calls into the JavaScript module that disposal released.FluentJSModule.Importedstaystrueafter the module is disposed, so the grid's own check doesn't catch it, and theObjectDisposedExceptionescapesOnAfterRenderAsync:DisposalSafeFluentDataGridignores that exception when it comes from a grid whose disposal has started. The same exception from a grid that's still in use still surfaces. Fluent UI's own disposal flag is internal, so the grid sets its own inDisposeAsync.click,mousedownandkeydownlisteners ondocument.body. The grid runs Fluent UI's controller cleanup again once a render that resumed after disposal completes. The cleanup stops and releases the controller once and does nothing after that.AspireFluentDataGridderives from it, and the 12 grids that usedFluentDataGriddirectly now use it: resource details (5), span details (2), the property grid, the metric table and its filters, the exemplars dialog and the legacy metrics page. They don't useAspireFluentDataGriditself, because it also turns headertitles into dashboard tooltips and adds a loading view.Metrics overview (the crash reported in #21714)
MeterOverview's first render imports its module and then asks it to observe the cards. When the overview is removed during the import, for example by switching from Metrics to Traces right after opening an instrument, its container is gone by the time the module arrives. Blazor passes the container toobserveCardsasnull, andquerySelectorAllthrows:observeCardsreturns an observer that does nothing when it gets no container.MeterOverviewremembers that it was disposed and releases a module or observer that arrives afterwards. Disposal had nothing to release yet, so they leaked before.Tests
DisposalSafeFluentDataGridTests.RemovedWhileInitializing_IgnoresTheLateCallInsteadOfEndingTheCircuit(both grid types) removes a resizable grid while its JavaScript initialization is pending, then completes it. It checks that the late call was rejected, nothing reached the renderer, and the controller that arrived after disposal was stopped and released. It fails with the workaround disabled.RemovedWhileInitializing_StopsTheGridControllerThatArrivesAfterDisposalchecks the same cleanup for a grid without resizable columns, whose late render completes without an error.FluentDataGrid_StillCallsIntoItsDisposedModuleWhenRemovedWhileInitializingdoes the same with Fluent UI'sFluentDataGridand expects the exception, and that the late controller is left running. It fails once a Fluent UI update fixes the bug, which is the signal to remove the workaround.MeterOverview_RemovedWhileItsModuleLoads_ReleasesTheModuleWithoutObservingCardsremoves the overview while its module loads. It checks that the module is released, the cards aren't observed, and nothing reaches the renderer. It fails without the fix.TestJSObjectReferencerecords the calls it rejects after disposal, and can return a value from a call.Aspire.Dashboard.Components.Testsproject passes (1405 tests).main(MobileNavMenuClosesWhenFocusLeavesMenu,MobileNavFocusRemainsVisibleAtHighZoomViewport,ResourceRowModifierClicks_SelectSeveralResourceswith a Windows user agent, andCloseThenTab_OpensTheChosenTabForAllResourcesWithoutBouncingBackat 1000px). Seven more failed under parallel load and pass when run on their own. No circuit ended because of a grid or the metrics overview.SelectionAndResize_PreserveAvailableTracesTab, which resizes the viewport across layouts, failed in 5 of 14 executions onmain's code, and one of those runs logged the grid crash. With the workaround, no run ended the circuit. It still fails occasionally on a focus check (#tracesScrollContainer), which also happens onmainwithout the crash.Checklist
<remarks />and<code />elements on your triple slash comments?