Repository navigation
Broadside v0.1.0-preview.8: new viewer shells, document builder, faster and smaller - #538
Merged
Merged
Conversation
…gments (#259) A JPX file whose first codestream box is a fragment table (ftbl holding an flst) is decoded from its in-file fragments joined in list order, identical to the unfragmented codestream. A fragment with a nonzero data reference (another file or a URL) is refused with JpxFragmentExternal and nothing is decoded; no file or network is opened. A fragment past the end of the file ends the list with JpxBoxInvalid, and the joined bytes never exceed the file length. A fragment table after a jp2c box is still only reported. Adds corpus jpx-fragmented.pdf (also a filter-jpx fuzz seed), a JpxEditing.Fragmented test helper, and marks row 7.4.9 done.
A linearized save of a MAC-protected document, or one newly protected, now carries a standalone AuthCode dictionary in the first-page trailer, the document's trailer (ISO 32000-2 F.3.4), instead of being refused. The byte range and MAC string are placeholders of their final widths in both renderings of the fixed-length beginning, so no offset, hint table entry or linearization parameter moves. Once every byte is known the byte range is filled in to cover the whole file but the MAC string (ISO/TS 32004 6.5.1) and the token is computed over the file in written order (6.6.2). The refusal tests become positive tests: the saved files reopen as Verified and pass qpdf --check and --check-linearization.
Add ColorFilter (None, DarkMode) with RenderOptions.WithColorFilter and SoftwareRasterizer.ColorFilter for display-list renders. The rasterizer runs the filter over the finished pixels: c' = c + alpha - max - min per channel (HSL lightness inverted, hue kept, exact integer arithmetic), and leaves the pixels images cover as rendered, tracked as an 8-bit coverage plane of image outlines. White paper becomes black; stencil masks, shadings and patterns are filtered like vector content. Default renders are unchanged. Skia, CoreGraphics, Direct2D, Android and WebGL page renders with a filter fall back to the software rasterizer. In the viewer, ViewerOptions.WithColorFilter and DocumentSession.ColorFilter choose the filter; ITileBackend and IRemoteTileRenderer gain default members that fall back to the software path, so toggling redraws tiles from the cached display lists without rebuilding them.
DocumentSearch indexes each page's words in the background (thread-pool workers under the session's read lease, or one page per cooperative slice in the browser) into an index that grows page by page, so the first matches arrive before indexing finishes. Queries ignore case and diacritics unless asked and can match whole words; folding uses a generated compatibility-decomposition table, so it works under invariant globalization. Results are quads per line; Next, Previous and MoveTo step through them; GetQuads feeds a highlight-all overlay. Closing the session or disposing the search stops indexing. The Blazor viewer exposes PdfViewer.Search and draws every match (and the current one distinctly) over the tiles without redrawing them; the demo's search panel uses it with case, whole-word and diacritics options in place of its ad-hoc page-by-page search.
…256) Predefined CMaps and the Registry-Ordering-UCS2 tables were parsed once per document. They are now parsed the first time any document of an engine needs them and shared, immutable, by every document and thread of that engine. The cache hangs off the engine's font resolver chain, so two engines share nothing (FontResolverChain.Default, a static, becomes CreateDefault). Only tables a resolver supplied are kept, at most 256 tables and 16 MiB of resource text; past that a document parses its own copy. Each document still records the diagnostics of the parse it used. Adds EngineSharedTableTests (parse counter over 100 documents, separate engines, concurrent first use, the bound) and a benchmark comparing the first Unicode lookup of a first and a second document.
Type 2 path arithmetic sums finite operands, which can pass the largest double, and a Font DICT matrix can scale a finite coordinate past it. The path builder now flags a non-finite current point or written point and the interpreter drops the glyph; the CID matrix adjustment drops it too. Both report the new FontCharstringCoordinateOverflow code. Type 1 finiteness checks now include the accent origin offset. Adds the reproducer as a font-cff fuzz seed and tests over the overflowing operands and the matrix.
…direct references (#305) A RemoveObject changes what a reference in an unchanged container resolves to (ISO 32000-2 §7.3.10). Two families of caches still missed it. Colour space views: which view a space gets (its family, or DeviceGray when it cannot be used) is decided when it is built, e.g. [/ICCBased 6 0 R] is ICCBased only while object 6 is a stream. Each view now records the references resolved while it was built (its own and those of the nested spaces it reads) with their targets. OnceCache gains an isCurrent hook on the stamped GetOrCreate: after an object is added or removed, a view whose references still resolve to the same objects is kept (same instance, so converter keys and render fast paths still hit) and re-recorded at the new stamp; any other view is built again. Views that resolved no reference are cached as the view alone, so they allocate nothing more. Decode caches: Caching/DecodeStamp records the document's ObjectsVersion only for streams whose Filter or DecodeParms is or holds an indirect reference. Applied to decoded content (single streams and Contents arrays), Type 3 glyph heads, font programs (key gains the dictionary version), encoding and ToUnicode CMaps, XMP packets and ICC profile headers. Unstamped entries keep their size. Tests per case: ICCBased stream, Indexed lookup and nested Pattern space removed; identity kept after an unrelated add and remove; ICC profile, content stream, Contents array and ToUnicode filter removed; DecodeParms removed.
PdfViewer gains a ColorFilter parameter (null keeps the session's own). A change sets DocumentSession.ColorFilter and redraws every tile from the cached display lists; the paper drawn before tiles arrive and the canvas around the pages turn dark with it. The render worker draws filtered tiles itself (the filter travels with each render request). The demo's View panel gets a Dark mode switch, covered by the demo browser test. Also: ColorFilterBenchmarks (0 B per replay, baseline entries added), the 10.7.1 conformance row and the Color filter term in CONTEXT.md.
…sk scaling rows (#473) Adds Vector128 rows for the kernels #492 left scalar: Compositor.Mix (a non-isolated group onto its backdrop), KnockOut, RemoveBackdrop and the scaling of a clip mask row by a partial coverage. Each has a scalar reference, a vector path and a dispatcher in CompositingRows, exhaustive bit-exact tests (also under DOTNET_EnableHWIntrinsic=0), a MemoryDiagnoser benchmark and a browser kernel case. Faster than scalar in the JIT, the browser interpreter and the browser AOT build; no allocations. Golden images unchanged.
… times per nested run (#257) GraphicsStateBenchmarks isolates the cost of a state copy (CopyState, about 23 ns for the 816-byte state) and of a q/Q pair (SaveRestore, about 83 ns). On the pinned real-world subset the q copies cost about 1 % of the most q-heavy pages, so the representation (two inline 32-float colors) is unchanged; the numbers and the reasoning are in docs/benchmarks/graphics-state-copies.md. Nested runs (forms, Type 3 glyphs, pattern cells, soft-mask groups) copied the state about ten times each: through the NestedRun property, building and adding the run frame, and enumerating frames by value in the recursion guard. The initial state now goes to RunNested by reference and frames are filled in place, leaving three copies. Type3GlyphBenchmarks: 4.49 ms to 3.74 ms. Interpretation stays allocation-free (new q/Q-heavy allocation test).
…ree (#258) A catalog whose Pages entry is absent or names an object the cross-reference information does not list now has its cross-reference information rebuilt by scanning when opened, kept only when the scan finds a catalog with a page tree (ISO 32000-2 §7.7.2, §7.7.3). The check reads the cross-reference entry only, so opening still parses the catalog and nothing else. When Pages still does not resolve, the page tree reader rebuilds the pages from the objects the file holds: page tree nodes without a parent, walked as roots, then page objects no walk reached, in object number order, inheriting through their Parent chain. Both paths report PagesMissing (Warning when pages are recovered, Error when none are) and throw it in strict mode. qpdf/minimal-linearize-pass1.pdf reads one page again, as in pdf.js and poppler. Nine real-world files change; seven gain pages (each agreeing with pdf.js, poppler or qpdf, or opened by none of them), two keep zero. The triage is in docs/research/pages-missing-triage.md; the real-world and pdf.js/qpdf content-gate snapshots are updated to match.
# Conflicts: # docs/conformance/iso-32000-2.md
# Conflicts: # src/Broadside.Viewer.Blazor/PublicAPI.Unshipped.txt # src/Broadside.Viewer/PublicAPI.Unshipped.txt
…ic in the MAUI view (#358) PdfView gains Search, Reveal, Redraw, ColorFilter and DocumentChanged on the viewer core (#215 DocumentSearch, #219 ColorFilter). The controller draws search matches as an overlay without redrawing tiles and composes a dark frame in dark mode. Internal panel logic (document facts, tag tree, annotation tools, signature status, layout changes) is free of MAUI types and tested on net10.0.
…h hand-written COM vtable structs (#360) CsWin32 emitted every requested COM interface with its inheritance chain, friendly overloads and callable wrapper stubs (725 generated files). Turn friendly overloads off, replace the interfaces the backend calls with blittable vtable structs that declare only the 218 methods it uses, and declare the four structures with interface-typed fields and D3D11CreateDevice by hand. CsWin32 still supplies the value types. Assembly: 1,654,272 B to 205,312 B. A trimmed app already dropped the unused surface (160,256 B to 157,184 B), so the gain is package size. Measurements in docs/benchmarks/direct2d-assembly-size.md.
…nd thumbnails (#216) DocumentOutline loads the outline as a snapshot tree of OutlineEntry whose destinations (explicit, named, through a GoTo action) resolve to ViewTarget values; ViewTarget.GetViewport shows every Table 149 view (XYZ, Fit, FitH, FitV, FitR and the bounding-box forms). PageLabelTable reads the page labels. PageThumbnails draws whole pages small from the document's shared display-list cache, one at a time and after the session's other pending work, with the session's color filter. The Blazor viewer gains PdfViewer.GoTo(ViewTarget), and the demo's Outline and Pages panels use the core instead of their own destination lookup and render loop.
Broadside.Viewer.Wpf adds PdfView, a FrameworkElement on the shared viewer core: document session, tile scheduler with separate overlay tiles, input model (mouse, touch, pen, wheel, keys), text selection with touch handles, annotation and link layers with a text box or combo box over focused fields, find-in-document with highlights, F3 and Reveal, smart dark mode through ColorFilter, and UI Automation peers: a document whose loaded pages carry their text in reading order as their value, with the accessibility bridge's nodes under them and the scroll pattern on the document. Tiles render off the UI thread with the managed software rasterizer and become frozen bitmaps drawn in OnRender. The MAUI head draws with Skia, which the WPF package may not depend on; Direct2D would read every tile back from the GPU into a CPU bitmap for WPF, so the software rasterizer is the default and hosts can still pick a backend with ViewerOptions.UseBackend. The controller is a port of the MAUI shell's, free of WPF types. Tests cover the controller, the reading-order text, the control and its peers on an STA thread, and a UI Automation test that starts the sample app and opens, reads, zooms, scrolls, selects and searches the pinned subset. CI runs them on the Windows leg; the package builds on every host like the Direct2D backend.
…UI tests (#358) Broadside.Viewer.Maui gains PdfSearchPanel, PdfOutlinePanel, PdfThumbnailsPanel, PdfAnnotationsPanel, PdfDocumentInfoPanel, PdfSignaturesPanel and PdfViewSettingsPanel, each bound to a PdfView, and PdfView.GoTo for outline targets (#216). Touch selection handles are drawn and grabbable only when the last pointer was not the mouse (the quirk #222 found). The MAUI sample gets the Blazor demo's feature set: a phone layout (compact top bar, bottom tool bar, bottom sheets) and a tablet/desktop layout (tool rail and sidebar), open from files, URL or the gallery, create PDF/A + PDF/UA with the shared DocumentCreator, save and share edits, and a tile renderer switch. An in-app UI test run (UiTests.cs, uitest.sh) drives every panel through its real controls; maui-ui.yml runs it on Mac Catalyst and the iOS simulator and maui-android.yml on the emulator after the smoke run.
…window saw for a wheel turn, and trace wheel input for the UI tests (#223) Ctrl+wheel did not zoom under the UI test's injected input, with the event's modifiers and WinUI's keyboard state for the thread already counted. The zoom path itself is the toolbar's (ProgressiveZoom.ZoomBy, state published every frame), so the modifiers or the event's delivery are what is missing. A wheel turn now also counts Win32's GetKeyState and any modifier whose key-down the window's content saw (handled or not) and whose key-up it has not, for up to 1.5 s (a held key repeats its key-down), and so do key presses. With BROADSIDE_WINUI_TRACE=1 (set by the UI test fixture) the sample logs every wheel turn the view handles (delta, the event's modifiers, both keyboard states, the held keys, the modifiers used, and whether it zoomed or scrolled with the zoom before and after), every modifier key, every wheel turn that reaches the window's content and every status line. A timed-out wait now carries the sample's diagnostics, as an early exit already did.
…fall inside it (#362) The cancellation test placed its seven cancel points at eighths of a "full" time that also counted building the page's display list. On the 2550 x 3150 catalogue photograph a reduction 1 decode takes about 44 ms, but the measured time was about 150 ms, so every point from 3/8 on (56 ms and later) came after the decode had already finished and only 2 or 3 of 7 decodes could be cancelled. Cancellation itself is prompt: a probe cancelling at 2, 5, 10, 20 and 40 ms saw latencies under 0.2 ms at reductions 0 and 1. The same failure reproduces on bc6125a, before the sweep, so no decoder change caused it; the margin was simply gone. Build the display list before starting the clock, keep the fastest of three decodes, and when a decode finishes before its cancel point (the JIT keeps optimizing it), place the remaining points within that faster decode instead of racing its completion. A decode that stops observing its token still fails: no point is ever cancelled, or the decode runs on past 10 ms. Reductions 2 and 3 are now covered too.
…e input workarounds the trace proved unneeded (#223) The input trace showed WinUI handling the injected Ctrl release before the injected wheel event that was sent between press and release, so the wheel arrived with no modifier held. The control's wheel handling was right; the test released Ctrl too early. This reverts the Win32 key-state and tracked-modifier fallbacks and the trace hook, and keeps the fixture's timeout diagnostics.
…put sent at once can reach WinUI out of order (#223)
…ag with real pointer moves in the UI test (#223) A mouse drag over text selected nothing in the WinUI UI test: the press started an empty caret selection and the release only ended the gesture, so a selection grew only through the moves in between. The test moved the mouse with FlaUI's Mouse.MoveTo, which repositions the cursor with SetCursorPos rather than sending mouse input, so the moves may never reach WinUI's pointer events. - ViewerController.PointerUp extends a Select or Handle gesture to the release point, so a move folded into the release, or not delivered at all, still selects up to where the pointer let go. - The UI test sends every drag step (move, press, moves, release) through SendInput at an absolute position, and waits for the sample's new selection line before it copies. - The sample shows the selection (Selected page:offset-page:offset) and, with BROADSIDE_WINUI_TRACE=1 (set by the UI tests), logs the pointer events the view receives and the selection at Copy, so a failed wait prints them.
…tead of throwing into the host's click handler The WinUI UI test's sample crashed with an unhandled TaskCanceledException from TextSelection.LoadPageAsync: Ctrl+A then Copy on a 180-page novel loads every page's text, the test failed its next step and closed the window, and the view's disposal canceled the copy still loading, which the sample's async void Copy handler rethrew into the dispatcher. The shells' GetSelectedTextAsync (WinUI, WPF, Avalonia, Uno, MAUI) now return null when the document closes under the copy (another document opened or the view disposed), so PdfView.CopySelectionAsync never throws for it. The WinUI sample shows "Copying…" until a copy ends (a reader of the line can no longer take the previous copy's count for this one's) and reports a failed copy instead of ending the app; the WPF sample reports one too. Tests: the controllers' copy overtaken by a replaced document and by disposal; and, in the viewer core, a page load that joined a list build its starter canceled still loads, and a whole-document copy runs to the end while tiles and lists of its pages are requested and canceled (sharing never hands one requester's cancellation to another).
…Invoke pattern SampleApp.Click invoked it through UIA's Invoke pattern, which a ToggleButton does not support (PatternNotSupportedException), so the sample test failed at its dark-mode step. SampleApp.Toggle uses the Toggle pattern.
… its inner hyphen dropped (#223)
…s for a moment; name the test's counts in camel case (#358)
…f the exact allocation gate (#397) A [BenchmarkCategory("NoAllocationGate")] case stays a normal benchmark and keeps its time comparison, but --gate-allocations lists it under NotGated instead of measuring it, and BenchGate neither wants a baseline entry for it nor reports it missing. Applied to the document builder cases that allocate 350 MB to 6 GB per call (garbage collections inside the call move the figure by bytes to kilobytes) and to InvoiceParallel; Hello and HelloFlow stay gated.
…so it does not read as a diagnostic code (#397)
… looking for its first line (#223)
…a short window can be a heading (#223)
… one only when none shows (#223)
… which may select the same word (#225)
…o it does not spill without AVX-512 (#335)
…ompute the decode stamp (#305)
Sweep 7B: hardening, viewer shells and features, size and performance, document builder
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.
Merges
spec/33-broadside-v1intomainfor v0.1.0-preview.8.mainis merged into the release branch with no conflicts; the tree is identical tospec/33-broadside-v1.Highlights
PdfDocument.Create(doc => ...)with sections, headers and footers, tables, links, a table of contents, form fields, PDF/UA and PDF/A profiles andAppendPages. Marked[Experimental("BROADSIDE0001")].Broadside.dllis 5.5% smaller, with Native AOT size probes gated in CI (Reduce the core library's shipped size (pay-for-play trimming, size probes) #361).New API
Broadside.Viewer.Wpf,Broadside.Viewer.WinUI,Broadside.Viewer.Avalonia,Broadside.Viewer.Uno.RenderOptions.WithGlyphPositioning(exact by default, quantized opt-in).PdfDocument.Create(...)builder (experimental),PdfColor.FromHex,PdfDocument.DefaultSaveOptions.Fixes