packages.flutter
packages.flutter copied to clipboard
[Android only] App crashes on PlattformException
Describe the bug
When I try to check the error handling for non-PDF files, I get a
PlatformException (PlatformException(RENDER_ERROR, Invalid PDF format, null, null))
on iOS when I load a PNG file. This is totally fine and expected as I can handle the error with the errorBuilder
.
On Android, the same test-file causes the app to crash in the simulator, as well as on device:
I[/flutter]() (18263): PlatformException(PdfRendererException, io.scer.pdfx.PdfRendererException: Can't open file, Cause: null, Stacktrace: io.scer.pdfx.PdfRendererException: Can't open file
I[/flutter]() (18263): at io.scer.pdfx.Messages.openDocumentFile(Messages.kt:73)
I[/flutter]() (18263): at dev.flutter.pigeon.Pigeon$PdfxApi.lambda$setup$1(Pigeon.java:1131)
I[/flutter]() (18263): at dev.flutter.pigeon.-$$Lambda$Pigeon$PdfxApi$dJmc5gvkZ0Szsm4_Cv_2xqqkC3M.onMessage(Unknown Source:2)
I[/flutter]() (18263): at io.flutter.plugin.common.BasicMessageChannel$IncomingMessageHandler.onMessage(BasicMessageChannel.java:217)
I[/flutter]() (18263): at io.flutter.embedding.engine.dart.DartMessenger.invokeHandler(DartMessenger.java:296)
I[/flutter]() (18263): at io.flutter.embedding.engine.dart.DartMessenger.lambda$dispatchMessageToQueue$0$DartMessenger(DartMessenger.java:320)
I[/flutter]() (18263): at io.flutter.embedding.engine.dart.-$$Lambda$DartMessenger$TsixYUB5E6FpKhMtCSQVHKE89gQ.run(Unknown Source:12)
I[/flutter]() (18263): at android.os.Handler.handleCallback(Handler.java:938)
I[/flutter]() (18263): at android.os.Handler.dispatchMessage(Handler.java:99)
I[/flutter]() (18263): at android.os.Looper.loop(Looper.java:223)
I[/flutter]() (18263): at android.app.ActivityThread.
I[/flutter]() (18263): #0 PdfxApi.openDocumentFile
package:pdfx/…/io/pigeon.dart:544
I[/flutter]() (18263): <asynchronous suspension>
I[/flutter]() (18263): #1 PdfxPlatformPigeon.openFile
package:pdfx/…/io/platform_pigeon.dart:31
I[/flutter]() (18263): <asynchronous suspension>
I[/flutter]() (18263): ----------------------------------------------------
D[/HostConnection]()(18263): HostConnection::get() New Host Connection established 0xe8aa0530, tid 18298
F[/libc]() (18263): FORTIFY: pthread_mutex_lock called on a destroyed mutex (0xb8c4a008)
F[/libc]() (18263): Fatal signal 6 (SIGABRT), code -1 (SI_QUEUE) in tid 18305 (dart:io EventHa), pid 18263
To Reproduce
Steps to reproduce the behavior:
Use this code snippet on a page to load e.g. a PNG file:
PdfView(
scrollDirection: Axis.vertical,
controller: PdfController(
document: PdfDocument.openFile(_file!.path),
),
builders: PdfViewBuilders<DefaultBuilderOptions>(
options: const DefaultBuilderOptions(),
errorBuilder: (context, error) {
// On iOS, this is reached. On Android, the App Crashes.
Logger('PDFView').severe(
'PdfView loading failed',
error,
StackTrace.current,
);
return Center(
child: Text("Some Error"),
);
},
),
)
Expected behavior I would expect the same error-handling on Android and iOS.
Smartphone (please complete the following information):
- Device: [e.g. Pixel5 Simulator]
- OS: [Android 11]
- Version [30]