You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Inserting a MarkupString with many top-level nodes is quadratic since .NET 11 (insertLogicalChild orphan scan) #70503
Since .NET 11, inserting a MarkupString with many top-level nodes is quadratic in the number of nodes.
insertLogicalChild in src/Components/Web.JS/src/Rendering/LogicalElements.ts gained an orphan-removal loop in #66007 ("Fix Blazor crash when interactive component is in layout with enhanced nav"). The loop walks the whole logical-children array of the parent on every call:
BrowserRenderer.insertMarkup calls insertLogicalChild once per top-level node of the parsed markup, into the same container, so inserting markup with n top-level nodes does about n²/2 sibling checks.
Expected Behavior
Inserting a large MarkupString costs about the same as on .NET 10.
Steps To Reproduce
Render a MarkupString holding many top-level elements, for example the HTML Markdig produces for a 1.2 MB Markdown document of short paragraphs (about 18,000 <p> elements, 1.3 MB of HTML), in a Blazor Server component.
Measured with the server's own RemoteRenderer log (Completing batch N without error in X ms, which runs when the browser confirms the batch), same machine, same 1,309,606-byte render batch, nothing else running:
Runtime
Batch confirmed after
.NET 10 (ASP.NET Core 10.0.x)
47 ms
.NET 11 (ASP.NET Core 11.0.0)
8,700 ms
.NET 11, same HTML inside one <div> (one top-level node)
23 ms
Under CPU load the .NET 11 case took 18.75 s.
Workaround
Wrap the markup in a single root element, so insertMarkup inserts one node and the browser's parser builds the rest.
Possible fix
Do the orphan sweep once per insertMarkup (or per render batch) rather than inside each insertLogicalChild, or only when the computed nextSibling is actually disconnected.
.NET Version
11.0.100
Anything else?
The same script is used by Blazor Hybrid (BlazorWebView), so MAUI and WPF/WinForms hosts are affected as well.
Area:area-blazor (insertLogicalChild in src/Components/Web.JS/src/Rendering/LogicalElements.ts, BrowserRenderer.insertMarkup) Type:Bug (insertion of a MarkupString with many top-level nodes is slower on .NET 11 than on .NET 10)
Regression Info
Previously working version: ASP.NET Core 10.0.x (batch confirmed after 47 ms, per reporter)
Failing version: ASP.NET Core 11.0.0 (batch confirmed after 8,700 ms, per reporter)
Same 1,309,606-byte render batch on the same machine; wrapping the markup in a single root element takes 23 ms on .NET 11 (reporter-supplied measurements).
Activity
github-actions commentedon Nov 11, 2026
Triage Summary
Area:
area-blazor(insertLogicalChildinsrc/Components/Web.JS/src/Rendering/LogicalElements.ts,BrowserRenderer.insertMarkup)Type:
Bug(insertion of a MarkupString with many top-level nodes is slower on .NET 11 than on .NET 10)Regression Info
Potential Duplicates