4

I have been trying to open a pdf file by URL in a full screen WebView. Loading the file is no issue, but performance is a BIG one. Scrolling is almost non-responsive, with changes appearing up to 5 seconds after the scroll. Same idea for zooming in/out. This makes the activity almost unusable.

Here's how I'm opening the pdf:

WebView webView = (WebView)findViewById(R.id.webview);
webView.getSettings().setJavaScriptEnabled(true);
webView.loadUrl("http://docs.google.com/gview?embedded=true&url=" + url);

I have tried to set hardwareAccelerated to true and to false in the AndroidManifest, which had no change.

I have tried the solution found here about setting render priority, but that has also had no change on performance.

I have tried to set the Layer Type (mWebView.setLayerType(View.LAYER_TYPE_HARDWARE, null);), but this has also had no effect on the performance.

The pdf file itself is very small at about 6 pages. It is 177Kb in size. The phone I am testing on is a Samsung Galaxy S5, so hardware performance is no issue. The network connection is very good. This leads me to believe there is either something wrong with my code, or with the WebView or Google Viewer.

How can I improve performance on this webview?

edit: I have tried a different pdf file, same result.

Community
  • 1
  • 1
h_k
  • 1,674
  • 1
  • 24
  • 46
  • not sure if you can do anything but you can try Embeding Croswalk, as an alternative to WebView -- should be faster -- https://crosswalk-project.org/documentation/embedding_crosswalk.html -- AS Demo download to test if any better -- https://github.com/dougdiego/CrosswalkDemo -- make sure in build gradle-- https://github.com/dougdiego/CrosswalkDemo/blob/master/app/build.gradle -- you use the latest version of Crosswalk (org.xwalk:xwalk_core_library) -- (15.44.384.12) and api and build – Tasos Nov 02 '15 at 18:24
  • most device will have an embedded pdf reader, so you can try to use it instead – njzk2 Nov 02 '15 at 19:09
  • @njzk2 Thanks, I've also considered simply downloading the file as well, but I'd prefer the user stay inside the app for a smoother UX. – h_k Nov 02 '15 at 19:10
  • If the drawback of a smooth UX is a terribly slow and lagging UI, I'd say that's not a good bargain. – njzk2 Nov 02 '15 at 19:11
  • you can use pdf.js from mozilla to show a pdf in a webview without google docs. It has decent performances, provided that you implement the hooks properly – njzk2 Nov 02 '15 at 19:12
  • @njzk2 if I were happy with current performance, I wouldn't have made this thread ;) I'll look into pdf.js. Thank you. – h_k Nov 02 '15 at 19:38

0 Answers0