title: Firefox UI becomes unresponsive while downloading many files with Addon SDK API
body: <p>I have a problem that is rather hard to debug, i need to download a lot (~400) of rather small (~3-4mb) files in the background using the firefox addon sdk API.</p>
  
  <p>I tried using the old API (<a href="https://developer.mozilla.org/en-US/Add-ons/Code_snippets/Downloading_Files" rel="nofollow">nsIWebBrowserPersist</a>) as well as the new API (<a href="https://developer.mozilla.org/en-US/docs/Mozilla/JavaScript_code_modules/Downloads.jsm" rel="nofollow">Downloads.jsm</a>) (shortened code):</p>
  
  <pre><code>Task.spawn(function () {                
    for (var i = 0; i &lt; documents.length; i++) {
      var url = ...;
      var file = ...;
  
      let download = yield Downloads.createDownload({
        source: url,
        target: file,
      });
  
      yield download.start();
      yield download.finalize();
    }
  });
  </code></pre>
  
  <p>But the UI gets extremely unresponsive after some time, i tried using the same file and overwriting it, because my first guess was windows file handles accumulating over the time, but it didn't help. It does not seem to be related to the system performance, also it works sometimes and on the same machine after 5 min it fails.</p>
  
  <p>Is there a known issue with downloading a lot of files using the firefox sdk api, or am i doing something wrong?</p>