WebView Maximum Cache Size on Android 4.4

3,391 views
Skip to first unread message

lyo...@gmail.com

unread,
Nov 11, 2013, 2:35:04 AM11/11/13
to chromi...@chromium.org
Hi

On Android 4.4, Webview is based on Chromium. After checking the code, it seems the maxmium cache size is hard-coded to 10MB in\src\android_webview\browser\net\aw_url_request_context_getter.cc.

Since I'm new to the Chromium source code, is this the correct place where the maximum cache size is defined, or may in other place ?

I'm asking here because it seems the value is hard-coded to 20M on previous Android WebView version (4.0 later) in \Source\WebKit\android\WebCoreSupport\WebCache.cpp

Does anyone know why it is reduced to 10M in Android 4.4?

Thank you

BRs

Torne (Richard Coles)

unread,
Nov 11, 2013, 6:40:26 AM11/11/13
to lyo...@gmail.com, bo...@chromium.org, Chromium-dev
Bo, do you remember why we started with a 10M cache here? It's been that way since we implemented the request context getter..


--
--
Chromium Developers mailing list: chromi...@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-dev

To unsubscribe from this group and stop receiving emails from it, send an email to chromium-dev...@chromium.org.

Bo Liu

unread,
Nov 11, 2013, 11:33:23 AM11/11/13
to Torne (Richard Coles), lyo...@gmail.com, Chromium-dev
It was passed around verbally that the original webview used 10M, so I added it without fact checking first and no one ever checked that code again.

aw_url_request_context_getter.cc is the right place to change this for the chromium webview.

Jonathan Dixon

unread,
Nov 11, 2013, 2:53:41 PM11/11/13
to Bo Liu, Torne (Richard Coles), lyo...@gmail.com, Chromium-dev
10MB was the max size when it was using an in memory cache. When using on disk (normal case) it could grow up to 20MB
This was the case from Honeycomb onward (when webview classic moved to use the chromium net stack). Prior to that the cache was limited to 6MB (see CACHE_THRESHOLD in CacheManager.java)

lyo...@gmail.com

unread,
Nov 20, 2013, 8:55:47 PM11/20/13
to chromi...@chromium.org, Bo Liu, Torne (Richard Coles), lyo...@gmail.com, jo...@chromium.org
Thank you all.
One more question: Why not expose the size to app layer ?

Bo Liu

unread,
Nov 20, 2013, 11:01:13 PM11/20/13
to lyo...@gmail.com, chromium-dev, Torne (Richard Coles), Jonathan Dixon
On Wed, Nov 20, 2013 at 5:55 PM, <lyo...@gmail.com> wrote:
Thank you all.
One more question: Why not expose the size to app layer ?

I think exposing this knob to the app is not the right answer here. It's indicating the restrictions of the current implementation sucks, and we can do something better than hardcoding a static limit.

I believe Chrome browser already grows/shrinks the cache size depending on usage and available space. Maybe that's good enough for webview or maybe it requires some tweaking. Could you can file a crbug assigned to me and state your specifc use case for webview and we can make sure whatever we end up doing satisfies your needs.
Reply all
Reply to author
Forward
0 new messages