Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 367216

Summary: [Browser] Xulrunner on Windows leaves cache files in Roaming Profile
Product: [Eclipse Project] Platform Reporter: Martin Oberhuber <mober.at+eclipse>
Component: SWTAssignee: Grant Gayed <grant_gayed>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: eclipse.felipe, etyme1000, ganoro, jacek.pospychala, markward.schubert, norbert.schoepke, parvez12, ramgopalmit
Version: 3.7.1   
Target Milestone: 3.8 M7   
Hardware: PC   
OS: Windows All   
Whiteboard:

Description Martin Oberhuber CLA 2011-12-20 11:32:08 EST
Build id: M20110909-1335 (3.7.1)
CQ:WIND00324159

Projects such as ATF and JSDT want to use Xulrunner on Windows in order to leverage its API for Javascript debugging. But it turns out that Xulrunner stores its Profile and Cache in the roaming profile, eg on Windows 7:

  C:\Users\mober\AppData\Roaming\Mozilla\eclipse\

This is a problem for companies leveraging the roaming profile, since any data in it needs to be synchronized across machines on every logon. The larger a roaming profile is, the slower the logon procedure, plus companies may have quota in place. We have concrete customer concern who sees megabytes of videos in his roaming Xulrunner cache, which is not acceptable !

Using a cache in the roaming profile is outright against Microsoft recommendation.

At Mozilla, the problem has been fixed in 2005:
   https://bugzilla.mozilla.org/show_bug.cgi?id=291033
   https://bugzilla.mozilla.org/show_bug.cgi?id=74085
and in fact Firefox now uses its Profile data under AppData\Roaming but Cache under AppData\Local. Indide Eclipse, though, xulrunner  still uses the hardcoded profile and cache in the Roaming Profile (I checked 1.9.x, using xulrunner from Firefox 3.6 which redirected its profile properly).


Steps to Reproduce:
-------------------
D:\Eclipse\eclipse3.7.1\eclipse\eclipse.exe -vmargs  \
  -Dorg.eclipse.swt.browser.DefaultType=mozilla 
  -Dorg.eclipse.swt.browser.XULRunnerPath=C:\PROGRA~2\MOZILL~1

Then Window > Show View > Internal Web Browser
Open an URL which loads large files.


Workaround: None!
-----------------
Browsing the Internet, I have seen people recommend overriding the Javascript configuration (prefs.js) and set the "browser.cache.disk.parent_directory" variable, but I couldn't get that to work.

Also, using a "profiles.ini" file to redirect the profile to a different location failed for me.

So it looks like the best thing one can do at the moment is writing a logon script which deletes %USERPROFILE%\AppData\Mozilla\eclipse on every logon ... but that also doesn't quite solve the problem.

Please investigate whether Eclipse code could redirect the profile or clean it on shutdown. Also note that sharing one Xulrunner profile between all Eclipse instances is a problem as per http://www.eclipse.org/forums/index.php/m/638175/ -- maybe both problems could be fixed at the same time by specifying a unique cache under %TEMP% and cleaning it on shutdown.
Comment 1 Martin Oberhuber CLA 2012-01-11 16:53:50 EST
FWIW, I happened to debug into the Mozilla class today for a different reason, and it looked like Mozilla#initPreferences() might be a place where Eclipse/SWT could specify a custom location for the cache by setting a 

   browser.cache.disk.parent

preference:

   http://kb.mozillazine.org/Browser.cache.disk.parent_directory

I'm not going to have time to dig into this any deeper, but maybe somebody else can follow up from here... see code at

http://git.eclipse.org/c/platform/eclipse.platform.swt.git/tree/bundles/org.eclipse.swt/Eclipse%20SWT%20Mozilla/common/org/eclipse/swt/browser/Mozilla.java
Comment 2 Ryan Archer CLA 2012-03-08 16:37:07 EST
There's a much older bug about this, marked as an enhancement. See https://bugs.eclipse.org/bugs/show_bug.cgi?id=178918.
Comment 3 Norbert Schöpke CLA 2012-03-21 12:25:16 EDT
If you don't need the cache or the cache size makes it prohibitive to use, one possible workaround is to disable it. The pref is "browser.cache.disk.enable".

The XULRunner distribution contains a file \greprefs\all.js where the cache is enabled by default. Disable it by changing the line to: 
pref("browser.cache.disk.enable", false);
 
The \Mozilla\eclipse folder will still be created in the user's AppData\Roaming directory, but no "Cache" folder will be created when you restart your Eclipse application.

Note that I first tried to set the same preference in the file 
\defaults\pref\xulrunner.js but this did not work. Apparently the above file takes precedence, at least in embedded scenarios like running inside the Eclipse SWT Mozilla control.

Regards
Norbert
Comment 4 Martin Oberhuber CLA 2012-03-22 11:55:14 EDT
(In reply to comment #3)
> The XULRunner distribution contains a file \greprefs\all.js -- set
> pref("browser.cache.disk.enable", false);

the workaround works - so many thanks for that !

SWT team, is there a case for setting this globally in the SWT Java / Javascript / config bits ? Given that the Eclipse config area for Xulrunner may be shared by multiple instances of Eclipse running at the same time it would seem wise to me to disable disk caching by default...
Comment 5 Grant Gayed CLA 2012-03-23 16:56:05 EDT
I've had a quick look, I think that Firefox's approach (profile can roam, cache always local) makes sense.  The Browser control should be able to do this, will revisit next week.
Comment 6 Grant Gayed CLA 2012-03-24 23:52:54 EDT
Fixed on Windows > 20120325, patch: http://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/?id=925a13ca36585501cfd4633effa1686ff264daa0 .

Keeping report open to investigate whether something similar should be done on Linux and Mac.
Comment 7 Grant Gayed CLA 2012-03-26 12:35:34 EDT
On Linux, Firefox stores its cache with the user profile, so no change made here.

Fixed on OS X > 20120326, patch: http://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/?id=baad710d04c31f3112d887cdf1d74d0dac488555 .
Comment 8 Parvez Ahmad Hakim CLA 2013-04-25 11:46:46 EDT
(In reply to comment #7)
> On Linux, Firefox stores its cache with the user profile, so no change made
> here.
> 
> Fixed on OS X > 20120326, patch:
> http://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/

solution is delete files from C:\Users\DE3\AppData\Roaming\Mozilla\eclipse\Cache
I faced problem while clearing mozila cache