Skip to content

Consolidate startup JS interop calls in Dashboard - #22659

Draft
4dwaffle wants to merge 1 commit into
microsoft:mainfrom
4dwaffle:perf/dashboard-startup-js-interop
Draft

4dwaffle wants to merge 1 commit into
microsoft:mainfrom
4dwaffle:perf/dashboard-startup-js-interop

Conversation

@4dwaffle

Copy link
Copy Markdown
Contributor

Description

Consolidates and parallelizes startup JavaScript interop calls in the Aspire Dashboard to reduce Blazor Server client–server round trips on initial page load (especially noticeable over remote/high-RTT connections):

  • BrowserDimensionWatcher: Combines window.getWindowDimensions and window.listenToWindowResize into a single window.initializeWindowDimensions call, guards null ViewportInformation in OnResizeAsync, and disposes the DotNetObjectReference in Dispose().
  • MainLayout: Runs ThemeManager.EnsureInitializedAsync() and window.registerGlobalKeydownListener concurrently on first render, skips the redundant initial import/updateTheme call (since app-theme-bootstrap.js and app-theme.js already apply the initial theme and refresh the cookie before Blazor boots), and lazily imports app-theme.js when the user changes the theme in Settings.
  • ResourcesLayout: Consolidates the 6 post-import startup calls (usesCommandSelectionModifier, registerTabOverflow, registerResourceOrdering, registerResourceContextMenu, registerPaneActivityVisibility, and initial registerPaneResizer) into a single initializeResourcesLayout call, and consolidates the 7 teardown calls in DisposeAsync into disposeResourcesLayout. Existing individual JS exports are preserved.

Round-trip savings

Component Before (sequential RTTs) After (sequential RTTs) RTTs saved
BrowserDimensionWatcher (OnAfterRenderAsync) 2 1 1
MainLayout (OnAfterRenderAsync) 6 3 3
ResourcesLayout (OnAfterRenderAsync) 7 2 5
ResourcesLayout (DisposeAsync) 7 1 6

Across initial load, this eliminates 9 sequential JS interop round trips (15 → 6 across the three components; 5 RTTs off the critical path once MainLayout and ResourcesLayout overlap after BrowserDimensionWatcher: 2 + max(6, 7) = 9 → 1 + max(3, 2) = 4), plus 6 fewer RTTs on ResourcesLayout disposal / run switching.

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?
    • 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
    • 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
    • No

@github-actions

Copy link
Copy Markdown
Contributor

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 22659

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 22659"

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant