GwtMaterialDesign / gwt-material

A Google Material Design wrapper for GWT
https://gwtmaterialdesign.github.io/gmd-core-demo/
Apache License 2.0
410 stars 124 forks source link

ServiceWorker observing lifecycle not working as expected #1011

Open ingosch opened 3 years ago

ingosch commented 3 years ago

Sry, forget my initial post, my configuration was somehow messed up. But while testing and digging into serviceworkers I discovered some other issues with the ServiceWorkerManager that I don't understand.

protected void observeLifecycle(ServiceWorkerRegistration registration) {
        registration.onupdatefound = event -> {

            onNewServiceWorkerFound(new ServiceEvent(), registration.waiting);

            if (registration.installing != null) {
                onInstalling(new ServiceEvent());

                onStateChange(registration.installing);
            }

            if (registration.active != null) {
                onStateChange(registration.active);
            }
            return true;
        };
    }
  1. When reloading the page a servicworker that is waiting to be activated is ignored cause onupdatefound is not triggered in this case.
  2. Does calling onNewServiceWorkerFound with registration.waiting make sense? At that point there should usually be either no waiting SW or an older one that is to be replaced with the new one that triggered the onupdatefound event. IMHO the way it is at the moment onupdatefound will always be called together with onInstalling what is unnecessary.

I think using onupdatefound like it was until v2.2 (just calling it once on setup if registration.waiting is true) would make more sense and would solve problem nr. 1.