So from what I tested on Android Chrome, the load event seems to only fire when the page is first loaded into a new tab. Once the tab has been loaded, the load event doesn’t fire until I close the tab and create a new one. Not sure if that is the intended behavior that the Chrome team wanted, perhaps we should check with them on this.
A simple rule of thumb would be to delay registration until after the load event fires on window , like so
We can definitely do without it but that does mean we have to be sure that whatever is happening in the initializer does not affect the page load time significantly.
It’s strange because it’s not consistent. Sometimes I’m able to get the service worker in a new tab and refresh both (more consistently on meta), but on other sites I cannot seem to get the service worker to re-install even when opening a new tab.
My best guess is that ember’s initialization method may fire after the window’s load event, so it never gets called in some cases.
Other oddities, the service worker registrations only work in production environments with compiled assets - I’ve added a registration case for development as well.
I’ve prepared a PR with the suggested fixes, let me know if it looks OK: