Bug 976216 - Part 2: Purge startup caches when starting Gecko in developer builds. r=mfinkle

This change only impacts developer builds.  A developer build is one
where MOZILLA_OFFICIAL is not set.

The startup cache is invalidated when the buildid changes; see [1] for
details.  For MOZILLA_OFFICIAL builds, the buildid is always bumped, so
the startup cache is always fresh on a package re-deploy to device.

Most developers re-deploy using |mach build mobile/android && mach
package && mach install| or similar.  This does not bump the buildid.
The re-deployed package will read the out-dated startup cache, leading
to frustrating inconsistencies when developing Javascript, especially
chrome content and module JSMs.

This change purges the startup caches every time Gecko is started in
developer builds.  This keeps the running Javascript consistent (which
is good for development), but incurs a startup performance
penalty (since the cache must be purged, and since the cached files must
be recompiled, etc).

[1] http://hg.mozilla.org/mozilla-central/file/901d300bb441/toolkit/xre/nsAppRunner.cpp#l2350
This commit is contained in:
Nick Alexander 2014-05-05 11:27:55 -07:00
parent 8fc9d06555
commit d1d48c29e1

View File

@ -323,6 +323,16 @@ public class GeckoAppShell
if (type != null)
combinedArgs += " " + type;
// In un-official builds, we want to load Javascript resources fresh
// with each build. In official builds, the startup cache is purged by
// the buildid mechanism, but most un-official builds don't bump the
// buildid, so we purge here instead.
if (!AppConstants.MOZILLA_OFFICIAL) {
Log.w(LOGTAG, "STARTUP PERFORMANCE WARNING: un-official build: purging the " +
"startup (JavaScript) caches.");
combinedArgs += " -purgecaches";
}
DisplayMetrics metrics = getContext().getResources().getDisplayMetrics();
combinedArgs += " -width " + metrics.widthPixels + " -height " + metrics.heightPixels;