Closed Bug 880359 Opened 11 years ago Closed 11 years ago

Default Android cache is 200MB, which is greater then the amount of free space or internal memory

Categories

(Firefox for Android Graveyard :: General, defect)

21 Branch
ARM
Android
defect
Not set
normal

Tracking

(fennec+)

RESOLVED WORKSFORME
Tracking Status
fennec + ---

People

(Reporter: stefan, Assigned: gbrown)

Details

User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:21.0) Gecko/20100101 Firefox/21.0 (Beta/Release)
Build ID: 20130511120803

Steps to reproduce:

I have two Android phones, each with have less then 200MB of internal storage. One runs Android version 2.2.1 the other runs version 2.3.4 .

By default, the size of the Mozilla Cache is way too large. The two phones have about 140MB of internal storage and 200MB of internal storage. There is only about 70MB of free space on on the internal storage, but Firefox sets the cache to be about 200MB. The value of the cache should not be larger then the amount of free space on the internal storage. As a result, Firefox eventually fills up all available space on the filesystem, which causes problems on the phone (For example: The apps on the phone cannot receive security updates because Android says there is not enough space).

Also note that the cache cannot be moved to the sdcard.

Steps to reproduce:

1. Install Firefox on my Android Phone
2. Go to Android Settings: Applications: Manage Applications: Sort by Size. Notice that Firefox 21.0 is using 53MB of storage. I have not browsed to any site yet. The sum is:

Total: 53:33MB
Application: 26.41MB
Data:14.93MB

2. Open Firefox. Go to about:cache , which says the following. Note the unusual value for "Maximum storage size:" The value is 204800KiB (200MB), but the internal storage on the phone is less then 200MB. The amount of free space is much less then 200MB.

Information about the Cache Service

Disk cache device

Number of entries: 0
Maximum storage size: 204800 KiB
Storage in Use: 0 KiB
Cache Directory: /data/data/org.mozilla.firefox/files/mozilla/$blah.default/Cache

3. Go to "about:config" and search for "cache". The following values were set automatically:

browser.cache.disk.capacity 204800

4. Browse to some heavy sites to populate the cache like m.pinterest.com. On Pinterest scroll down to bottom and click "See more pins". This will load up the cache. 

5. Keep browsing. Eventually Android will complain that it is "Low on space". Go to 'about:cache' and the value for "Storage in use" can get quite large (30-40MB before this particular phone fills up).



Actual results:

Firefox thinks it can cache 200MB on this phone. However, the internal storage on this phone is about 190MB. With all the default applications included with the phone there is only about 70MB of free space available. Why does Firefox think it can store 200MB worth of cache?


Expected results:

The cache for Firefox should not exceed the actual free space on the phone.
OS: Mac OS X → Android
Hardware: x86 → ARM
Summary: Default Android cache is 200MB, but phone has less then → Default Android cache is 200MB, which is greater then the amount of free space or internal memory
tracking-fennec: --- → ?
With default prefs, Firefox for Android uses the disk cache "smart sizing" feature, with slight modifications for Android. The max size of the disk cache should be set dynamically, based on the amount of space available on the device.

If less than 500 MB is available, the max size of the disk cache should be set to 20% of the available space, or 10 MB if less than 50 MB is available. With 140 MB available, I would expect the disk cache size to max out around 28 MB (probably a little larger in practice, due to overhead). With 70 MB available, I would expect up to 14 MB used for the disk cache.

There are some other prefs in about:config that may help us understand this issue better; can you tell me your settings for:

 browser.cache.disk.smart_size.first_run
 browser.cache.disk.smart_size.use_old_max
 browser.cache.disk.smart_size_cached_value

?
Flags: needinfo?(stefan)
Here are the settings.

browser.cache.disk.smart_size.first_run = false
browser.cache.disk.smart_size.use_old_max = false
browser.cache.disk.smart_size_cached_value = 10240
Flags: needinfo?(stefan)
That looks right. browser.cache.disk.smart_size_cached_value = 10240 shows that smart sizing detected less than 50 MB of free space and assigned a 10 MB max size for the cache. However, in this case, I would expect about:cache to show something like "Maximum storage size: 10240 KiB". 

Is it possible that you have browser.cache.disk.smart_size.enabled = false?

(If smart sizing has been disabled, Firefox will use the configured maximum, from browser.cache.disk.capacity.)
Flags: needinfo?(stefan)
browser.cache.disk.smart_size.enable is set to true.

And now, about:cache shows that the "Maximum storage size" is 10240 KiB, which is what you said.

Strangely I didn't touch anything, although the Firefox browser has been restarted a couple of times and the phone has possibly been rebooted.

These other values still haven't changed. Their current values are:

browser.cache.disk.smart_size.firs_run is false.
browser.cache.disk.smart_size.use_old_max is false
browser.cache.disl.smart_size_cached_value is 10240
Flags: needinfo?(stefan)
Assignee: nobody → gbrown
tracking-fennec: ? → +
I have not been able to reproduce this problem. In my experience, smart sizing is used and assigns a reasonable maximum size to the disk cache (according to the rules explained in Comment 1), and that maximum size is displayed as "Maximum storage size" in about:cache.

(I used a Galaxy S running Android 2.2.1. I wrote files to /data to restrict the free storage, then installed Firefox, checked about:cache, browsed, checked about:cache again.)

Without a reliable description of steps to reproduce the problem, I don't know that we can do anything here. Stefan -- any other ideas?
I wrote a blog post to help better describe the way the disk cache should work on Firefox for Android: http://gbrownmozilla.wordpress.com/2013/06/19/firefox-for-androids-disk-cache/
Please re-open if steps to reproduce can be determined, or if it happens again.
Status: UNCONFIRMED → RESOLVED
Closed: 11 years ago
Resolution: --- → WORKSFORME
Product: Firefox for Android → Firefox for Android Graveyard
You need to log in before you can comment on or make changes to this bug.