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

ClassCastException when registering ServiceWorker in Safari on MacOS X #1015

Open ingosch opened 2 years ago

ingosch commented 2 years ago

registration = (ServiceWorkerRegistration) object; in setupRegistration method of ServiceWorkerManager throws a ClassCastException when using Safari on MacOS X. I think this might be an internal problem with Safari and GWT.

Made a workaround using a native method casting the object.

public native ServiceWorkerRegistration castRegistration(JavaScriptObject o) /*-{
    return o;
}-*/;

protected void setupRegistration() {
    if (isServiceWorkerSupported()) {
        Navigator.serviceWorker.register(getResource()).then(object -> {
            logger.info("Service worker has been successfully registered");
            registration = castRegistration((JavaScriptObject) object);

This works on all systems and browsers I've tested so far.