espresso3389 / pdfrx

pdfrx is yet another PDF viewer implementation that built on the top of pdfium. The plugin currently supports Android, iOS, Windows, macOS, Linux, and Web.
MIT License
62 stars 38 forks source link

Render performance is terrible on many page documents #12

Closed sidetraxaudio closed 4 months ago

sidetraxaudio commented 5 months ago

Excellent work but underlying philosophy regarding rendering/caching/rasterizing pages is a problem. Rendering a very basic many-page PDF file full of basic text shows very bad performance and long delays waiting for pages to render. Also pages that have already been rendered are disposed and not cached. For example, scrolling to the bottom of a long document and then to the top and back to the bottom sees the bottom pages needing to re-render with a long delay.

espresso3389 commented 5 months ago

Yes, it's on my TODO list. The current cache control mechanism is not optimum.

Do you think just updating cache mechanism is enough? Or, any other opinion/ideas?

mlican commented 4 months ago

The loading time of the PDF file below seems a bit long when viewing it. Could you investigate what might be causing the issue? Green Chemistry_ CHEM _25-12-2023 -fpdf_231226_103903.pdf

espresso3389 commented 4 months ago

0.4.3 fixes apparently broken cache mechanism.

It's still not fast in some case, but the latest version show the pages faster than the previous versions.

mlican commented 4 months ago

0.4.3 fixes apparently broken cache mechanism.

It's still not fast in some case, but the latest version show the pages faster than the previous versions.

Loading is obviously faster on Windows, but the improvement on Android is not very obvious.

espresso3389 commented 4 months ago

@mlican So, do you need more speed on Android?

I'm testing the example on Pixel 6a and, for me, the speed is just "acceptable".

Could you give me some solid goal for the issue or, anyway I'll keep the issue open and try to improve the performance if I can. (I mean, not just now but sometime in future)

espresso3389 commented 4 months ago

As a side note, I found that the key algorithm for the issue is cancellation of the rendering for skipped pages. It's already in the code but not working well for Android.

mlican commented 4 months ago

@mlican So, do you need more speed on Android?

I'm testing the example on Pixel 6a and, for me, the speed is just "acceptable".

Could you give me some solid goal for the issue or, anyway I'll keep the issue open and try to improve the performance if I can. (I mean, not just now but sometime in future)

When jumping to a specific page on Android in a PDF, there is a long period of blank screen, while on Windows it performs much better.

https://github.com/espresso3389/pdfrx/assets/10806361/cf485e59-bdfe-4466-b7c5-fe19cbe980e9

espresso3389 commented 4 months ago

0.4.6 introduces PdfPage.render cancellation mechanism to skip rendering of pages that are just passed-by during the long scrolling.

mlican commented 4 months ago

0.4.6 introduces PdfPage.render cancellation mechanism to skip rendering of pages that are just passed-by during the long scrolling.

Wow, thank you so much.

mlican commented 4 months ago

0.4.6 introduces PdfPage.render cancellation mechanism to skip rendering of pages that are just passed-by during the long scrolling.

The following error occurs when building Android

Execution failed for task ':pdfrx:buildCMakeRelWithDebInfo[armeabi-v7a]'.
...
pdfrx-0.4.6/src/pdfium_interop.cpp:5:10: fatal error: 'fpdfview.h' file not found
  #include <fpdfview.h>
           ^~~~~~~~~~~~
  1 error generated.
  ninja: build stopped: subcommand failed.
mlican commented 4 months ago

0.4.6 introduces PdfPage.render cancellation mechanism to skip rendering of pages that are just passed-by during the long scrolling.

The following error occurs when building Android

Execution failed for task ':pdfrx:buildCMakeRelWithDebInfo[armeabi-v7a]'.
...
pdfrx-0.4.6/src/pdfium_interop.cpp:5:10: fatal error: 'fpdfview.h' file not found
  #include <fpdfview.h>
           ^~~~~~~~~~~~
  1 error generated.
  ninja: build stopped: subcommand failed.

"x86_64/pdfium/chromium%2F6150/lib/libpdfium.so" does not exist under the x86_64 directory

espresso3389 commented 4 months ago

@mlican Please discuss the build issue on #16.