Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

An unhandleable error is thrown when attempting to display unsupported files, such as password-protected PDFs #504

Open
chocoyama opened this issue Apr 24, 2024 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@chocoyama
Copy link

Describe the bug
When attempting to display a password-protected PDF file using the pdfx library in a Flutter application, the app fails to load the document and throws the following error instead:

════════ Exception caught by image resource service ════════════════════════════
The following PlatformException was thrown resolving an image codec:
PlatformException(RENDER_ERROR, Unexpected error: renderer is nil., null, null)

When the exception was thrown, this was the stack:
#0      PdfxApi.getPage (package:pdfx/src/renderer/io/pigeon.dart:647:7)
pigeon.dart:647
<asynchronous suspension>
#1      PdfDocumentPigeon.getPage.<anonymous closure> (package:pdfx/src/renderer/io/platform_pigeon.dart:99:24)
platform_pigeon.dart:99
<asynchronous suspension>
#2      BasicLock.synchronized (package:synchronized/src/basic_lock.dart:33:16)
basic_lock.dart:33
<asynchronous suspension>
#3      _PdfViewState._getPageImage.<anonymous closure> (package:pdfx/src/viewer/simple/pdf_view.dart:121:22)
pdf_view.dart:121
<asynchronous suspension>
#4      BasicLock.synchronized (package:synchronized/src/basic_lock.dart:33:16)
basic_lock.dart:33
<asynchronous suspension>
#5      PdfPageImageProvider._loadAsync (package:pdfx/src/viewer/pdf_page_image_provider.dart:44:32)
pdf_page_image_provider.dart:44
<asynchronous suspension>
#6      MultiFrameImageStreamCompleter._handleCodecReady (package:flutter/src/painting/image_stream.dart:985:3)
image_stream.dart:985
<asynchronous suspension>

Page: 0, DocumentId: 9E53B1E8-D4EC-4FB2-A368-07DB67BBC315

The PdfView interface provides onDocumentError and errorBuilder methods, but these are not triggered in this case, leaving no way to handle the error within the application.

To Reproduce
Steps to reproduce the behavior:

  1. Integrate the pdfx library into a Flutter project.
  2. Attempt to open a password-protected PDF file using PdfView.
  3. Observe that the document fails to load and the specified error is thrown.
  4. Note that onDocumentError and errorBuilder are not called, even though an error has occurred.

Expected behavior
I expect the pdfx library to provide an interface or mechanism to explicitly catch and handle errors like this. The library should enable developers to implement error handling through an interface or callback function specifically designed to manage these types of errors when rendering fails.

Screenshots

Smartphone (please complete the following information):
I've only confirmed this on iOS, but it doesn't seem to be device-dependent.

Additional context

@chocoyama chocoyama added the bug Something isn't working label Apr 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants