lohanidamodar / pdf_viewer

A flutter plugin for handling PDF files. Works on both Android & iOS
https://pub.dev/packages/advance_pdf_viewer
BSD 3-Clause "New" or "Revised" License
61 stars 145 forks source link

Methods marked with @UiThread must be executed on the main thread. #86

Open kNoAPP opened 3 years ago

kNoAPP commented 3 years ago
I/System.out(31423): Already closed
W/System.err(31423): java.lang.IllegalStateException: Already closed
W/System.err(31423):    at android.graphics.pdf.PdfRenderer.throwIfClosed(PdfRenderer.java:270)
W/System.err(31423):    at android.graphics.pdf.PdfRenderer.close(PdfRenderer.java:187)
W/System.err(31423):    at pt.tribeiro.flutter_plugin_pdf_viewer.FlutterPluginPdfViewerPlugin.getPage(FlutterPluginPdfViewerPlugin.java:206)
W/System.err(31423):    at pt.tribeiro.flutter_plugin_pdf_viewer.FlutterPluginPdfViewerPlugin.access$100(FlutterPluginPdfViewerPlugin.java:31)
W/System.err(31423):    at pt.tribeiro.flutter_plugin_pdf_viewer.FlutterPluginPdfViewerPlugin$1.run(FlutterPluginPdfViewerPlugin.java:84)
W/System.err(31423):    at android.os.Handler.handleCallback(Handler.java:883)
W/System.err(31423):    at android.os.Handler.dispatchMessage(Handler.java:100)
W/System.err(31423):    at android.os.Looper.loop(Looper.java:237)
W/System.err(31423):    at android.os.HandlerThread.run(HandlerThread.java:67)
D/PdfViewerPlugin(31423): Retrieving page failed.
E/AndroidRuntime(31423): FATAL EXCEPTION: flutterPdfViewer
E/AndroidRuntime(31423): Process: net.vpl.one_on_one, PID: 31423
E/AndroidRuntime(31423): java.lang.RuntimeException: Methods marked with @UiThread must be executed on the main thread. Current thread: flutterPdfViewer
E/AndroidRuntime(31423):    at io.flutter.embedding.engine.FlutterJNI.ensureRunningOnMainThread(FlutterJNI.java:1280)
E/AndroidRuntime(31423):    at io.flutter.embedding.engine.FlutterJNI.invokePlatformMessageEmptyResponseCallback(FlutterJNI.java:933)
E/AndroidRuntime(31423):    at io.flutter.embedding.engine.dart.DartMessenger$Reply.reply(DartMessenger.java:167)
E/AndroidRuntime(31423):    at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler$1.notImplemented(MethodChannel.java:248)
E/AndroidRuntime(31423):    at pt.tribeiro.flutter_plugin_pdf_viewer.FlutterPluginPdfViewerPlugin$1.run(FlutterPluginPdfViewerPlugin.java:87)
E/AndroidRuntime(31423):    at android.os.Handler.handleCallback(Handler.java:883)
E/AndroidRuntime(31423):    at android.os.Handler.dispatchMessage(Handler.java:100)
E/AndroidRuntime(31423):    at android.os.Looper.loop(Looper.java:237)
E/AndroidRuntime(31423):    at android.os.HandlerThread.run(HandlerThread.java:67)
I/ViewRootImpl@8602f9b[MainActivity](31423): MSG_WINDOW_FOCUS_CHANGED 0 1

Branch: develop

Device: Note 9, Android 10

Steps to reproduce:

PDFViewer(
  document: _doc!, // Any valid .pdf document
  lazyLoad: false,
  showPicker: false,
  showNavigation: false,
  scrollDirection: Axis.vertical,
  progressIndicator: const CupertinoActivityIndicator(),
),

This stack is thrown when opening any pdf document.

dujardin-quentin commented 3 years ago

Same issue since the update of android embedding (dev or https://github.com/enveraltin/pdf_viewer.git)

enveraltin commented 3 years ago

@kNoAPP @gtu-myowin is the file you're trying to open local or remote?

gtu-myowin commented 3 years ago

@enveraltin The crash happens for both local (Inside Application Documents Directory) and remote files.

tomtitherington commented 2 years ago

I'm experiencing the same - OnePlus 6, Android 10.