Mobile WebViewer embedded into iOS and Android application performance problems

1,041 views
Skip to first unread message

Daniel Soriano Gil

unread,
Dec 3, 2013, 9:26:08 AM12/3/13
to pdfnet-w...@googlegroups.com
We're having important performance problems with a Mobile WebViewer embedded into iOS and Android app, simply 'crash' after few minutes going from one page to other. Profiling shows high memory usage, that is a typical issue in apps with embedded WebViews, but, is there any option to reduce memory usage, or to remove objects that Pdftron WebViewer created into DOM and JS context from other pages? or any other solution? 
Thanks

Matt Parizeau

unread,
Apr 30, 2015, 5:11:00 PM4/30/15
to pdfnet-w...@googlegroups.com
One way to reduce memory usage would be to lower the amount of caching done. In MobileReaderControl.js you can find a call to exports.CoreControls.SetCachingLevel(2). By default the mobile viewer has the caching level set to 2, but you could lower it to 1 or 0 to reduce the amount of caching and therefore memory usage. Note that if you set the caching level to 0 this means file data isn't cached in memory potentially causing many more HTTP requests. Take note of the trade off between memory usage and the delay caused from re-requesting information.

Matt Parizeau
Software Developer
PDFTron Systems Inc.

Matt Parizeau

unread,
Apr 29, 2015, 6:24:20 PM4/29/15
to pdfnet-w...@googlegroups.com
Here are some more ways to help reduce the crashing issue: 

1) Call window.utils.setCanvasMultiplier(1) WebViewer uses the browser's devicePixelRatio to display higher quality content for browsers that can support it.  The iPad 3 and up all have retina displays which means the devicePixelRatio is equal to 2 and so we increase the size of the canvases to show sharper images for those devices.  However this also means that we use more memory when creating the pages (2x increase in both dimensions means 4x more memory!). The multiplier of the canvas will use the devicePixelRatio by default but it can be overridden if you call setCanvasMultiplier. In this case WebViewer won't display pages in retina quality but the memory usage will be much lower.  You could compare your documents with 1 and 2 and see if the quality loss is acceptable.  You can call this near the top of MobileReaderControl.js.

2) Remove -webkit-backface-visibility css.  In MobileReaderControl.html you'll find the .hacc style which has -webkit-backface-visibility: hidden; and -webkit-perspective: 1000px;  These have been used to improve the graphical performance on iOS 5/6 but apparently there may be some issues using them with iOS7.  You could comment out this style and see if there is an improvement.

3) Minimize use of css transforms.  CSS transforms also seem to cause Mobile Safari problems though the graphical performance is better.  In MobileReaderControl.js near the top of the file you'll find the variable useTransformFallback.  This will fall back to using css top and left properties instead of css translate.  After the browser checks at the top you could set me.useTransformFallback = true; to test out the effect it has.

Some relevant links about the issue with iOS in particular:

Matt Parizeau
Software Developer
PDFTron Systems Inc.

On Tuesday, December 3, 2013 9:30:44 AM UTC-8, Matt Parizeau wrote:
One way to reduce memory usage would be to lower the amount of caching done.  In MobileReaderControl.js you can find a call to exports.CoreControls.SetCachingLevel(2).  By default the mobile viewer has the caching level set to 2, but you could lower it to 1 or 0 to reduce the amount of caching and therefore memory usage.

Michael Lee

unread,
Sep 13, 2016, 4:58:10 PM9/13/16
to PDFTron WebViewer
Hi,

We also experience crash with iOS 9.3.4 on the latest iPhone Ultra Model MGA92X/A.

It happens when we test a user in 'panic/baby' mode, simulating multiple fast crazy gestures, notably when zooming out.

I implemented what I could from the above (.hacc style reference not exist anymore), to no-avail.

Mike

Matt Parizeau

unread,
Sep 14, 2016, 5:27:30 PM9/14/16
to PDFTron WebViewer
Hi Mike,

Apple has acknowledged that there is a bug in Mobile Safari related to certain transformations that can cause memory problems.

Unfortunately we've heard from them that there is "no known workaround" for the problem and the suggestions above are ways to reduce the frequency of it occurring.

Matt Parizeau
Software Developer
PDFTron Systems Inc.

Reply all
Reply to author
Forward
0 new messages