Repository navigation
MarkdownRenderer structure step 2b: public SVG host API for resvg - #106
Merged
zhuowcui merged 1 commit intoOct 28, 2026
Merged
Conversation
The resvg pack plugged into the renderer through internal types in three groups. Each is now public API in MarkdownRenderer.Images, and resvg uses only public API. Memory admission and render priority. These are optional capabilities an IMarkdownSvgRenderer can implement; the views detect them: - IMarkdownSvgAdmission (TryOpenAsync, WaitForCapacityAsync), so the view waits for capacity instead of failing an image when the provider is full. - IMarkdownSvgPreparationAdmission and IMarkdownSvgPreparationLease, for PrepareSource scratch memory from the same capacity. - IMarkdownSvgPrioritizedDocument and MarkdownSvgRenderDemand, so queued renders move ahead when their image scrolls into view. Only Priority and RegisterPromotion are public; the view creates and raises demands. - MarkdownSvgAdmissionResult and MarkdownSvgAdmissionStatus. The internal names said "host" (OpenForHostAsync, MarkdownSvgDemandTicket and so on); the public names drop it. Raster checks. MarkdownRasterImageInspection.Inspect applies the renderer's own decode budget to encoded bytes without decoding them. resvg uses it before sending WebP and SVG-embedded rasters to its worker, instead of calling the renderer's internal budget parser. MarkdownRasterFormat gains Ico, which the parser already recognized. SVG source information. resvg reads an SVG's title, description and root size during its own validation pass, which a test holds to at least 30% fewer allocations than separate passes. It now does that with the public MarkdownSvgSourceInfoReader and hands the result over with MarkdownSvgSourcePreparation.Admit(bytes, info). The view's own fallback uses the same collector, so there is still one implementation. The opt-in layout-diagnostics build, which was already failing and is not part of CI, still stops in resvg: its #if diagnostics blocks write worker events into the renderer's internal event source and read its correlation ID. Step 4 replaces those blocks. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
zhuowcui
approved these changes
Oct 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Step 2, part 2 of the MarkdownRenderer structure cleanup. It targets the #103 branch, not
main.The resvg pack plugged into the renderer through 13 internal types. They are now public API in
MarkdownRenderer.Images, resvg uses only public API, and its internals grant is gone. Two grants remain (the performance harness and the sample), plus the TextMate grammar link; they come next.The public SVG host API
Memory admission and render priority. These are optional capabilities of
IMarkdownSvgRenderer; the views detect them.IMarkdownSvgAdmissionTryOpenAsyncopens a document if capacity allows, or reports how much it needs;WaitForCapacityAsynclets the view wait instead of failing the image.IMarkdownSvgPreparationAdmission,IMarkdownSvgPreparationLeasePrepareSourcescratch memory from the same capacity.IMarkdownSvgPrioritizedDocumentMarkdownSvgRenderDemandPriorityand callRegisterPromotion; only the view creates and raises demands.MarkdownSvgAdmissionResult,MarkdownSvgAdmissionStatusTryOpenAsync.The internal names said "host" (
OpenForHostAsync,RenderForHostAsync,MarkdownSvgDemandTicket); the public names drop it. Each type has its own file.Raster checks.
MarkdownRasterImageInspection.Inspect(bytes)applies the renderer's own decode budget to encoded bytes without decoding them. It reports format, size, frames, decoded bytes, orientation and whether a static preview fits. resvg uses it before sending WebP and SVG-embedded rasters to its worker; before, it called the renderer's internal budget parser.MarkdownRasterFormatgainsIco, which the parser already recognized.SVG source information. resvg reads an SVG's title, description and root size during its own validation pass. A test holds that single pass to at least 30% fewer allocations than separate passes. It now does this with the public
MarkdownSvgSourceInfoReaderand returnsMarkdownSvgSourcePreparation.Admit(bytes, info). The view's own fallback uses the same collector, so there is still one implementation.Decisions for review
MarkdownRasterImageInspectionfield by field with the internal budget it wraps, and the reader with the view's own extraction.Not covered
#ifdiagnostics blocks write worker events into the renderer's internal event source and read the renderer's SVG correlation ID. Step 4 replaces those blocks with a public tracing design. I updated the diagnostics-only tests to the new API, but they compile only in that build.Verification
MarkdownRenderer.slnxRelease x64JitHub.WinUIRelease x64 with the security gateReleaseSecuritytestsMarkdownRendererpackage consumed by NativeAOT and trimmed single-file--locked-moderestoreJitHub.Web, whose lock does not match this machine's SDK (10.0.14 vs 10.0.11), unchanged hereTest-ProjectStructure.ps1, engineering and compliance script self-testsAlso not run: PixelTests, the external performance-gate subset, and Sandbox UI runs.
🤖 Generated with Claude Code