pdfx: fix error if rawDocumentProgress is NaN - #602
Closed
akiller wants to merge 1 commit into
Closed
Conversation
Member
vicajilau
added a commit
that referenced
this pull request
Aug 20, 2026
…inch (#621) * fix(pdfx): evita crash "Infinity or NaN toInt" en PdfViewPinch Cuando el documento cabe exactamente en el viewport (o cuando ambos miden 0 durante el primer frame en Android edge-to-edge / gesture nav), el divisor (_docSize.height - _lastViewSize.height) es 0 y produce NaN/Infinity. Al llegar a .round().toInt() lanza UnsupportedError y el PDF se queda en blanco. Se normaliza rawDocumentProgress a 0.0 cuando es NaN o Infinite antes de aplicar .round(): no hay recorrido pendiente si el documento cabe en pantalla. Basado en el PR #602 de akiller (upstream, sin merge desde nov 2025). Repro: Pixel 10a Android 15/16, pdfx 2.9.2. * Translate guard comment to English * Apply dart format --------- Co-authored-by: Victor Carreras <34163765+vicajilau@users.noreply.github.com>
Member
|
Following up on the earlier comment: we merged #621, which has the same NaN/Infinity guard as this PR plus an updated branch and an explanatory comment. Closing this as a duplicate. Thanks for the fix, and sorry for the delay in following up. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Using pdfx 2.9.2, and also when using the latest changes on main.
I'm seeing the PDF widget render as a white block on iOS, or very occasionally a red Flutter error:
It seems to be fine if using Axis.vertical but not when using horizontal scrolling:
The error in my logs is:
Which through debugging is caused by line 298 of pdf_view_pinch.dart inside _determinePagesToShow():
In my case, the rawDocumentProgress calculation ended up being
(503.15789473684214 - 503.15789473684214) / (503.15789473684214 - 503.15789473684214)= 0/0 which results in a NaN in Flutter.This PR adds a check to set the progress to 0 if rawDocumentProgress is NaN.
It seems to work OK, but I have no idea if this will have any negative effects elsewhere
Thanks