fix(pdfx): guard rawDocumentProgress against NaN/Infinity in PdfViewPinch#621
Open
MarkianUchiha wants to merge 1 commit into
Open
fix(pdfx): guard rawDocumentProgress against NaN/Infinity in PdfViewPinch#621MarkianUchiha wants to merge 1 commit into
MarkianUchiha wants to merge 1 commit into
Conversation
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 ScerIO#602 de akiller (upstream, sin merge desde nov 2025). Repro: Pixel 10a Android 15/16, pdfx 2.9.2.
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.
Problem
PdfViewPinchcrashes on Android with:Reproduced on
pdfx 2.9.2, Pixel 10a running Android 15/16/17 (edge-to-edge / gesture nav).Root cause
In
_determinePagesToShow,rawDocumentProgressis computed as:When the document fits exactly in the viewport (or both dimensions are still 0 during the first frame on Android edge-to-edge), the divisor is 0 → produces
NaN/Infinity→.round().toInt()throwsUnsupportedErrorand the PDF stays blank.Fix
Normalize
rawDocumentProgressto0.0when it isNaNorInfinitebefore calling.round(). When the document fits the viewport there is no scroll progress to report —0.0is the correct semantic value.Notes