PDF in webview performance

后端 未结 2 1197
后悔当初
后悔当初 2021-01-01 08:17

I am using the following (simple) code to load a PDF from the documents folder in my app into a UIWebView. The performance is very poor. I tried loading the same PDF from th

2条回答
  •  长发绾君心
    2021-01-01 09:03

    The first thing I would look at is the PDF its self. Often people try loading huge PDF files and expect them to perform wonderfully. Can you post the PDF for us to see? How large is the file? Remember that the PDF file size is the compressed size, to display images in the PDF they will be uncompressed when stored in RAM. Its not uncommon for a 500KB image on disk to use 20 MB in memory (This applies for all raster graphics, not just PDFs). This is usually the case when PDF performance is poor from what I've seen around here.

    I know you said it works great in Safari, however we don't know what all Apple does in Safari's internals vs a UIWebView. Also Safari is usually running in the background, so it is using memory even when your app is running. This reduces mem that you app can use, but when you are running safari as the foremost app, 3rd party apps aren't using much memory, so safari could potentially cache more of the PDF at a time.

提交回复
热议问题