Fix PdfViewer issues with Blazor WASM (#12654)#12655
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (2)
📒 Files selected for processing (98)
WalkthroughPDF viewer loading, asynchronous rendering, PDF processing, browser scheduling, responsive placeholders, WebAssembly runtime support, demos, and tests are updated. ChangesPDF viewer performance and rendering
Estimated code review effort: 5 (Critical) | ~120 minutes Sequence Diagram(s)sequenceDiagram
participant Browser
participant PdfViewerTS
participant BitPdfViewer
participant BrowserEventLoop
Browser->>PdfViewerTS: scroll PDF surface
PdfViewerTS->>PdfViewerTS: throttle and prioritize placeholders
PdfViewerTS->>BitPdfViewer: request page fragments
BitPdfViewer->>BrowserEventLoop: delay between queued renders
BrowserEventLoop-->>BitPdfViewer: resume render pump
BitPdfViewer-->>Browser: update rendered page
Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (3)
src/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/BitPdfViewer.razor.cs (3)
261-291: 🩺 Stability & Availability | 🟠 Major | ⚡ Quick winTwo remaining batch-render loops still lack the per-item yield the new pumps use. Both
Print()andRunSearchAsync()render a batch of missing pages synchronously in one stretch; on WASM's single UI thread this reproduces the same freeze the queuedEnsurePagesRendered/EnsureThumbsRenderedpumps were built to avoid.
src/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/BitPdfViewer.razor.cs#L261-L291: add a periodicawait Task.Delay(1)inside the for-loop (e.g. every few pages) so the browser can paint/respond while printing prepares a large document.src/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/BitPdfViewer.razor.cs#L1054-L1090: add the same periodic yield inside the match-rendering loop to bound the worst case when a search term matches many pages.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/BitPdfViewer.razor.cs` around lines 261 - 291, The Print() page-rendering loop and RunSearchAsync() match-rendering loop block the WASM UI thread while processing large batches. Add the same periodic await Task.Delay(1) yield used by the existing rendering pumps inside both loops, including the cited sites at src/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/BitPdfViewer.razor.cs lines 261-291 and 1054-1090, so the browser can paint and respond during long operations.
1054-1090: 🩺 Stability & Availability | 🟡 Minor | ⚡ Quick winSame batch-render-without-yield pattern as
Print(), narrower blast radius.
RunSearchAsync's match-rendering loop (1074-1083) also renders every matched page synchronously in one stretch. The inline comment reasons this is fine because matches are typically few, which is usually true, but a query matching a large fraction of pages (e.g. a common word in a big document) would still stall the UI thread for that whole render burst. Shares the same root cause as thePrint()finding above.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/BitPdfViewer.razor.cs` around lines 1054 - 1090, Update RunSearchAsync’s matched-page rendering loop to yield periodically while processing pages, rather than rendering all matches in one synchronous batch. Preserve the existing text-index search, lazy page rendering, loading-state updates, and final repaint behavior while ensuring large result sets do not monopolize the UI thread.
738-769: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick winDoc comment no longer matches the eager-render behavior.
The XML comment above
PreparePagesstill says "Only a small window around the current page is rendered up front"-style wording (unchanged), but the implementation now eagerly renders only the single current page (center), not a window.📝 Proposed doc fix
/// <summary> /// Measures every page (cheap) and creates an empty render slot for each so /// the document surface, scrollbar and page count are correct immediately. - /// Only a small window around the current page is rendered up front; the - /// rest are rendered on demand as they approach the viewport. + /// Only the current page is rendered up front; the rest (including its + /// neighbors) are rendered on demand as they approach the viewport. /// </summary>🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/BitPdfViewer.razor.cs` around lines 738 - 769, Update the XML documentation for PreparePages to state that only the current page is rendered eagerly, while neighboring pages are rendered later on demand by the lazy-render pump. Remove the inaccurate wording that claims a small window is rendered up front.
🧹 Nitpick comments (1)
src/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/BitPdfViewer.razor.cs (1)
344-351: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick winConsider a
HashSet<int>alongside theQueue<int>for O(1) membership checks.
_renderQueue.Contains(idx)/_thumbQueue.Contains(idx)are linear scans, run once per candidate page on every throttled scroll pass. Queue sizes are small today, so this isn't urgent, but a pairedHashSet<int>(add/remove alongside the enqueue/dequeue) would make the dedup O(1) and also lets you drop the duplicate pump/version/dequeue-loop boilerplate betweenEnsurePagesRenderedandEnsureThumbsRenderedinto one generic helper if you want to reduce duplication.Also applies to: 401-408
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/BitPdfViewer.razor.cs` around lines 344 - 351, The page-rendering and thumbnail queue membership checks are linear because EnsurePagesRendered and EnsureThumbsRendered call Queue.Contains. Add paired HashSet<int> tracking for each queue, update the sets whenever items are enqueued or dequeued, and use set membership for deduplication while preserving existing queue behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/BitPdfViewer.razor.cs`:
- Around line 334-441: The render pumps in EnsurePagesRendered and
EnsureThumbsRendered must stop when the component is disposed. Check IsDisposed
before dequeuing or rendering on each loop iteration, and update DisposeAsync to
clear both _renderQueue and _thumbQueue so pending work cannot resume against
the torn-down component.
In
`@src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Extras/PdfViewer/BitPdfViewerDemo.razor.cs`:
- Around line 361-403: The example snippets for examples 2, 4, and 5 still
demonstrate eager readonly PDF loading. Update the corresponding example C#
snippet fields and handlers to match the demo’s nullable BitPdfSource? fields
and Load document button flow, including on-demand assignment via
BitPdfSource.FromUrl; use the existing symbols and patterns in BitPdfViewerDemo
for consistency.
- Around line 348-357: Update ReadFileSource and the two corresponding copied
examples to cast IBrowserFile.Size to int when allocating the byte array.
Preserve the existing stream reading and BitPdfSource creation behavior.
---
Outside diff comments:
In `@src/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/BitPdfViewer.razor.cs`:
- Around line 261-291: The Print() page-rendering loop and RunSearchAsync()
match-rendering loop block the WASM UI thread while processing large batches.
Add the same periodic await Task.Delay(1) yield used by the existing rendering
pumps inside both loops, including the cited sites at
src/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/BitPdfViewer.razor.cs
lines 261-291 and 1054-1090, so the browser can paint and respond during long
operations.
- Around line 1054-1090: Update RunSearchAsync’s matched-page rendering loop to
yield periodically while processing pages, rather than rendering all matches in
one synchronous batch. Preserve the existing text-index search, lazy page
rendering, loading-state updates, and final repaint behavior while ensuring
large result sets do not monopolize the UI thread.
- Around line 738-769: Update the XML documentation for PreparePages to state
that only the current page is rendered eagerly, while neighboring pages are
rendered later on demand by the lazy-render pump. Remove the inaccurate wording
that claims a small window is rendered up front.
---
Nitpick comments:
In `@src/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/BitPdfViewer.razor.cs`:
- Around line 344-351: The page-rendering and thumbnail queue membership checks
are linear because EnsurePagesRendered and EnsureThumbsRendered call
Queue.Contains. Add paired HashSet<int> tracking for each queue, update the sets
whenever items are enqueued or dequeued, and use set membership for
deduplication while preserving existing queue behavior.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 88c6459d-7c42-4197-b413-423b79eeed05
⛔ Files ignored due to path filters (2)
src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/wwwroot/samples/hello-world.pdfis excluded by!**/*.pdfsrc/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/wwwroot/samples/sample-pdf.pdfis excluded by!**/*.pdf
📒 Files selected for processing (5)
src/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/BitPdfViewer.razor.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/BitPdfViewer.scsssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/BitPdfViewer.tssrc/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Extras/PdfViewer/BitPdfViewerDemo.razorsrc/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Extras/PdfViewer/BitPdfViewerDemo.razor.cs
|
@coderabbitai full-review |
|
✅ Action performedFull review finished. |
There was a problem hiding this comment.
Actionable comments posted: 2
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
src/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/BitPdfViewer.razor.cs (2)
1197-1235: 🩺 Stability & Availability | 🟠 Major | ⚡ Quick winAdd a
_loadVersioncheck around the search loop.RunSearchAsyncyields multiple times, so a source change can invalidate_document/_pageTextmid-run and crash on the next iteration. Snapshot_loadVersionand exit when it changes, like the other async pumps here.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/BitPdfViewer.razor.cs` around lines 1197 - 1235, Update RunSearchAsync to snapshot _loadVersion before its yielding search loop and check it during each iteration, exiting immediately when the version changes. Ensure the check occurs before accessing _document.Pages or _pageText after an await, following the validation pattern used by the other async pumps.
1285-1309: 🩺 Stability & Availability | 🟠 Major | ⚡ Quick winDon't dispose
_renderGateuntil render work is drained
RenderPageAsync/RenderThumbAsynccan still be in theirfinallyblocks whenDisposeAsyncruns, so disposing the semaphore here can throw on_renderGate.Release().IsDisposedis only set inbase.DisposeAsync(disposing)at the end, so stop new render work and wait for any in-flight render to exit before disposing the gate.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/BitPdfViewer.razor.cs` around lines 1285 - 1309, Update DisposeAsync and the RenderPageAsync/RenderThumbAsync lifecycle so disposal first prevents new render work, then waits for in-flight render operations to finish before calling _renderGate.Dispose(). Ensure each render method can complete its finally block and release _renderGate safely, and preserve the existing cleanup and base.DisposeAsync flow.
♻️ Duplicate comments (2)
src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Extras/PdfViewer/BitPdfViewerDemo.razor.cs (1)
399-415: 📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick winUpdate the example 3 snippets to match the lazy-loading demo.
The actual demo in
src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Extras/PdfViewer/BitPdfViewerDemo.razor, Lines 55-58, now has a “Load document” button and a nullablecanvasSource. These embedded snippets still omit the button and eagerly initializecanvasSource, so copied code can reintroduce startup rendering and does not reflect the live example.Suggested update
private readonly string example3RazorCode = @" +<BitButton IsEnabled=""canvasSource is null"" + OnClick='() => canvasSource = BitPdfSource.FromUrl(""url-to-the-pdf-file.pdf"", ""file-name.pdf"")'>Load document</BitButton> + +<br /><br /> <InputFile OnChange=""OnCanvasFileChange"" accept="".pdf,application/pdf"" /> <BitPdfViewer Source=""canvasSource"" RenderMode=""BitPdfRenderMode.Canvas"" />"; private readonly string example3CsharpCode = @" -private BitPdfSource canvasSource = BitPdfSource.FromUrl(""url-to-the-pdf-file.pdf"", ""file-name.pdf""); +private BitPdfSource? canvasSource;🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Extras/PdfViewer/BitPdfViewerDemo.razor.cs` around lines 399 - 415, Update the example3RazorCode and example3CsharpCode snippets to match the lazy-loading implementation in BitPdfViewerDemo: include the “Load document” button and nullable canvasSource declaration, and move PDF source creation into the button-triggered flow so the viewer does not render at startup. Keep the file-selection handling consistent with the live example.src/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/BitPdfViewer.razor.cs (1)
391-419: 🩺 Stability & Availability | 🟠 Major | ⚡ Quick winRender pumps still race disposal after a page/thumb finishes rendering.
The
IsDisposed/_loadVersioncheck now guards dequeuing (addressing the earlier review), but afterawait RenderPageAsync(idx)/await RenderThumbAsync(idx)returns,EvictDistantPages()/EvictDistantThumbs()andStateHasChanged()run unconditionally.RenderPageAsync/RenderThumbAsyncthemselves await_renderGate.WaitAsync()and, withBackgroundRendering,Task.Run(...)— both real yield points during which disposal can complete. The pump then resumes and callsStateHasChanged()against a torn-down component.🛡️ Proposed fix: re-check after the render, before touching UI state
int idx = _renderQueue.Dequeue(); _renderQueued.Remove(idx); if (await RenderPageAsync(idx) is false) continue; + if (IsDisposed || version != _loadVersion) + { + _renderQueue.Clear(); + _renderQueued.Clear(); + return; + } EvictDistantPages(); StateHasChanged(); await Task.Delay(1);(mirror the same check in
EnsureThumbsRenderedafterRenderThumbAsync.)Also applies to: 449-474
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/BitPdfViewer.razor.cs` around lines 391 - 419, Re-check disposal and load-version validity immediately after each awaited RenderPageAsync and RenderThumbAsync call, before invoking EvictDistantPages/EvictDistantThumbs or StateHasChanged. Apply the same guard in the render loop and EnsureThumbsRendered, clearing the corresponding queues and returning when IsDisposed or the captured version no longer matches.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/BitPdfViewer.razor.cs`:
- Around line 838-915: The BuildPage method can dereference _document after
LoadAsync clears it during a queued background render. Guard BuildPage against a
null _document by capturing a safe local snapshot and returning a discardable
result, or otherwise coordinating the build so it cannot access cleared state;
preserve RenderPageAsync’s existing stale-build discard behavior.
In
`@src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Extras/PdfViewer/BitPdfViewerDemo.razor.cs`:
- Around line 359-361: Update the PDF upload handling around
e.File.OpenReadStream and the byte-array allocation to validate e.File.Size
against the intended maximum before allocating or reading. Reject oversized
files early, or replace full-file buffering with bounded streaming, while
preserving normal processing for accepted PDFs.
---
Outside diff comments:
In `@src/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/BitPdfViewer.razor.cs`:
- Around line 1197-1235: Update RunSearchAsync to snapshot _loadVersion before
its yielding search loop and check it during each iteration, exiting immediately
when the version changes. Ensure the check occurs before accessing
_document.Pages or _pageText after an await, following the validation pattern
used by the other async pumps.
- Around line 1285-1309: Update DisposeAsync and the
RenderPageAsync/RenderThumbAsync lifecycle so disposal first prevents new render
work, then waits for in-flight render operations to finish before calling
_renderGate.Dispose(). Ensure each render method can complete its finally block
and release _renderGate safely, and preserve the existing cleanup and
base.DisposeAsync flow.
---
Duplicate comments:
In `@src/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/BitPdfViewer.razor.cs`:
- Around line 391-419: Re-check disposal and load-version validity immediately
after each awaited RenderPageAsync and RenderThumbAsync call, before invoking
EvictDistantPages/EvictDistantThumbs or StateHasChanged. Apply the same guard in
the render loop and EnsureThumbsRendered, clearing the corresponding queues and
returning when IsDisposed or the captured version no longer matches.
In
`@src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Extras/PdfViewer/BitPdfViewerDemo.razor.cs`:
- Around line 399-415: Update the example3RazorCode and example3CsharpCode
snippets to match the lazy-loading implementation in BitPdfViewerDemo: include
the “Load document” button and nullable canvasSource declaration, and move PDF
source creation into the button-triggered flow so the viewer does not render at
startup. Keep the file-selection handling consistent with the live example.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 6e555480-958f-4cbd-a902-d2b796e94ded
⛔ Files ignored due to path filters (2)
src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/wwwroot/samples/hello-world.pdfis excluded by!**/*.pdfsrc/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/wwwroot/samples/sample-pdf.pdfis excluded by!**/*.pdf
📒 Files selected for processing (9)
src/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/BitPdfViewer.razorsrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/BitPdfViewer.razor.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/BitPdfViewer.scsssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/BitPdfViewer.tssrc/BlazorUI/Demo/Bit.BlazorUI.Demo.Server/Startup/Middlewares.cssrc/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Extras/PdfViewer/BitPdfViewerDemo.razorsrc/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Extras/PdfViewer/BitPdfViewerDemo.razor.cssrc/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Web/Bit.BlazorUI.Demo.Client.Web.csprojsrc/BlazorUI/Tests/Bit.BlazorUI.Tests/Components/Extras/PdfViewer/BitPdfViewerTests.cs
|
@coderabbitai full-review |
|
✅ Action performedFull review finished. |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Extras/PdfViewer/BitPdfViewerDemo.razor.cs (1)
383-421: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winUpdate the example snippets to include the size validation.
The
ReadFileSourcemethod was updated to gracefully reject files exceeding the 512 MiB limit before allocating the byte array. However, the C# snippets for examples 1 and 3 still omit this check. If a user copies these snippets and uploads a file larger thanmaxAllowedSize,OpenReadStreamwill throw an unhandledIOExceptionwhich crashes the flow.Update the snippets to match the robust handling in your actual implementation.
♻️ Proposed fixes
For
example1CsharpCode:private async Task OnBasicFileChange(InputFileChangeEventArgs e) { if (e.FileCount == 0) return; - using var stream = e.File.OpenReadStream(maxAllowedSize: 512 * 1024 * 1024); + const long maxSize = 512 * 1024 * 1024; + if (e.File.Size <= 0 || e.File.Size > maxSize) return; + + using var stream = e.File.OpenReadStream(maxAllowedSize: maxSize); var bytes = new byte[(int)e.File.Size]; await stream.ReadExactlyAsync(bytes); basicSource = BitPdfSource.FromBytes(bytes, e.File.Name); }And apply the exact same check to
example3CsharpCode:private async Task OnCanvasFileChange(InputFileChangeEventArgs e) { if (e.FileCount == 0) return; - using var stream = e.File.OpenReadStream(maxAllowedSize: 512 * 1024 * 1024); + const long maxSize = 512 * 1024 * 1024; + if (e.File.Size <= 0 || e.File.Size > maxSize) return; + + using var stream = e.File.OpenReadStream(maxAllowedSize: maxSize); var bytes = new byte[(int)e.File.Size]; await stream.ReadExactlyAsync(bytes); canvasSource = BitPdfSource.FromBytes(bytes, e.File.Name); }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Extras/PdfViewer/BitPdfViewerDemo.razor.cs` around lines 383 - 421, Update the OnBasicFileChange and OnCanvasFileChange snippets in example1CsharpCode and example3CsharpCode to validate the selected file size against the 512 MiB limit before calling OpenReadStream or allocating the byte array, matching the existing ReadFileSource behavior and safely rejecting oversized files.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/BitPdfViewer.razor.cs`:
- Around line 1250-1282: Add an early disposed/load-version guard in
RunSearchAsync immediately after the initial Task.Delay(1), before initializing
_pageText or reading _document.PageCount. Capture the current load version only
after confirming the component is still valid, then preserve the existing loop
guard for subsequent yields.
- Around line 674-693: Serialize the shared-state reset in LoadAsync with
_renderGate so in-flight rendering cannot repopulate _fontStore or related
fields after they are cleared; acquire the gate before resetting _document,
_fontStore, queues, and dimensions, then release it before continuing. Also
update RenderThumbContent to check _document after waiting on the gate and
return safely when it is null, instead of dereferencing _document!.
---
Nitpick comments:
In
`@src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Extras/PdfViewer/BitPdfViewerDemo.razor.cs`:
- Around line 383-421: Update the OnBasicFileChange and OnCanvasFileChange
snippets in example1CsharpCode and example3CsharpCode to validate the selected
file size against the 512 MiB limit before calling OpenReadStream or allocating
the byte array, matching the existing ReadFileSource behavior and safely
rejecting oversized files.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 916acecb-b4f4-4d27-b18f-d180fe889820
⛔ Files ignored due to path filters (2)
src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/wwwroot/samples/hello-world.pdfis excluded by!**/*.pdfsrc/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/wwwroot/samples/sample-pdf.pdfis excluded by!**/*.pdf
📒 Files selected for processing (9)
src/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/BitPdfViewer.razorsrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/BitPdfViewer.razor.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/BitPdfViewer.scsssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/BitPdfViewer.tssrc/BlazorUI/Demo/Bit.BlazorUI.Demo.Server/Startup/Middlewares.cssrc/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Extras/PdfViewer/BitPdfViewerDemo.razorsrc/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Extras/PdfViewer/BitPdfViewerDemo.razor.cssrc/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Web/Bit.BlazorUI.Demo.Client.Web.csprojsrc/BlazorUI/Tests/Bit.BlazorUI.Tests/Components/Extras/PdfViewer/BitPdfViewerTests.cs
|
@coderabbitai full-review |
|
✅ Action performedFull review finished. |
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (3)
src/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/BitPdfViewer.razor.cs (3)
218-231: 🩺 Stability & Availability | 🟠 Major | ⚡ Quick winNew render-before-scroll call widens the unguarded disposal window before the JS scroll call.
GoToPagenow awaitsRenderPageAsync(which itself can await the render gate and, withBackgroundRendering, aTask.Run) before the pre-existingawait _js.BitPdfViewerScrollToPage(...)/ScrollActiveThumbIntoViewAsync()calls. UnlikeScrollActiveThumbIntoViewAsync(which already catchesJSDisconnectedException) and the render pumps (which checkIsDisposed), this path has no guard: if the component is disposed whileRenderPageAsyncawaits, the subsequent JS call runs against a torn-down component and can throw uncaught.🐛 Proposed fix
if (await RenderPageAsync(target - 1)) { EvictDistantPages(); StateHasChanged(); } - await _js.BitPdfViewerScrollToPage(_containerRef, _currentPage); - if (_showThumbnails) - { - await ScrollActiveThumbIntoViewAsync(); - } + if (IsDisposed) return; + try + { + await _js.BitPdfViewerScrollToPage(_containerRef, _currentPage); + } + catch (JSDisconnectedException) { } + if (_showThumbnails) + { + await ScrollActiveThumbIntoViewAsync(); + }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/BitPdfViewer.razor.cs` around lines 218 - 231, Guard the post-render navigation work in GoToPage against component disposal: after awaiting RenderPageAsync, verify the component is still active before calling _js.BitPdfViewerScrollToPage or ScrollActiveThumbIntoViewAsync, and preserve the existing rendering/eviction behavior for active components.
784-799: 🩺 Stability & Availability | 🟠 Major | ⚡ Quick winMissing
_loadVersionre-check after the new eager-render await — a superseded load can clobber the newer load's state.Every other yield point in
LoadAsyncre-checksversion != _loadVersionbefore touching shared state (lines 730, 754, 781), but the newly addedawait RenderCurrentPageEagerlyAsync();(Line 784) has no follow-up check. If a newerSourcesupersedes this load while that render awaits the gate (or a backgroundTask.Runbuild), this call resumes and dereferences_document.Outline/_document.PageCount, sets_status, and firesOnWarnings/OnDocumentLoaded— none of that is guarded. Worse, an NRE from a nulled_documenthere is swallowed by the outercatch (Exception ex)(Line 801), which then sets_status = "Error: ..."and callsOnError, and thefinally { _loading = false; }(Line 808) turns off the loading indicator that belongs to the newer, still-in-progress load.🐛 Proposed fix
PreparePages(); await RenderCurrentPageEagerlyAsync(); + if (version != _loadVersion) return; // a newer Source superseded this load while the eager render awaited try { _outline = _document.Outline; }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/BitPdfViewer.razor.cs` around lines 784 - 799, Re-check the captured load version immediately after await RenderCurrentPageEagerlyAsync() in LoadAsync and return when it no longer matches _loadVersion, before accessing _document or updating shared state. Preserve the existing guarded flow for current loads, including outline/status updates and document-loaded callbacks.
1301-1316: 🩺 Stability & Availability | 🟠 Major | ⚡ Quick winSame missing-guard pattern after the search loop exits — stale load can clobber
_loading/fire JS calls with the wrong query/container state.The
forloop'sif (IsDisposed || version != _loadVersion) return;(Line 1289) only runs inside the loop. Once the loop exits normally (all pages checked, no match found on the last iteration, etc.), execution falls straight into_loading = false;(Line 1303, part of this same changed block) and then the unguarded_js.BitPdfViewerSearchAll/BitPdfViewerGotoMatchcalls (Lines 1310-1316) — with no re-check and noJSDisconnectedExceptionhandling (unlikeScrollActiveThumbIntoViewAsyncelsewhere in this file). A reload/dispose landing in the last iteration'sawait Task.Delay(1)lets a superseded search overwrite the loading flag and call JS against the new document/state, or throw uncaught if disposed.🐛 Proposed fix
} + if (IsDisposed || version != _loadVersion) return; _loading = false; if (rendered) { StateHasChanged(); await Task.Delay(1); // let the freshly rendered pages paint before highlighting } - _searchTotal = await _js.BitPdfViewerSearchAll(_containerRef, _searchQuery); - _searchIndex = _searchTotal > 0 ? 0 : -1; - if (_searchTotal > 0) - { - await _js.BitPdfViewerGotoMatch(_containerRef, _searchIndex); - } + try + { + _searchTotal = await _js.BitPdfViewerSearchAll(_containerRef, _searchQuery); + _searchIndex = _searchTotal > 0 ? 0 : -1; + if (_searchTotal > 0) + { + await _js.BitPdfViewerGotoMatch(_containerRef, _searchIndex); + } + } + catch (JSDisconnectedException) { }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/BitPdfViewer.razor.cs` around lines 1301 - 1316, In the search method surrounding the post-loop `_loading` update, add a second `IsDisposed || version != _loadVersion` guard immediately after the loop and before changing `_loading` or invoking JS. Keep superseded or disposed searches from reaching `StateHasChanged`, `BitPdfViewerSearchAll`, or `BitPdfViewerGotoMatch`, and handle `JSDisconnectedException` for these calls consistently with `ScrollActiveThumbIntoViewAsync`.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/BitPdfViewer.razor.cs`:
- Around line 931-965: Update RenderPageAsync and the thumbnail rendering path
to snapshot _rotation, TextCoalescing, and RenderMode before invoking BuildPage,
then change BuildPage and its callers to accept and use those captured settings
instead of reading mutable component state. Ensure each render, including
Task.Run background renders, uses one consistent settings snapshot.
---
Outside diff comments:
In `@src/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/BitPdfViewer.razor.cs`:
- Around line 218-231: Guard the post-render navigation work in GoToPage against
component disposal: after awaiting RenderPageAsync, verify the component is
still active before calling _js.BitPdfViewerScrollToPage or
ScrollActiveThumbIntoViewAsync, and preserve the existing rendering/eviction
behavior for active components.
- Around line 784-799: Re-check the captured load version immediately after
await RenderCurrentPageEagerlyAsync() in LoadAsync and return when it no longer
matches _loadVersion, before accessing _document or updating shared state.
Preserve the existing guarded flow for current loads, including outline/status
updates and document-loaded callbacks.
- Around line 1301-1316: In the search method surrounding the post-loop
`_loading` update, add a second `IsDisposed || version != _loadVersion` guard
immediately after the loop and before changing `_loading` or invoking JS. Keep
superseded or disposed searches from reaching `StateHasChanged`,
`BitPdfViewerSearchAll`, or `BitPdfViewerGotoMatch`, and handle
`JSDisconnectedException` for these calls consistently with
`ScrollActiveThumbIntoViewAsync`.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 67e81c90-3200-4a97-b62d-91db6ff322fc
⛔ Files ignored due to path filters (2)
src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/wwwroot/samples/hello-world.pdfis excluded by!**/*.pdfsrc/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/wwwroot/samples/sample-pdf.pdfis excluded by!**/*.pdf
📒 Files selected for processing (9)
src/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/BitPdfViewer.razorsrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/BitPdfViewer.razor.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/BitPdfViewer.scsssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/BitPdfViewer.tssrc/BlazorUI/Demo/Bit.BlazorUI.Demo.Server/Startup/Middlewares.cssrc/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Extras/PdfViewer/BitPdfViewerDemo.razorsrc/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Extras/PdfViewer/BitPdfViewerDemo.razor.cssrc/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Web/Bit.BlazorUI.Demo.Client.Web.csprojsrc/BlazorUI/Tests/Bit.BlazorUI.Tests/Components/Extras/PdfViewer/BitPdfViewerTests.cs
|
@coderabbitai full-review |
|
✅ Action performedFull review finished. |
There was a problem hiding this comment.
Actionable comments posted: 2
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (4)
src/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/BitPdfViewer.razor.cs (3)
767-785: 🗄️ Data Integrity & Integration | 🔴 Critical | 🏗️ Heavy liftDo not assign a parsed document until the load version is validated.
An older parse can finish after a newer load, assign its document to
_document, then fail the version check. This leaves the newer page slots backed by the older PDF.Proposed fix
+ BitPdfDocument document; try { - _document = await ParseAsync(bytes, _source.Password); + document = await ParseAsync(bytes, _source.Password); } catch (BitPdfPasswordException) when (OnPasswordRequested is not null) { ... - _document = await ParseAsync(bytes, entered); + document = await ParseAsync(bytes, entered); } - if (version != _loadVersion) return; + if (IsDisposed || version != _loadVersion) return; + _document = document;Apply the same ownership check before stale error/status callbacks mutate component state.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/BitPdfViewer.razor.cs` around lines 767 - 785, Update the load flow surrounding ParseAsync and the version check so parsed documents are assigned to _document only after confirming version still equals _loadVersion; apply the same ownership validation before stale error or status callbacks update component state. Preserve the password retry behavior while ensuring any older load cannot mutate the newer load’s document or state.
1079-1087: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick winRefresh the shared font stylesheet after rendering a canvas-mode thumbnail.
Passing
_fontStoremakesBitPdfHtmlRenderersuppress inline@font-faceoutput, but this branch never copies the updated store into_fontFaceStyle. Embedded fonts first encountered in a thumbnail therefore render as fallbacks.Proposed fix
- return new MarkupString(renderer.Render()); + var html = renderer.Render(); + _fontFaceStyle = _fontStore.FontFaceStyle; + return new MarkupString(html);🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/BitPdfViewer.razor.cs` around lines 1079 - 1087, Update the Canvas branch of the thumbnail rendering method to refresh `_fontFaceStyle` from the shared `_fontStore` after `renderer.Render()` completes and before returning the MarkupString. Preserve the existing BitPdfHtmlRenderer configuration and ensure newly discovered embedded fonts are reflected in the shared stylesheet.
297-324: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick winAbort printing when the document changes during a yield.
The new delays allow
LoadAsyncor disposal to run between pages._loadingflag and invoke print against incomplete or replaced content. Capture_loadVersionand guard after every render/delay and before JS interop.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/BitPdfViewer.razor.cs` around lines 297 - 324, Update the print flow around the page-render loop to capture the current _loadVersion before yielding, then verify it remains unchanged after each RenderPageAsync and delay, including the final delay, and immediately before BitPdfViewerPrint. Abort printing without modifying the newer load’s _loading state or invoking JS interop when the version changes or disposal occurs.src/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/BitPdfViewer.ts (1)
238-250: 🩺 Stability & Availability | 🟡 Minor | ⚡ Quick winCancel pending animation-frame rendering during disposal.
disposeScrollSpyclears the debounce timer but not a frame already queued byscheduleRender, nor__bitPdvRenderScheduled. Re-registration before that frame runs can skip the new initial fill while the stale frame invokes the old disposed .NET reference. Store the RAF handle, cancel it here, and reset the scheduled flag.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/BitPdfViewer.ts` around lines 238 - 250, The disposeScrollSpy cleanup must also cancel any animation frame queued by scheduleRender. Store and cancel the RAF handle during disposal, then reset __bitPdvRenderScheduled so re-registration performs its initial render and stale callbacks cannot use the disposed .NET reference.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/BitPdfViewer.razor.cs`:
- Around line 1304-1319: The search loop should yield periodically after
processing a small batch of pages, regardless of whether matches are rendered,
to prevent long no-match or already-rendered scans from monopolizing the UI
thread. Add and check a search-generation token alongside the existing
_loadVersion guard so superseded queries exit promptly, updating the search
state at the start of the relevant search method.
- Around line 699-713: Update the document load reset block in BitPdfViewer to
clear both the thumbnail storage (_thumbs) and canvas storage alongside _pages,
before setting _document to null. Ensure queued or previously rendered slots
cannot repopulate stale content while the replacement document loads or fails.
---
Outside diff comments:
In `@src/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/BitPdfViewer.razor.cs`:
- Around line 767-785: Update the load flow surrounding ParseAsync and the
version check so parsed documents are assigned to _document only after
confirming version still equals _loadVersion; apply the same ownership
validation before stale error or status callbacks update component state.
Preserve the password retry behavior while ensuring any older load cannot mutate
the newer load’s document or state.
- Around line 1079-1087: Update the Canvas branch of the thumbnail rendering
method to refresh `_fontFaceStyle` from the shared `_fontStore` after
`renderer.Render()` completes and before returning the MarkupString. Preserve
the existing BitPdfHtmlRenderer configuration and ensure newly discovered
embedded fonts are reflected in the shared stylesheet.
- Around line 297-324: Update the print flow around the page-render loop to
capture the current _loadVersion before yielding, then verify it remains
unchanged after each RenderPageAsync and delay, including the final delay, and
immediately before BitPdfViewerPrint. Abort printing without modifying the newer
load’s _loading state or invoking JS interop when the version changes or
disposal occurs.
In `@src/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/BitPdfViewer.ts`:
- Around line 238-250: The disposeScrollSpy cleanup must also cancel any
animation frame queued by scheduleRender. Store and cancel the RAF handle during
disposal, then reset __bitPdvRenderScheduled so re-registration performs its
initial render and stale callbacks cannot use the disposed .NET reference.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: b4822910-3538-4f2e-b34f-963f1d0f0a4d
⛔ Files ignored due to path filters (2)
src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/wwwroot/samples/hello-world.pdfis excluded by!**/*.pdfsrc/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/wwwroot/samples/sample-pdf.pdfis excluded by!**/*.pdf
📒 Files selected for processing (9)
src/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/BitPdfViewer.razorsrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/BitPdfViewer.razor.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/BitPdfViewer.scsssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/BitPdfViewer.tssrc/BlazorUI/Demo/Bit.BlazorUI.Demo.Server/Startup/Middlewares.cssrc/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Extras/PdfViewer/BitPdfViewerDemo.razorsrc/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Extras/PdfViewer/BitPdfViewerDemo.razor.cssrc/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Web/Bit.BlazorUI.Demo.Client.Web.csprojsrc/BlazorUI/Tests/Bit.BlazorUI.Tests/Components/Extras/PdfViewer/BitPdfViewerTests.cs
8dd5551 to
2a708df
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/BitPdfViewer.razor.cs (1)
830-840: 🩺 Stability & Availability | 🟠 Major | ⚡ Quick winInvalidate active loads when disposal begins.
Disposal does not change
_loadVersion, so fetch/parse continuations guarded only by version can still publish state or callbacks after teardown. Increment the version immediately and avoid retrying a password parse after ownership is lost.Proposed fix
string? entered = await OnPasswordRequested(); + if (IsDisposed || version != _loadVersion) return; if (string.IsNullOrEmpty(entered)) { throw; } IsDisposed = true; + _loadVersion++;Also applies to: 1491-1494
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/BitPdfViewer.razor.cs` around lines 830 - 840, Update the PdfViewer disposal path to increment _loadVersion immediately when teardown begins, invalidating all in-flight fetch and parse continuations before they can publish state or invoke callbacks. In the password-retry flow around OnPasswordRequested and ParseAsync, check ownership/version after awaiting and before retrying, and skip the retry when disposal or a newer load has taken over. Apply the same invalidation guard to the corresponding logic near the additional occurrence.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In
`@src/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Render/BitPdfHtmlRenderer.cs`:
- Around line 318-323: Update the Type3 color-lock condition in the renderer’s
operator handling to include the color-space operators FillColorSpace and
StrokeColorSpace, not just the range beginning at FillGray. Ensure both
operators are suppressed while _type3ColorLocked so they cannot invoke
SetDefaultColor, while preserving the existing suppression for all other
color-setting operators.
---
Outside diff comments:
In `@src/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/BitPdfViewer.razor.cs`:
- Around line 830-840: Update the PdfViewer disposal path to increment
_loadVersion immediately when teardown begins, invalidating all in-flight fetch
and parse continuations before they can publish state or invoke callbacks. In
the password-retry flow around OnPasswordRequested and ParseAsync, check
ownership/version after awaiting and before retrying, and skip the retry when
disposal or a newer load has taken over. Apply the same invalidation guard to
the corresponding logic near the additional occurrence.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 5b622678-b1ae-47ea-ac54-0b28a2430fab
⛔ Files ignored due to path filters (2)
src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/wwwroot/samples/hello-world.pdfis excluded by!**/*.pdfsrc/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/wwwroot/samples/sample-pdf.pdfis excluded by!**/*.pdf
📒 Files selected for processing (98)
src/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/BitPdfRenderMode.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/BitPdfSource.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/BitPdfTextCoalescing.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/BitPdfViewer.razorsrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/BitPdfViewer.razor.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/BitPdfViewer.scsssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/BitPdfViewer.tssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/BitPdfViewerJsRuntimeExtensions.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/BitPdfZoomMode.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfAcroForm.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfBaseStream.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfCmd.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfDestination.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfDestinationFit.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfDict.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfDocument.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfFormField.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfFormatException.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfLexer.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfMetadata.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfName.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfOutlineBuilder.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfOutlineItem.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfPage.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfPageLabelBuilder.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfParser.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfPasswordException.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfPermissions.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfPrimitives.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfRef.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfRefSet.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfRefSetCache.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfStream.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfString.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfStructElement.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfStructTree.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfUnsupportedEncryptionException.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfXRef.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Content/BitPdfContentParser.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Content/BitPdfOpCode.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Content/BitPdfOperation.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Content/BitPdfTextExtractor.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Filters/BitPdfCcittFaxDecoder.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Filters/BitPdfCcittParams.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Filters/BitPdfJpegDecoder.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Filters/BitPdfJpegImage.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Filters/BitPdfLzwDecode.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Filters/BitPdfPredictor.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Filters/BitPdfStreamDecoder.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Fonts/BitPdfCMap.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Fonts/BitPdfCffFontParser.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Fonts/BitPdfCffFontWriter.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Fonts/BitPdfCmapBuilder.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Fonts/BitPdfEncodings.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Fonts/BitPdfFont.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Fonts/BitPdfGlyph.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Fonts/BitPdfGlyphList.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Fonts/BitPdfGlyphOutline.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Fonts/BitPdfPathSeg.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Fonts/BitPdfSfntGlyphMapper.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Fonts/BitPdfStandardFonts.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Fonts/BitPdfToUnicodeCMap.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Fonts/BitPdfTrueTypeSanitizer.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Fonts/BitPdfType1Font.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Fonts/BitPdfType3FontData.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Fonts/BitPdfWinAnsiEncoding.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Functions/BitPdfConstantFunction.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Functions/BitPdfExponentialFunction.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Functions/BitPdfFunction.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Functions/BitPdfPostScriptFunction.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Functions/BitPdfSampledFunction.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Functions/BitPdfStitchingFunction.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Geometry/BitPdfMatrix.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/IBlazorPdfXRef.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Render/BitPdfCanvasRenderResult.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Render/BitPdfCanvasRenderer.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Render/BitPdfColorSpace.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Render/BitPdfCssShadingBuilder.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Render/BitPdfFontStore.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Render/BitPdfGraphicsState.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Render/BitPdfHtmlRenderer.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Render/BitPdfImage.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Render/BitPdfIndexedColorSpace.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Render/BitPdfLabColorSpace.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Render/BitPdfPngEncoder.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Render/BitPdfSeparationColorSpace.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Security/BitPdfCipherKind.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Security/BitPdfManagedAes.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Security/BitPdfManagedMd5.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Security/BitPdfRc4.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Security/BitPdfStandardSecurityHandler.cssrc/BlazorUI/Demo/Bit.BlazorUI.Demo.Server/Startup/Middlewares.cssrc/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Extras/PdfViewer/BitPdfViewerDemo.razorsrc/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Extras/PdfViewer/BitPdfViewerDemo.razor.cssrc/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Web/Bit.BlazorUI.Demo.Client.Web.csprojsrc/BlazorUI/Tests/Bit.BlazorUI.Tests/Bit.BlazorUI.Tests.csprojsrc/BlazorUI/Tests/Bit.BlazorUI.Tests/Components/Extras/PdfViewer/BitPdfOpCodeTests.cssrc/BlazorUI/Tests/Bit.BlazorUI.Tests/Components/Extras/PdfViewer/BitPdfViewerTests.cs
|
@coderabbitai full-review |
|
✅ Action performedFull review finished. |
There was a problem hiding this comment.
Actionable comments posted: 2
♻️ Duplicate comments (5)
src/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/BitPdfViewer.scss (1)
1-2: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick winRemove
.scssextensions from partial imports.Both imports still violate
scss/load-partial-extension.-@import "../../Styles/extra-variables.scss"; -@import "../../../Bit.BlazorUI/Styles/functions.scss"; +@import "../../Styles/extra-variables"; +@import "../../../Bit.BlazorUI/Styles/functions";🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/BitPdfViewer.scss` around lines 1 - 2, Update the partial imports at the top of BitPdfViewer.scss to remove the .scss extensions from both referenced paths, preserving their existing paths and import order.Source: Linters/SAST tools
src/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/BitPdfViewer.razor.cs (3)
743-760: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick winRegression: clear thumbnail and canvas state during load reset.
_thumbs,_canvasOps, and_canvasDirtysurvive this reset. A null or failed replacement source can therefore retain the previous PDF’s thumbnail sidebar and canvas memory.Proposed fix
_pages.Clear(); + _thumbs.Clear(); + _canvasOps.Clear(); + _canvasDirty.Clear(); _renderQueue.Clear();🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/BitPdfViewer.razor.cs` around lines 743 - 760, Update the load-reset logic in BitPdfViewer to also clear or reset _thumbs, _canvasOps, and _canvasDirty alongside the existing page, thumbnail-queue, and document state cleanup. Ensure null or failed replacement sources cannot retain thumbnail or canvas state from the previous PDF.
1399-1417: 🚀 Performance & Scalability | 🟠 Major | ⚡ Quick winYield during every search batch and cancel superseded queries.
A no-match or already-rendered search performs every extraction without yielding, recreating the WASM freeze. The same-load version guard also cannot stop an older query from publishing after
_searchQuerychanges. Add periodic batch yields and a search-generation token.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/BitPdfViewer.razor.cs` around lines 1399 - 1417, Update the search flow containing the loop over pageCount to yield periodically even when no pages require rendering, such as after a bounded batch of page extractions, so large searches do not monopolize the UI thread. Add a search-generation token tied to each query, invalidate the previous generation when _searchQuery changes, and check that token alongside IsDisposed and _loadVersion before continuing or publishing results, preventing superseded queries from completing.
417-424: 🚀 Performance & Scalability | 🟠 Major | ⚡ Quick winReprioritize pages that are already queued.
_renderQueued.Add(idx)and_thumbQueued.Add(idx)skip entries already in an older batch, leaving a newly visible page behind stale off-screen work. Remove/reinsert existing entries at the front when they appear in the latest viewport batch.Also applies to: 490-497
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/BitPdfViewer.razor.cs` around lines 417 - 424, Update the page-render and thumbnail queue handling around _renderQueued and _thumbQueued so pages already queued are removed from their stale position and reinserted at the front when included in the latest viewport batch. Do not skip existing entries based solely on Add returning false; preserve deduplication while promoting these indices ahead of older off-screen work in both affected paths.src/BlazorUI/Demo/Bit.BlazorUI.Demo.Server/Startup/Middlewares.cs (1)
28-29: 🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy liftComplete the Safari cross-origin-isolation contract.
The server configuration explicitly acknowledges that
credentiallessdoes not provide Safari’s required isolation, while the client enables threads globally.
src/BlazorUI/Demo/Bit.BlazorUI.Demo.Server/Startup/Middlewares.cs#L28-L29: userequire-corpwith CORP/CORS-compliant assets, or implement a supported browser-specific strategy.src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Web/Bit.BlazorUI.Demo.Client.Web.csproj#L18-L23: ensure threaded runtime startup is gated when the host cannot provide compatible isolation.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/BlazorUI/Demo/Bit.BlazorUI.Demo.Server/Startup/Middlewares.cs` around lines 28 - 29, Complete the cross-origin-isolation contract in the middleware configuring Cross-Origin-Opener-Policy and Cross-Origin-Embedder-Policy by using require-corp with CORP/CORS-compliant assets, or a supported browser-specific strategy. In src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Web/Bit.BlazorUI.Demo.Client.Web.csproj lines 18-23, gate threaded runtime startup whenever the host cannot provide compatible isolation.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/BitPdfViewer.razor.cs`:
- Around line 216-239: The GoToPage navigation flow must abort when a newer page
change supersedes its target. In GoToPage, re-check _currentPage == target after
each await, including after OnPageChanged and RenderPageAsync, before rendering,
eviction, state updates, or scrolling; use the captured target for the final
BitPdfViewerScrollToPage call instead of mutable _currentPage.
- Around line 1033-1044: Update the page-building flow around BuildPage and the
corresponding BuildThumb flow to catch build exceptions instead of letting them
escape the JS-invokable render pumps. Ensure each failure releases _renderGate,
invokes the documented OnError callback, and returns without committing the
failed page or thumbnail slot, while preserving existing stale-build checks and
successful commit behavior.
---
Duplicate comments:
In `@src/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/BitPdfViewer.razor.cs`:
- Around line 743-760: Update the load-reset logic in BitPdfViewer to also clear
or reset _thumbs, _canvasOps, and _canvasDirty alongside the existing page,
thumbnail-queue, and document state cleanup. Ensure null or failed replacement
sources cannot retain thumbnail or canvas state from the previous PDF.
- Around line 1399-1417: Update the search flow containing the loop over
pageCount to yield periodically even when no pages require rendering, such as
after a bounded batch of page extractions, so large searches do not monopolize
the UI thread. Add a search-generation token tied to each query, invalidate the
previous generation when _searchQuery changes, and check that token alongside
IsDisposed and _loadVersion before continuing or publishing results, preventing
superseded queries from completing.
- Around line 417-424: Update the page-render and thumbnail queue handling
around _renderQueued and _thumbQueued so pages already queued are removed from
their stale position and reinserted at the front when included in the latest
viewport batch. Do not skip existing entries based solely on Add returning
false; preserve deduplication while promoting these indices ahead of older
off-screen work in both affected paths.
In `@src/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/BitPdfViewer.scss`:
- Around line 1-2: Update the partial imports at the top of BitPdfViewer.scss to
remove the .scss extensions from both referenced paths, preserving their
existing paths and import order.
In `@src/BlazorUI/Demo/Bit.BlazorUI.Demo.Server/Startup/Middlewares.cs`:
- Around line 28-29: Complete the cross-origin-isolation contract in the
middleware configuring Cross-Origin-Opener-Policy and
Cross-Origin-Embedder-Policy by using require-corp with CORP/CORS-compliant
assets, or a supported browser-specific strategy. In
src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Web/Bit.BlazorUI.Demo.Client.Web.csproj
lines 18-23, gate threaded runtime startup whenever the host cannot provide
compatible isolation.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 08cef298-57ff-47b9-b8a8-ebf2f7feedff
⛔ Files ignored due to path filters (2)
src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/wwwroot/samples/hello-world.pdfis excluded by!**/*.pdfsrc/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/wwwroot/samples/sample-pdf.pdfis excluded by!**/*.pdf
📒 Files selected for processing (98)
src/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/BitPdfRenderMode.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/BitPdfSource.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/BitPdfTextCoalescing.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/BitPdfViewer.razorsrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/BitPdfViewer.razor.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/BitPdfViewer.scsssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/BitPdfViewer.tssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/BitPdfViewerJsRuntimeExtensions.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/BitPdfZoomMode.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfAcroForm.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfBaseStream.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfCmd.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfDestination.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfDestinationFit.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfDict.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfDocument.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfFormField.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfFormatException.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfLexer.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfMetadata.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfName.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfOutlineBuilder.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfOutlineItem.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfPage.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfPageLabelBuilder.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfParser.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfPasswordException.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfPermissions.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfPrimitives.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfRef.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfRefSet.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfRefSetCache.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfStream.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfString.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfStructElement.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfStructTree.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfUnsupportedEncryptionException.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfXRef.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Content/BitPdfContentParser.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Content/BitPdfOpCode.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Content/BitPdfOperation.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Content/BitPdfTextExtractor.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Filters/BitPdfCcittFaxDecoder.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Filters/BitPdfCcittParams.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Filters/BitPdfJpegDecoder.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Filters/BitPdfJpegImage.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Filters/BitPdfLzwDecode.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Filters/BitPdfPredictor.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Filters/BitPdfStreamDecoder.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Fonts/BitPdfCMap.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Fonts/BitPdfCffFontParser.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Fonts/BitPdfCffFontWriter.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Fonts/BitPdfCmapBuilder.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Fonts/BitPdfEncodings.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Fonts/BitPdfFont.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Fonts/BitPdfGlyph.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Fonts/BitPdfGlyphList.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Fonts/BitPdfGlyphOutline.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Fonts/BitPdfPathSeg.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Fonts/BitPdfSfntGlyphMapper.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Fonts/BitPdfStandardFonts.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Fonts/BitPdfToUnicodeCMap.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Fonts/BitPdfTrueTypeSanitizer.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Fonts/BitPdfType1Font.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Fonts/BitPdfType3FontData.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Fonts/BitPdfWinAnsiEncoding.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Functions/BitPdfConstantFunction.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Functions/BitPdfExponentialFunction.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Functions/BitPdfFunction.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Functions/BitPdfPostScriptFunction.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Functions/BitPdfSampledFunction.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Functions/BitPdfStitchingFunction.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Geometry/BitPdfMatrix.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/IBlazorPdfXRef.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Render/BitPdfCanvasRenderResult.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Render/BitPdfCanvasRenderer.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Render/BitPdfColorSpace.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Render/BitPdfCssShadingBuilder.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Render/BitPdfFontStore.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Render/BitPdfGraphicsState.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Render/BitPdfHtmlRenderer.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Render/BitPdfImage.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Render/BitPdfIndexedColorSpace.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Render/BitPdfLabColorSpace.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Render/BitPdfPngEncoder.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Render/BitPdfSeparationColorSpace.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Security/BitPdfCipherKind.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Security/BitPdfManagedAes.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Security/BitPdfManagedMd5.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Security/BitPdfRc4.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Security/BitPdfStandardSecurityHandler.cssrc/BlazorUI/Demo/Bit.BlazorUI.Demo.Server/Startup/Middlewares.cssrc/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Extras/PdfViewer/BitPdfViewerDemo.razorsrc/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Extras/PdfViewer/BitPdfViewerDemo.razor.cssrc/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Web/Bit.BlazorUI.Demo.Client.Web.csprojsrc/BlazorUI/Tests/Bit.BlazorUI.Tests/Bit.BlazorUI.Tests.csprojsrc/BlazorUI/Tests/Bit.BlazorUI.Tests/Components/Extras/PdfViewer/BitPdfOpCodeTests.cssrc/BlazorUI/Tests/Bit.BlazorUI.Tests/Components/Extras/PdfViewer/BitPdfViewerTests.cs
|
@coderabbitai full-review |
|
✅ Action performedFull review finished. |
There was a problem hiding this comment.
Actionable comments posted: 3
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/BitPdfViewer.razor.cs (1)
1438-1446: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick winCancel and finish the active search when clearing the query.
An empty query returns without clearing
_loading, so clearing an in-flight search leaves the progress indicator stuck after the older generation exits. Closing the search also callsClearSearchAsyncdirectly without incrementing_searchGeneration, allowing obsolete extraction to continue. Move generation invalidation and loading cleanup into the common clear path.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/BitPdfViewer.razor.cs` around lines 1438 - 1446, Update the empty-query handling in the search flow and ClearSearchAsync so clearing the query always invalidates the active generation, resets _loading, and cancels or finishes any in-flight search before returning. Ensure the direct search-close path also uses this shared invalidation and cleanup behavior, while preserving normal search execution for non-empty queries.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/BitPdfViewer.razor.cs`:
- Around line 1063-1089: Update the failure handling in the page and thumbnail
build paths, including the code around CommitPage and the corresponding block
near the thumbnail build, to revalidate ownership after releasing _renderGate
before invoking OnError. Only publish buildError when the component is still
active and the captured load version/render epoch still match the current
_loadVersion/_renderEpoch; suppress errors from superseded builds while
preserving current error reporting for active builds.
In
`@src/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Render/BitPdfImage.cs`:
- Line 454: Bound the soft-mask scale-map allocation in the rendering logic
around BuildScaleMap and both affected loops. Only create xMap when the image
width is below the established safe threshold; otherwise avoid allocating the
width-sized array and compute each source coordinate with the existing 64-bit
scaling calculation inline. Preserve the current direct path when mw equals
width and apply the selection consistently in both loops.
In
`@src/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Render/BitPdfIndexedColorSpace.cs`:
- Around line 25-26: Update the hival calculation in BitPdfIndexedColorSpace to
clamp the parsed value to the full valid Indexed color range of 0 through 255,
preserving the existing fallback to 0 for non-double values. Ensure GetRgb
receives the bounded hival value so large inputs cannot overflow index * n.
---
Outside diff comments:
In `@src/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/BitPdfViewer.razor.cs`:
- Around line 1438-1446: Update the empty-query handling in the search flow and
ClearSearchAsync so clearing the query always invalidates the active generation,
resets _loading, and cancels or finishes any in-flight search before returning.
Ensure the direct search-close path also uses this shared invalidation and
cleanup behavior, while preserving normal search execution for non-empty
queries.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: f3d0a8b6-2ae0-4fa2-a356-089e8df2e205
⛔ Files ignored due to path filters (2)
src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/wwwroot/samples/hello-world.pdfis excluded by!**/*.pdfsrc/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/wwwroot/samples/sample-pdf.pdfis excluded by!**/*.pdf
📒 Files selected for processing (98)
src/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/BitPdfRenderMode.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/BitPdfSource.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/BitPdfTextCoalescing.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/BitPdfViewer.razorsrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/BitPdfViewer.razor.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/BitPdfViewer.scsssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/BitPdfViewer.tssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/BitPdfViewerJsRuntimeExtensions.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/BitPdfZoomMode.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfAcroForm.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfBaseStream.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfCmd.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfDestination.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfDestinationFit.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfDict.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfDocument.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfFormField.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfFormatException.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfLexer.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfMetadata.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfName.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfOutlineBuilder.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfOutlineItem.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfPage.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfPageLabelBuilder.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfParser.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfPasswordException.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfPermissions.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfPrimitives.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfRef.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfRefSet.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfRefSetCache.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfStream.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfString.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfStructElement.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfStructTree.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfUnsupportedEncryptionException.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfXRef.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Content/BitPdfContentParser.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Content/BitPdfOpCode.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Content/BitPdfOperation.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Content/BitPdfTextExtractor.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Filters/BitPdfCcittFaxDecoder.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Filters/BitPdfCcittParams.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Filters/BitPdfJpegDecoder.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Filters/BitPdfJpegImage.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Filters/BitPdfLzwDecode.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Filters/BitPdfPredictor.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Filters/BitPdfStreamDecoder.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Fonts/BitPdfCMap.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Fonts/BitPdfCffFontParser.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Fonts/BitPdfCffFontWriter.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Fonts/BitPdfCmapBuilder.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Fonts/BitPdfEncodings.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Fonts/BitPdfFont.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Fonts/BitPdfGlyph.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Fonts/BitPdfGlyphList.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Fonts/BitPdfGlyphOutline.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Fonts/BitPdfPathSeg.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Fonts/BitPdfSfntGlyphMapper.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Fonts/BitPdfStandardFonts.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Fonts/BitPdfToUnicodeCMap.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Fonts/BitPdfTrueTypeSanitizer.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Fonts/BitPdfType1Font.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Fonts/BitPdfType3FontData.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Fonts/BitPdfWinAnsiEncoding.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Functions/BitPdfConstantFunction.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Functions/BitPdfExponentialFunction.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Functions/BitPdfFunction.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Functions/BitPdfPostScriptFunction.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Functions/BitPdfSampledFunction.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Functions/BitPdfStitchingFunction.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Geometry/BitPdfMatrix.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/IBlazorPdfXRef.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Render/BitPdfCanvasRenderResult.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Render/BitPdfCanvasRenderer.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Render/BitPdfColorSpace.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Render/BitPdfCssShadingBuilder.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Render/BitPdfFontStore.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Render/BitPdfGraphicsState.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Render/BitPdfHtmlRenderer.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Render/BitPdfImage.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Render/BitPdfIndexedColorSpace.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Render/BitPdfLabColorSpace.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Render/BitPdfPngEncoder.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Render/BitPdfSeparationColorSpace.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Security/BitPdfCipherKind.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Security/BitPdfManagedAes.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Security/BitPdfManagedMd5.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Security/BitPdfRc4.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Security/BitPdfStandardSecurityHandler.cssrc/BlazorUI/Demo/Bit.BlazorUI.Demo.Server/Startup/Middlewares.cssrc/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Extras/PdfViewer/BitPdfViewerDemo.razorsrc/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Extras/PdfViewer/BitPdfViewerDemo.razor.cssrc/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Web/Bit.BlazorUI.Demo.Client.Web.csprojsrc/BlazorUI/Tests/Bit.BlazorUI.Tests/Bit.BlazorUI.Tests.csprojsrc/BlazorUI/Tests/Bit.BlazorUI.Tests/Components/Extras/PdfViewer/BitPdfOpCodeTests.cssrc/BlazorUI/Tests/Bit.BlazorUI.Tests/Components/Extras/PdfViewer/BitPdfViewerTests.cs
|
@coderabbitai full-review |
|
✅ Action performedFull review finished. |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
src/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Filters/BitPdfJpegDecoder.cs (1)
521-556: 🚀 Performance & Scalability | 🔵 Trivial | 💤 Low valueConsider reusing the
srcbuffer to reduce stack allocations.Because
srcis no longer needed after the firstRowIdctpass, you can use it as the intermediate destination forTransposeinstead of allocating the third bufferb. This safely reduces stack usage by 256 bytes per block and removes one zero-initialization from the hot path.♻️ Proposed refactor
- Span<float> src = stackalloc float[64]; - Span<float> a = stackalloc float[64]; - Span<float> b = stackalloc float[64]; + Span<float> src = stackalloc float[64]; + Span<float> a = stackalloc float[64]; for (int i = 0; i < 64; i++) { src[i] = block[i]; } RowIdct(src, a); // transform each row - Transpose(a, b); // columns become rows - RowIdct(b, a); // transform the (original) columns + Transpose(a, src); // columns become rows (reusing src buffer) + RowIdct(src, a); // transform the (original) columns TransposeToInt(a, block); // restore orientation and round back to the caller's buffer🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Filters/BitPdfJpegDecoder.cs` around lines 521 - 556, Update Idct to reuse the src buffer after the initial RowIdct call: transpose a into src, then run the second RowIdct from src into a, eliminating the separate b stack buffer while preserving the existing transform order and output behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/BitPdfViewer.razor.cs`:
- Around line 453-457: The stale render pump must not clear queues belonging to
a replacement document. Update the render-pump ownership handling around the
IsDisposed/version check at lines 453-457 to preserve newer entries and restart
or transfer ownership to the current _loadVersion; apply the same ownership
change to the thumbnail pump at
src/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/BitPdfViewer.razor.cs
lines 527-531.
- Around line 340-345: Update the page-rendering loop around RenderPageAsync so
it checks the render result and immediately aborts printing when a page fails to
render. Preserve the existing disposal and load-version cancellation checks, and
ensure the failure path does not continue to subsequent pages with an empty
slot.
---
Nitpick comments:
In
`@src/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Filters/BitPdfJpegDecoder.cs`:
- Around line 521-556: Update Idct to reuse the src buffer after the initial
RowIdct call: transpose a into src, then run the second RowIdct from src into a,
eliminating the separate b stack buffer while preserving the existing transform
order and output behavior.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: a9fbf0a9-f431-45dd-a160-51966b1034ac
⛔ Files ignored due to path filters (2)
src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/wwwroot/samples/hello-world.pdfis excluded by!**/*.pdfsrc/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/wwwroot/samples/sample-pdf.pdfis excluded by!**/*.pdf
📒 Files selected for processing (98)
src/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/BitPdfRenderMode.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/BitPdfSource.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/BitPdfTextCoalescing.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/BitPdfViewer.razorsrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/BitPdfViewer.razor.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/BitPdfViewer.scsssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/BitPdfViewer.tssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/BitPdfViewerJsRuntimeExtensions.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/BitPdfZoomMode.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfAcroForm.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfBaseStream.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfCmd.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfDestination.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfDestinationFit.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfDict.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfDocument.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfFormField.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfFormatException.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfLexer.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfMetadata.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfName.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfOutlineBuilder.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfOutlineItem.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfPage.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfPageLabelBuilder.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfParser.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfPasswordException.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfPermissions.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfPrimitives.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfRef.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfRefSet.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfRefSetCache.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfStream.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfString.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfStructElement.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfStructTree.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfUnsupportedEncryptionException.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfXRef.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Content/BitPdfContentParser.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Content/BitPdfOpCode.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Content/BitPdfOperation.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Content/BitPdfTextExtractor.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Filters/BitPdfCcittFaxDecoder.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Filters/BitPdfCcittParams.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Filters/BitPdfJpegDecoder.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Filters/BitPdfJpegImage.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Filters/BitPdfLzwDecode.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Filters/BitPdfPredictor.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Filters/BitPdfStreamDecoder.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Fonts/BitPdfCMap.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Fonts/BitPdfCffFontParser.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Fonts/BitPdfCffFontWriter.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Fonts/BitPdfCmapBuilder.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Fonts/BitPdfEncodings.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Fonts/BitPdfFont.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Fonts/BitPdfGlyph.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Fonts/BitPdfGlyphList.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Fonts/BitPdfGlyphOutline.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Fonts/BitPdfPathSeg.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Fonts/BitPdfSfntGlyphMapper.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Fonts/BitPdfStandardFonts.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Fonts/BitPdfToUnicodeCMap.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Fonts/BitPdfTrueTypeSanitizer.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Fonts/BitPdfType1Font.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Fonts/BitPdfType3FontData.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Fonts/BitPdfWinAnsiEncoding.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Functions/BitPdfConstantFunction.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Functions/BitPdfExponentialFunction.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Functions/BitPdfFunction.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Functions/BitPdfPostScriptFunction.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Functions/BitPdfSampledFunction.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Functions/BitPdfStitchingFunction.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Geometry/BitPdfMatrix.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/IBlazorPdfXRef.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Render/BitPdfCanvasRenderResult.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Render/BitPdfCanvasRenderer.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Render/BitPdfColorSpace.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Render/BitPdfCssShadingBuilder.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Render/BitPdfFontStore.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Render/BitPdfGraphicsState.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Render/BitPdfHtmlRenderer.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Render/BitPdfImage.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Render/BitPdfIndexedColorSpace.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Render/BitPdfLabColorSpace.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Render/BitPdfPngEncoder.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Render/BitPdfSeparationColorSpace.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Security/BitPdfCipherKind.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Security/BitPdfManagedAes.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Security/BitPdfManagedMd5.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Security/BitPdfRc4.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Security/BitPdfStandardSecurityHandler.cssrc/BlazorUI/Demo/Bit.BlazorUI.Demo.Server/Startup/Middlewares.cssrc/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Extras/PdfViewer/BitPdfViewerDemo.razorsrc/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Extras/PdfViewer/BitPdfViewerDemo.razor.cssrc/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Web/Bit.BlazorUI.Demo.Client.Web.csprojsrc/BlazorUI/Tests/Bit.BlazorUI.Tests/Bit.BlazorUI.Tests.csprojsrc/BlazorUI/Tests/Bit.BlazorUI.Tests/Components/Extras/PdfViewer/BitPdfOpCodeTests.cssrc/BlazorUI/Tests/Bit.BlazorUI.Tests/Components/Extras/PdfViewer/BitPdfViewerTests.cs
|
@coderabbitai full-review |
|
✅ Action performedFull review finished. |
There was a problem hiding this comment.
Actionable comments posted: 3
🧹 Nitpick comments (1)
src/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Filters/BitPdfJpegDecoder.cs (1)
521-556: 🚀 Performance & Scalability | 🔵 Trivial | 💤 Low valueConsider using
IndexOfAnyExceptfor the AC-zero check.If this project targets .NET 8 or newer, you can optimize the AC-zero check using
IndexOfAnyExcept, which leverages SIMD internally to scan the span without explicit looping.💡 Proposed refactor
- bool acZero = true; - for (int i = 1; i < 64; i++) - { - if (block[i] != 0) - { - acZero = false; - break; - } - } + bool acZero = block.AsSpan(1).IndexOfAnyExcept(0) < 0;🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Filters/BitPdfJpegDecoder.cs` around lines 521 - 556, In Idct, replace the explicit AC-coefficient scan with an IndexOfAnyExcept-based check over block[1..] when the project targets .NET 8 or newer. Preserve the existing acZero behavior, DC-only flat-plane output, and early return for blocks whose AC coefficients are all zero.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/BitPdfViewer.razor.cs`:
- Around line 358-366: Update the rendered branch in the PDF viewer print flow
to await completion of canvas painting performed by OnAfterRenderAsync before
calling BitPdfViewerPrint. Replace the fixed one-millisecond delay with the
existing or newly introduced awaitable paint-completion barrier, while
preserving the disposal and load-version checks before printing.
- Around line 368-377: Update the print cleanup in the finally block of the
print flow to evict all print-only pages after the snapshot is built, removing
their DOM and corresponding _canvasOps entries before or when _printing is
cleared. Preserve the version check so only the owning load clears _loading, and
ensure cleanup also runs for superseded or failed prints.
- Around line 879-883: Update the password-request flow around ParseAsync so it
checks IsDisposed and the captured load version immediately before invoking the
user-supplied OnPasswordRequested callback. Retain the existing ownership check
after the callback returns, ensuring stale or disposed requests never invoke
user code or publish results.
---
Nitpick comments:
In
`@src/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Filters/BitPdfJpegDecoder.cs`:
- Around line 521-556: In Idct, replace the explicit AC-coefficient scan with an
IndexOfAnyExcept-based check over block[1..] when the project targets .NET 8 or
newer. Preserve the existing acZero behavior, DC-only flat-plane output, and
early return for blocks whose AC coefficients are all zero.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: aa14721e-d5a0-488b-9b64-b27a6bbdb143
⛔ Files ignored due to path filters (2)
src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/wwwroot/samples/hello-world.pdfis excluded by!**/*.pdfsrc/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/wwwroot/samples/sample-pdf.pdfis excluded by!**/*.pdf
📒 Files selected for processing (98)
src/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/BitPdfRenderMode.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/BitPdfSource.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/BitPdfTextCoalescing.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/BitPdfViewer.razorsrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/BitPdfViewer.razor.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/BitPdfViewer.scsssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/BitPdfViewer.tssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/BitPdfViewerJsRuntimeExtensions.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/BitPdfZoomMode.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfAcroForm.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfBaseStream.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfCmd.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfDestination.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfDestinationFit.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfDict.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfDocument.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfFormField.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfFormatException.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfLexer.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfMetadata.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfName.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfOutlineBuilder.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfOutlineItem.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfPage.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfPageLabelBuilder.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfParser.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfPasswordException.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfPermissions.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfPrimitives.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfRef.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfRefSet.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfRefSetCache.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfStream.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfString.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfStructElement.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfStructTree.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfUnsupportedEncryptionException.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfXRef.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Content/BitPdfContentParser.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Content/BitPdfOpCode.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Content/BitPdfOperation.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Content/BitPdfTextExtractor.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Filters/BitPdfCcittFaxDecoder.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Filters/BitPdfCcittParams.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Filters/BitPdfJpegDecoder.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Filters/BitPdfJpegImage.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Filters/BitPdfLzwDecode.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Filters/BitPdfPredictor.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Filters/BitPdfStreamDecoder.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Fonts/BitPdfCMap.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Fonts/BitPdfCffFontParser.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Fonts/BitPdfCffFontWriter.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Fonts/BitPdfCmapBuilder.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Fonts/BitPdfEncodings.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Fonts/BitPdfFont.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Fonts/BitPdfGlyph.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Fonts/BitPdfGlyphList.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Fonts/BitPdfGlyphOutline.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Fonts/BitPdfPathSeg.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Fonts/BitPdfSfntGlyphMapper.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Fonts/BitPdfStandardFonts.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Fonts/BitPdfToUnicodeCMap.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Fonts/BitPdfTrueTypeSanitizer.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Fonts/BitPdfType1Font.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Fonts/BitPdfType3FontData.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Fonts/BitPdfWinAnsiEncoding.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Functions/BitPdfConstantFunction.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Functions/BitPdfExponentialFunction.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Functions/BitPdfFunction.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Functions/BitPdfPostScriptFunction.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Functions/BitPdfSampledFunction.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Functions/BitPdfStitchingFunction.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Geometry/BitPdfMatrix.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/IBlazorPdfXRef.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Render/BitPdfCanvasRenderResult.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Render/BitPdfCanvasRenderer.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Render/BitPdfColorSpace.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Render/BitPdfCssShadingBuilder.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Render/BitPdfFontStore.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Render/BitPdfGraphicsState.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Render/BitPdfHtmlRenderer.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Render/BitPdfImage.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Render/BitPdfIndexedColorSpace.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Render/BitPdfLabColorSpace.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Render/BitPdfPngEncoder.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Render/BitPdfSeparationColorSpace.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Security/BitPdfCipherKind.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Security/BitPdfManagedAes.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Security/BitPdfManagedMd5.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Security/BitPdfRc4.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Security/BitPdfStandardSecurityHandler.cssrc/BlazorUI/Demo/Bit.BlazorUI.Demo.Server/Startup/Middlewares.cssrc/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Extras/PdfViewer/BitPdfViewerDemo.razorsrc/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Extras/PdfViewer/BitPdfViewerDemo.razor.cssrc/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Web/Bit.BlazorUI.Demo.Client.Web.csprojsrc/BlazorUI/Tests/Bit.BlazorUI.Tests/Bit.BlazorUI.Tests.csprojsrc/BlazorUI/Tests/Bit.BlazorUI.Tests/Components/Extras/PdfViewer/BitPdfOpCodeTests.cssrc/BlazorUI/Tests/Bit.BlazorUI.Tests/Components/Extras/PdfViewer/BitPdfViewerTests.cs
|
@coderabbitai full-review |
|
✅ Action performedFull review finished. |
There was a problem hiding this comment.
Actionable comments posted: 3
🧹 Nitpick comments (1)
src/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Content/BitPdfTextExtractor.cs (1)
67-74: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueConsolidate identical switch cases.
The
NextLineShowTextandNextLineShowTextSpacingcases perform the exact same operations and can be combined to reduce duplication.♻️ Proposed refactor
case BitPdfOpCode.NextLineShowText: - sb.Append('\n'); - AppendShow(sb, font, op.Operands.Count > 0 ? op.Operands[^1] : null); - break; case BitPdfOpCode.NextLineShowTextSpacing: sb.Append('\n'); AppendShow(sb, font, op.Operands.Count > 0 ? op.Operands[^1] : null); break;🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Content/BitPdfTextExtractor.cs` around lines 67 - 74, Consolidate the BitPdfOpCode.NextLineShowText and BitPdfOpCode.NextLineShowTextSpacing branches in the switch so both share one implementation of the newline append and AppendShow call, preserving their current behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/BitPdfViewer.razor.cs`:
- Around line 796-799: Update ParseAsync to accept and propagate a per-load
CancellationToken through BitPdfDocument.Load, including the Task.Run path and
all parsing loops. Cancel the previous token when a new load supersedes it or
the component is disposed, and ensure cancellation stops stale parsing rather
than only suppressing result publication; preserve the browser synchronous path
while passing the token through.
- Around line 1535-1562: Update the search flow around the per-page matching and
RenderPageAsync calls so it does not render every matching page before
publishing state. Retain match metadata for all pages, but limit rendering to
the current page and nearby matches according to the existing MaxRenderedPages
policy, and refresh highlights as navigation changes. Ensure StateHasChanged
does not batch hundreds of rendered pages into the _pages collection.
- Around line 323-382: Update the print flow containing _loadVersion and
BitPdfViewerPrint to capture _renderEpoch at the start and validate it alongside
the load version after every await, including initial delays, page rendering,
canvas painting, and DOM-paint delays. Abort immediately when the captured epoch
changes, including immediately before invoking BitPdfViewerPrint, so rotation or
render-mode changes cannot print cleared page slots.
---
Nitpick comments:
In
`@src/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Content/BitPdfTextExtractor.cs`:
- Around line 67-74: Consolidate the BitPdfOpCode.NextLineShowText and
BitPdfOpCode.NextLineShowTextSpacing branches in the switch so both share one
implementation of the newline append and AppendShow call, preserving their
current behavior.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 938497c0-cc8e-4cb8-b858-a789bb0135bf
⛔ Files ignored due to path filters (2)
src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/wwwroot/samples/hello-world.pdfis excluded by!**/*.pdfsrc/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/wwwroot/samples/sample-pdf.pdfis excluded by!**/*.pdf
📒 Files selected for processing (98)
src/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/BitPdfRenderMode.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/BitPdfSource.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/BitPdfTextCoalescing.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/BitPdfViewer.razorsrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/BitPdfViewer.razor.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/BitPdfViewer.scsssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/BitPdfViewer.tssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/BitPdfViewerJsRuntimeExtensions.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/BitPdfZoomMode.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfAcroForm.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfBaseStream.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfCmd.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfDestination.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfDestinationFit.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfDict.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfDocument.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfFormField.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfFormatException.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfLexer.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfMetadata.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfName.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfOutlineBuilder.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfOutlineItem.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfPage.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfPageLabelBuilder.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfParser.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfPasswordException.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfPermissions.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfPrimitives.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfRef.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfRefSet.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfRefSetCache.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfStream.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfString.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfStructElement.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfStructTree.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfUnsupportedEncryptionException.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfXRef.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Content/BitPdfContentParser.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Content/BitPdfOpCode.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Content/BitPdfOperation.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Content/BitPdfTextExtractor.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Filters/BitPdfCcittFaxDecoder.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Filters/BitPdfCcittParams.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Filters/BitPdfJpegDecoder.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Filters/BitPdfJpegImage.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Filters/BitPdfLzwDecode.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Filters/BitPdfPredictor.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Filters/BitPdfStreamDecoder.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Fonts/BitPdfCMap.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Fonts/BitPdfCffFontParser.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Fonts/BitPdfCffFontWriter.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Fonts/BitPdfCmapBuilder.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Fonts/BitPdfEncodings.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Fonts/BitPdfFont.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Fonts/BitPdfGlyph.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Fonts/BitPdfGlyphList.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Fonts/BitPdfGlyphOutline.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Fonts/BitPdfPathSeg.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Fonts/BitPdfSfntGlyphMapper.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Fonts/BitPdfStandardFonts.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Fonts/BitPdfToUnicodeCMap.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Fonts/BitPdfTrueTypeSanitizer.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Fonts/BitPdfType1Font.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Fonts/BitPdfType3FontData.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Fonts/BitPdfWinAnsiEncoding.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Functions/BitPdfConstantFunction.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Functions/BitPdfExponentialFunction.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Functions/BitPdfFunction.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Functions/BitPdfPostScriptFunction.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Functions/BitPdfSampledFunction.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Functions/BitPdfStitchingFunction.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Geometry/BitPdfMatrix.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/IBlazorPdfXRef.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Render/BitPdfCanvasRenderResult.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Render/BitPdfCanvasRenderer.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Render/BitPdfColorSpace.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Render/BitPdfCssShadingBuilder.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Render/BitPdfFontStore.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Render/BitPdfGraphicsState.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Render/BitPdfHtmlRenderer.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Render/BitPdfImage.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Render/BitPdfIndexedColorSpace.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Render/BitPdfLabColorSpace.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Render/BitPdfPngEncoder.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Render/BitPdfSeparationColorSpace.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Security/BitPdfCipherKind.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Security/BitPdfManagedAes.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Security/BitPdfManagedMd5.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Security/BitPdfRc4.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Security/BitPdfStandardSecurityHandler.cssrc/BlazorUI/Demo/Bit.BlazorUI.Demo.Server/Startup/Middlewares.cssrc/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Extras/PdfViewer/BitPdfViewerDemo.razorsrc/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Extras/PdfViewer/BitPdfViewerDemo.razor.cssrc/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Web/Bit.BlazorUI.Demo.Client.Web.csprojsrc/BlazorUI/Tests/Bit.BlazorUI.Tests/Bit.BlazorUI.Tests.csprojsrc/BlazorUI/Tests/Bit.BlazorUI.Tests/Components/Extras/PdfViewer/BitPdfOpCodeTests.cssrc/BlazorUI/Tests/Bit.BlazorUI.Tests/Components/Extras/PdfViewer/BitPdfViewerTests.cs
|
@coderabbitai full-review |
|
✅ Action performedFull review finished. |
There was a problem hiding this comment.
Actionable comments posted: 3
🧹 Nitpick comments (1)
src/BlazorUI/Tests/Bit.BlazorUI.Tests/Components/Extras/PdfViewer/BitPdfViewerTests.cs (1)
84-107: 📐 Maintainability & Code Quality | 🔵 Trivial | 🏗️ Heavy liftExercise the browser-specific background-rendering path.
bUnit runs outside the browser, where parsing already uses
Task.Runregardless ofBackgroundRendering. This test therefore cannot detect regressions in the threaded WASM branch. Add browser-hosted coverage, or extract the scheduling decision behind a testable abstraction.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/BlazorUI/Tests/Bit.BlazorUI.Tests/Components/Extras/PdfViewer/BitPdfViewerTests.cs` around lines 84 - 107, Update BitPdfViewerShouldLoadAndRenderWithBackgroundRendering so it exercises the browser-specific BackgroundRendering scheduling path rather than relying solely on bUnit’s non-browser execution. Add browser-hosted coverage, or route the scheduling decision through a testable abstraction and verify the threaded WASM branch while preserving the existing document-loaded and page-render assertions.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/BitPdfViewer.razor.cs`:
- Around line 506-528: Move the Task.Delay(1) event-loop yield in the main
rendering pump outside the successful RenderPageAsync branch so it also runs
after failed renders; preserve disposal checks and successful-render updates.
Apply the same structure to the thumbnail rendering pump at
src/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/BitPdfViewer.razor.cs#L586-L607.
- Around line 789-795: Update the print barrier logic around _canvasPaintSignal
and OnAfterRenderAsync to associate each signal with the canvas-paint generation
requested by Print. Increment or capture the generation when canvases are
dirtied, store the target generation with the signal, and only complete it after
OnAfterRenderAsync finishes painting that generation; an earlier render pass
must leave the signal pending.
In
`@src/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Render/BitPdfImage.cs`:
- Around line 449-471: Update both soft-mask rendering loops around the rowStart
calculations to compute the source row offset using a wide integer type before
multiplying by rowBytes, then convert only after safely validating or
constraining the resulting offset for ReadBits. Ensure masks with large declared
widths cannot wrap to a negative offset, preserving the existing row-selection
behavior in both the matte and non-matte paths.
---
Nitpick comments:
In
`@src/BlazorUI/Tests/Bit.BlazorUI.Tests/Components/Extras/PdfViewer/BitPdfViewerTests.cs`:
- Around line 84-107: Update
BitPdfViewerShouldLoadAndRenderWithBackgroundRendering so it exercises the
browser-specific BackgroundRendering scheduling path rather than relying solely
on bUnit’s non-browser execution. Add browser-hosted coverage, or route the
scheduling decision through a testable abstraction and verify the threaded WASM
branch while preserving the existing document-loaded and page-render assertions.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 6c39218c-d650-4210-b162-d67c0c36540f
⛔ Files ignored due to path filters (2)
src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/wwwroot/samples/hello-world.pdfis excluded by!**/*.pdfsrc/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/wwwroot/samples/sample-pdf.pdfis excluded by!**/*.pdf
📒 Files selected for processing (98)
src/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/BitPdfRenderMode.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/BitPdfSource.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/BitPdfTextCoalescing.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/BitPdfViewer.razorsrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/BitPdfViewer.razor.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/BitPdfViewer.scsssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/BitPdfViewer.tssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/BitPdfViewerJsRuntimeExtensions.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/BitPdfZoomMode.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfAcroForm.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfBaseStream.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfCmd.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfDestination.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfDestinationFit.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfDict.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfDocument.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfFormField.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfFormatException.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfLexer.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfMetadata.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfName.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfOutlineBuilder.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfOutlineItem.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfPage.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfPageLabelBuilder.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfParser.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfPasswordException.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfPermissions.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfPrimitives.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfRef.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfRefSet.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfRefSetCache.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfStream.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfString.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfStructElement.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfStructTree.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfUnsupportedEncryptionException.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/BitPdfXRef.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Content/BitPdfContentParser.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Content/BitPdfOpCode.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Content/BitPdfOperation.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Content/BitPdfTextExtractor.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Filters/BitPdfCcittFaxDecoder.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Filters/BitPdfCcittParams.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Filters/BitPdfJpegDecoder.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Filters/BitPdfJpegImage.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Filters/BitPdfLzwDecode.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Filters/BitPdfPredictor.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Filters/BitPdfStreamDecoder.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Fonts/BitPdfCMap.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Fonts/BitPdfCffFontParser.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Fonts/BitPdfCffFontWriter.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Fonts/BitPdfCmapBuilder.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Fonts/BitPdfEncodings.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Fonts/BitPdfFont.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Fonts/BitPdfGlyph.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Fonts/BitPdfGlyphList.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Fonts/BitPdfGlyphOutline.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Fonts/BitPdfPathSeg.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Fonts/BitPdfSfntGlyphMapper.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Fonts/BitPdfStandardFonts.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Fonts/BitPdfToUnicodeCMap.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Fonts/BitPdfTrueTypeSanitizer.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Fonts/BitPdfType1Font.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Fonts/BitPdfType3FontData.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Fonts/BitPdfWinAnsiEncoding.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Functions/BitPdfConstantFunction.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Functions/BitPdfExponentialFunction.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Functions/BitPdfFunction.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Functions/BitPdfPostScriptFunction.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Functions/BitPdfSampledFunction.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Functions/BitPdfStitchingFunction.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Geometry/BitPdfMatrix.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/IBlazorPdfXRef.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Render/BitPdfCanvasRenderResult.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Render/BitPdfCanvasRenderer.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Render/BitPdfColorSpace.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Render/BitPdfCssShadingBuilder.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Render/BitPdfFontStore.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Render/BitPdfGraphicsState.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Render/BitPdfHtmlRenderer.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Render/BitPdfImage.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Render/BitPdfIndexedColorSpace.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Render/BitPdfLabColorSpace.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Render/BitPdfPngEncoder.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Render/BitPdfSeparationColorSpace.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Security/BitPdfCipherKind.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Security/BitPdfManagedAes.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Security/BitPdfManagedMd5.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Security/BitPdfRc4.cssrc/BlazorUI/Bit.BlazorUI.Extras/Components/PdfViewer/Core/Security/BitPdfStandardSecurityHandler.cssrc/BlazorUI/Demo/Bit.BlazorUI.Demo.Server/Startup/Middlewares.cssrc/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Extras/PdfViewer/BitPdfViewerDemo.razorsrc/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Extras/PdfViewer/BitPdfViewerDemo.razor.cssrc/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Web/Bit.BlazorUI.Demo.Client.Web.csprojsrc/BlazorUI/Tests/Bit.BlazorUI.Tests/Bit.BlazorUI.Tests.csprojsrc/BlazorUI/Tests/Bit.BlazorUI.Tests/Components/Extras/PdfViewer/BitPdfOpCodeTests.cssrc/BlazorUI/Tests/Bit.BlazorUI.Tests/Components/Extras/PdfViewer/BitPdfViewerTests.cs
|
@coderabbitai full-review |
|
✅ Action performedFull review finished. |
closes #12654
Summary by CodeRabbit
Improvements
New Features / API Changes
BackgroundRendering.EnsurePagesRendered/EnsureThumbsRenderedare now async (Task-returning).Heightvalue (no longer auto-sets780px).UI/Rendering
Demo, Tests & Platform