1

I have a chrome packaged app i have made using Polymer paper-elements. it uses HTML5 audio tag to stream music from a online service. My issue is when the app grabs results from server and parses the array while playing. Sometimes the music will stop for a few milliseconds. (a few seconds on lowend chromebooks) I have tried to use Polymers async method to delay the work til next available microtask. This helps but causes some undesirable things to happen in interface. (content that shouldn't be displayed is shown until the async method is executed)

currently i have nothing happening in the background.js file. Everything is happening in the main.js file or within a custom element.

would i see any performance gain from using message passing to push some of the work when parsing the response to the background.js file?

example of the work that appears to cause the pause in audio.

        var i = 0;
        Array.prototype.forEach.call(response.albumList2.album, function (e) {
          // buildObject returns the needed data from the object that is returned from the loop as well as other needed data
          var obj = this.buildObject(e);
          // this.wall is the array that i pass to core-list to display
          this.wall.push(obj);
          // this is to keep callback from executing before the array is built
          i = i + 1;
          if (i === response.albumList2.album.length) {
            this.async(callback);
          }
        }.bind(this));

in this situation the callback just hides the loading spinner.

thanks in advance for any help.

jimi dough10
  • 2,016
  • 2
  • 13
  • 20
  • 1
    My understanding is that everything runs in the same UI thread, including the background page and async micro-tasks. To improve performance, you would need to use mutliple threads. I would look into Web Workers, but you might have to work around the same problems as with extensions : http://stackoverflow.com/questions/22717586/create-a-web-worker-from-a-chrome-extension-content-script . – Kevin Coulombe May 15 '15 at 14:46
  • This is my understanding as well. background and foreground page javascript all run in the same thread. You will need to use a web worker. – kzahel Mar 25 '16 at 18:20

0 Answers0