Alex Rivera | Logout

Ways to improve UIWebView scrolling performance?

Asked 2012-04-15T16:35:38.503
15

I am building an application that includes a UIWebView containing a large number of images, CSS, embedded video, and JavaScript tap handlers. Scrolling performance is stuttery and I am looking for insight into the most effective ways to improve this.

Which if any of the following characteristics lead to laggy UIWebView scrolling? What other factors may be hindering performance?

  • Quantity of images
    • Should I be removing images from the DOM as the user scrolls past them, and adding them back if they scroll back up?
  • Size of images
    • Will Retina-quality images in a web view affect scrolling performance a lot more than smaller versions would?
  • Image scaling
    • Would resizing the images ahead of time make a big difference, rather than relying on the web view to scale based on declarations like width: 100%;?
  • CSS
    • I have avoided box-shadow, but are there other CSS properties that are also known for adversely affecting scrolling performance?

If there are any other resources or tools that can be used for profiling, I've love to hear about them.

Edit
Report

1 Answer

8

This is the answer I got from Apple Developer Technical Support a while ago:

At this time, we do not provide any mechanisms to optimize the rendering of UIWebView. The reason you see a difference is due to Mobile Safari and UIWebView not using the same rendering engine.

The performance is dependent on the content loaded. If there are javascripts running or plugins being used, this can hinder the performance.

I recommend that you file a bug report at http://developer.apple.com/bugreporter/ detailing your situation. This will also keep you informed on the status of your bug report.

A possible alternative to UIWebView would be the open-source DTCoreText library: https://github.com/Cocoanetics/DTCoreText, which powers the Float Reader app: http://itunes.apple.com/us/app/float-reader/id447992005?mt=8

answered 2012-04-24T13:49:45.973

Your Answer