1. James Sumners
  2. CacheViewer Continued
  3. Issues


Issue #13 open

CacheViewer Continued crashes Firefox 9

Anonymous created an issue

Previously I was running FF3 and had the original CacheViewer. I updated to FF9 a few days ago and was happy to see a version of this excellent add-on available. However, more often than not when I try to open the CacheViewer window, I will get a message about an unresponsive script, but unlike normal when this happens, all windows will be frozen and I'm not able to click to stop or continue the script; my only option is to force quit Firefox and restart it. However, once Firefox has restarted, I am able to use the CacheViewer window. So it seems to only have issues if I've had Firefox running for awhile. I'm running CacheViewer Continued 0.5 in Firefox 9.0.1 on Mac OSX 10.6.8.

Since I've only been running FF9 for a few days, I don't have much more information to go on than the little posted above. If I notice more conclusive patterns with the failure in the future, I will post them here.

Comments (5)

  1. James Sumners repo owner

    Same things happens for me on 10.7.2. This looks to be caused by the fact that CacheViewer reads every single entry in the memory and disks caches when the CacheViewer window is opened. As best I can tell, this is done so that the whole cache can be searched easily (since everything is loaded into CacheViewer's own data store).

    I am working through how CacheViewer (and Firefox through "about:cache") accesses the cache to learn how the XUL APIs work in this area. I doubt I can re-write it such that all entries don't have to be examined on load, about:cache does this as well, but I believe it should be possible to do so way more efficiently (and clean up a bunch of code at the same time).

  2. Anonymous

    To add a bit of new information: Right after I made the post above, I switched the CacheViewer preferences to open in a new tab instead of a new window and have had no problems with it freezing Firefox since.

  3. James Sumners repo owner

    That's good to know. Although I'm not sure how that makes it better. The problem lies with Firefox's cache API[1]. Basically, it sucks. You can either query the whole damn thing or not at all. The method used for getting the cache entries is the visitEntries() method. This method is documented thusly:

    "This method visits entries stored in the cache. Used to implement the about:cache URI."

    Notice that this is the same method, according to the documentation, that is used when you visit the "about:cache" URL. If you visit that URL, you should notice the exact same performance problems as you do with CacheViewer Continued. So in order for the add-on to be improved, and I really would like to improve it, there needs to be a way to query the cache in a more efficient manner (e.g. in chunks).

    For reference, here is the simplest code necessary to get the cache items:

    var Cc = Components.classes;
    var Ci = Components.interfaces;
    var Cr = Components.results;
    var cache = {};
    var cacheVisitor = {
      visitDevice: function(deviceID, deviceInfo) {
        if (deviceID === "offline") {
          // We don't care about the offline cache device.
          // So we return true to continue listing devices.
          return true;
        cache[deviceID] = {};
        cache[deviceID].description = deviceInfo.description;
        cache[deviceID].entryCount = deviceInfo.entryCount;
        cache[deviceID].maximumSize = deviceInfo.maximumSize;
        cache[deviceID].totalSize = deviceInfo.totalSize;
        cache[deviceID].entries = [];
        return true;
      visitEntry: function(deviceID, entryInfo) {
        //return false;
        if (entryInfo.key.indexOf("http") === 0) {
          // Push HTTP/HTTPS entries onto our cache object
        return true;
    var cacheService = Cc["@mozilla.org/network/cache-service;1"].getService(Ci.nsICacheService);

    Uncomment the last line at your own peril. Also, this is basically how CacheViewer Continued works right now. The original author did it with a little more complexity, but this is all the add-on is really doing to get the cache entries.

    [1] -- https://developer.mozilla.org/en/NsICacheService

  4. Log in to comment