Start in Desktop Browser starts program twice - windows with chrome

If I deploy the app and start it from local storage or even phonegap it, it runs just fine. However, when I start in desktop browser, it opens a tab (or an instance if chrome isn’t open) and starts the program, it even fires the main routine, then after a second or two, it acts like I pressed refresh and begins again, and fires the main again. Other than that, it is fine. It’s a bit annoying.

I should note this is Windows 10 and Chrome the latest Version 78.0.3904.108 (Official Build) (64-bit) and latest AppStudio 7.4.2.0.

And I just noticed that if you close AppStudio, open it, on the first usage of Run on Desktop Browser the program starts only once. If you run it again, it runs twice. If you close AppStudio, and reopen it, it runs only once, the first time. Totally consistent.

It’s how a PWA works at present. It starts the cached version of the app, then checks with the server if there is an update. If there is, it gets the new code and restarts the app.

This ends up being more of an issue during testing than production.

I’m also now getting that same response with the web app on AWS servers. When I make a change, it starts it from cache, then reloads from the server the new files and starts again. How can I stop this, as this is production environment equivalent.

Is there an easy way to check to see if the reload is happening? Wouldn’t it be nice to tell the user the software is now updating, that’s why the screen is jumping around.

There appears to be a way, but it doesn’t look easy. See:

Maybe AS can find an easier solution. George?

John

PWA’s are still pretty new, both to the web and AppStudio. Both Safari and Chrome are making changes to PWA support with every new version. We haven’t seen a perfect solution to this issue - but let’s all keep watching.

Maybe this is not so difficult. Can a service worker, after it has started, set some sort of public variable indicating to the main of the project, that the reload has been completed and it is aok to now load the first real page. Also, the initial startup from cache would hold waiting for this flag until the refresh killed it. Then on the reload, the main would again wait, but will, once the reload completes, get the signal to start.

This assumes firstFrom is pointing to a splash screen that you don’t care if it’s the old version or the new, we’re more concerned about a flaky looking UI.

Taking this further, can the service worker set a flag that it is refreshing the components? Maybe we could slip in an additional “splash screen” stating “downloading new awesome”.

EDIT
See this post for additional information. Modifying PWA.js code