Viewing 10 posts - 1 through 10 (of 13 total)
  • Author
  • #10411 Reply


    Dear Dr. Plug,

    plugpdf.openFile(path, “”);

    is run on the main thread seems, because UI blocks while loading and Android warns that using a AsyncTask is impossible.

    This causes lag for the user. It also seems that load obviously takes up the most startup time for the activity.

    It seems to be because:

    is run from openFile and thus the native load call is executed on the main thread.

    Also, i would like to set the PDFDocument myself, that would seem to resolve the issue? But ReaderView does not have a set method for the mDoc private property.

    Any ideas on how to increase loading performance?

    #10420 Reply

    Dr. Plug

    Hi Ben,

    Sorry for late reply. First, you can open PDF to another thread by using AsyncTask. like below,

    But! our SDK have using UI edit such as load display in the openFile(…). So, you should set UI again on the UI Thread(Main Thread) after openFile. So, you can set UI like below.

    Thank you,
    Dr. Plug

    #10422 Reply


    Not true.

    At least the Android Studio does not agree with you.


    Im an experienced developer, I would have used AsyncTask if it was possible.

    What do you think?

    #10423 Reply


    As expected, im getting exceptions because of the thread when using the AsyncTask:

    E/PlugPDF: [ERROR] java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()

    #10424 Reply


    I think it is because you are calling:

    this.setPageDisplayMode(PageDisplayMode.HORIZONTAL); in openFile.

    so thus it is creating an clearing views on a background thread.


    this.loadDisplay(new HorizontalDisplay(this.mCtx));

    leading to:

    #10425 Reply


    After forcing it to use AsyncTask, I got crazy behaviour.

    Sometimes the page would not load at all. Other times it would load but allow horizontal scrolling even though it is a single page.

    Also many flickers and other issues. It is clearly on the wrong thread.

    The only stable use is loading the ReaderView.openFile on the main thread.

    I think either something has changed or there is a fundamental problem with your readerView code and it must be rewritten.

    Are you able to share the REaderView source? Because that would not put your native libs in danger. But allow for a reimplementation by me? I need this smooth soon.

    #10427 Reply


    Also yes i did use your example of setting the page mode in the onPostExecute.

    Also your SimpleDocumentReader uses the main thread also.

    So at this point im thinking of adding your package to my project and implementing a ReaderView myself.

    Please provide the source code for the core classes please.

    #10428 Reply

    Dr. Plug

    Hello Ben,

    You are right. First, openFile was contained UI edit by call the ‘setPageDisplayMode’, So you could saw the “E/PlugPDF: [ERROR] java.lang.RuntimeException”. But, that time, ReaderView has opened the document successfully. And It work fine after set the only BasePlugPDFDisplay. that task is ‘onPostExecute’ in the my previous comment.

    But if you want a source of the ReaderView. I can provide it. If you contact “” this mail with this post link, I send the file to you.

    Thank you,
    Dr. Plug

    • This reply was modified 1 year, 10 months ago by  Dr. Plug.
    #10439 Reply


    Dear Dr. Plug,

    Well like I said, I tried your solution and I could not get it to work properly.

    So I will send you that email and address it myself. If you know this is an issue, are you planning to fix it?


    #10440 Reply


    Dear Dr Plug,

    I have now used the new version and it works well after your fix.

    I still would like the source of the readerview etc for the future.

    Thanks for fixing it in your release. What now remains is the fact that Android still complains about the line, but at least it works.


Viewing 10 posts - 1 through 10 (of 13 total)
Reply To: Loading PDF data in the background instead of in the maint thread
Your information: