Skip to content

Instantly share code, notes, and snippets.

@shazron
Last active October 8, 2015 06:20
Show Gist options
  • Select an option

  • Save shazron/3290760 to your computer and use it in GitHub Desktop.

Select an option

Save shazron/3290760 to your computer and use it in GitHub Desktop.
Unresolved UIWebView WebKit bugs
Fundamentally, this is a WebKit bug that cannot be worked around currently (it does not release memory of images that a not used anymore). I did extensive measurements by loading huge images in a previous project, and it consistently crashes because of this bug.
I believe it has been reported to the WebKit project, with no resolution:
https://bugs.webkit.org/show_bug.cgi?id=31253
https://bugs.webkit.org/show_bug.cgi?id=39628
Usually, setting the image src to null I think would flag the gc to recycle the memory, but I don't think it will work because of this bug.
Others have the same problem, from the Apple Dev Forums (login needed):
https://devforums.apple.com/search.jspa?resultTypes=MESSAGE&q=UIWebView+memory&peopleEnabled=true&start=1&dateRange=all
There are purported "workarounds" in some of the posts (I don't remember which) and I've tried them all – with no success.
An extreme that I suggested to a client is when a low memory warning comes in, take a screenshot, show it – release the whole UIWebView and then reinstantiate it, wait till the page loads (half a second) then remove the screenshot. We're taking steps to have the PhoneGap "view" as a component – so technically you could have two UIWebViews that you swap in, in the future – to mitigate the risk of this problem. Not ideal, but what can you do.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment