Renders the viewer's content tiles in a Web Worker (#357): a second .NET runtime, booted from the app's own framework files, holds
its own copy of each document, builds its display lists and rasterizes its tiles, and hands each tile back as a transferable
ImageBitmap. The page's thread then only plans frames, presents finished tiles and draws the annotation and form-field
overlays (so edits never wait for the worker and never reach its copy). It needs no cross-origin isolation, so it works on any
static host; where Web Workers are missing, or the app does not serve the worker, the viewer draws every tile itself.
[SupportedOSPlatform("browser")]
public static class RenderWorker
Spec #33 viewer capability 1 (#357). Strictly opt-in: the library never starts the worker by itself. It costs a second
.NET runtime (boot time and memory, see docs/benchmarks/viewer-render-worker.md), so an app that wants it does all three of: serve
it from Main, start it with StartAsync(Nullable<TimeSpan>), and give each session a renderer with
UseRemoteRenderer(IRemoteTileRenderer). Without them every tile renders on the page's thread, as before.
The app's Main runs in the worker too, and must start with:
if (RenderWorker.IsWorker)
{
RenderWorker.Serve(() => new PdfEngine(options)); // the engine the page opens documents with
return;
}
Then StartAsync(Nullable<TimeSpan>) starts the worker once, and each document opened from bytes gets a renderer with
Open(ReadOnlySpan<Byte>, DisplayIntent) (options.UseRemoteRenderer(RenderWorker.Open(bytes, options.Intent)!)) or, for a
document read through range requests, Open(Uri, DisplayIntent). Password-protected documents are drawn on the page's thread.
kind:method, kind:property, kind:ctor. Press Esc to clear.IsRunningGets whether the worker is running and serving tiles (after StartAsync(Nullable<TimeSpan>) succeeded).IsWorkerGets whether this runtime is the render worker (the app's Main then calls Serve(Func<PdfEngine>) and returns).Open(ReadOnlySpan<Byte>, DisplayIntent)Sends a document to the worker and returns the renderer a session opened from the same bytes uses for its content tiles, or null when the worker is not running.Open(Uri, DisplayIntent)Has the worker open a document from an address through HTTP range requests (as OpenAsync(HttpClient, Uri, ViewerOptions?, CancellationToken) does on the page) and returns the renderer a session opened from the same address uses, or null when the worker is not running.Serve(Func<PdfEngine>)Serves tiles from this runtime, the worker's: documents are opened with the engine engine creates.StartAsync(Nullable<TimeSpan>)Starts the render worker once (later calls share the first): it boots the app's runtime in a Web Worker and waits until the app's Main has called Serve(Func<PdfEngine>).