afreakyelf / Pdf-Viewer

A Lightweight PDF Viewer Android library which only occupies around 80kb while most of the Pdf viewer occupies up to 16MB space.
https://afreakyelf.github.io/Pdf-Viewer/
MIT License
692 stars 150 forks source link

Improve Error Handling when receiving invalid PDF #138

Open LarsWigger opened 4 weeks ago

LarsWigger commented 4 weeks ago

I just spent quit a bit of time debugging the PdfRendererView.initWithUrl() call because the app kept crashing when trying to load a specific PDF. In the end, the issue was that the server sent a 302 with a small HTML message when using the default headers (while accepting the default headers of every single other client I tried).

While this was not an issue on the side of Pdf-Viewer, I found the error handling pretty unhelpful and it definitely should not allow the app to crash when such a thing happens. I encountered two separate issues: The download silently failing because it was incomplete (I think the statusListener did not react to this, even though I saw the error messages in the logs) and the main issue of the app crashing when the data received was actually not a PDF document.

I suggest trying to download invalid data and checking whether the error handling is graceful and the error logging can be improved.

github-actions[bot] commented 4 weeks ago

Thank you for creating your first issue. We appreciate your help in making this project better. We will look into it, and get back to you soon. Need help or want to discuss this issue? Join our Discord community here to ask questions and discuss this issue live!