6

Observation: I am running an SPA in Polymer and when I open internal links in new background tabs in chrome, the pages don't finish loading (ajax and all) until I focus on the tab.

Questions: What is chrome waiting for user focus to do -or- What is Polymer waiting for before it finishes rendering the page and sending ajax requests?

Bonus: How can I open a dev tools panel targeting a tab I have opened in the background to observe what is/isn't happening?

Bonus Answer: If you open dev tools on a tab, navigate away from the tab, then refresh the dev tools, the associated tab will also refresh and simulate having been opened in the backgroun.

km6zla
  • 4,787
  • 2
  • 29
  • 51
  • According to [this answer](http://stackoverflow.com/a/22070842/361762) all processing is stopped in background tabs. [A different answer](http://stackoverflow.com/a/12522580/361762) suggests using WebWorkers to keep a thread running in the background. – Dave Aug 25 '15 at 19:30
  • Except that if you go to http://builtwithpolymer.org/ and open any of the sites in new background tabs. They all seem to complete loading before in the background before I focus them. – km6zla Aug 25 '15 at 20:19
  • 1
    Relevant: [Wikipedia - If a tree falls in a forest and no one is around to hear it, does it make a sound?](https://en.wikipedia.org/wiki/If_a_tree_falls_in_a_forest) – zerkms Aug 25 '15 at 20:25
  • 3
    @zerkms I just expect to see it laying down in the dirt when i finally am around, not suspended in the air waiting for me to see it fall. – km6zla Aug 25 '15 at 21:45

1 Answers1

5

In Polymer, core-ajax with the auto attribute set to true uses Polymer job utility (source). Polymer's job utility uses the requestAnimationFrame() function (source). According to here and here, chrome pauses on this function completely when the tab is inactive.

Solution: By removing the auto attribute from my core-ajax elements and manually calling the go() method on the ready event, I was able to get my pages to fully load in the background.

Community
  • 1
  • 1
km6zla
  • 4,787
  • 2
  • 29
  • 51