question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

workbox-broadcast-update does not work inside android webview

See original GitHub issue

Library Affected: workbox-broadcast-update (v6.3.0)

Browser & Platform: Webview for Android

Issue Description: I have a PWA application that is also inside an android webview in my app, and the broadcast update plugin does not send the update event with the StaleWhileRevalidate strategy. The exactly same build of PWA app with react performs diferently inside the webview and directly on chrome (on Chrome it works just fine).

    navigator?.serviceWorker?.addEventListener('message', async event => {
      if (event.data.meta === 'workbox-broadcast-update') {

        /* eslint-disable */
        if (confirm(`New app update is available!. Click OK to refresh`)) {
          window.location.reload();
        }
      }
    });

I added just a confirm call to test and on chrome it is been called but inside the webview it is not called. The confirm is just an extra test, The usual was to update the views with the new data, that works on chrome browser too, but also not in webview

The code to register the route is this one:

registerRoute(
  ({ url }) => url.pathname.startsWith('/my-url/v1/something'),
  new StaleWhileRevalidate({
    plugins: [new BroadcastUpdatePlugin()]
  })

I don’t know if there is an issue at all, or the webview part is bad configured perhaps? But the service-worker and offline caching working just fine, only the broadcast update is not performing well.

On android side is just a webview

    <WebView
        android:id="@+id/webview"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        />
        webview.settings.javaScriptEnabled = true
        webview.settings.domStorageEnabled = true
        webview.settings.setGeolocationEnabled(true)
        webview.settings.mediaPlaybackRequiresUserGesture = false
        webview.loadUrl(url)

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
andrebancommented, Nov 9, 2021

🇧🇷 Oi Heitor!

I can see the message when using the example PWA you shared using WebView implementation in this gist: https://gist.github.com/andreban/40b22d321e4fc2de3f05f7753b8cd927.

Screenshot_20211109-110133

The sample is a bit more involved than the one you shared, as it implements onRenderProcessGone(), which enables the app to recover to a potential WebView crash and also ensures that external links are handled in the user’s browser.

However, I think that what may be making the difference here is the call to webSettings.setDatabaseEnabled(true);. Can you try this one out in your Android sample?

1reaction
jeffposnickcommented, Oct 29, 2021

CC: @andreban, my colleague whom I normally turn to for questions related to Android & the web. He might have some idea as to what’s going on.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Ionic Forum - Latest topics - RSSing.com
I am experiencing problems with the zone on my Angular-Capacitor app. When my app do a server request with httpClient/rxjs like:
Read more >
Livereload problem: ReferenceError: process is not defined
Hi, I am trying to launch my Ionic 4 app in device livereload mode: ionic cordova run android --l --c When the is...
Read more >
Open Source Used In slido-test 22.06 - Cisco
This document contains licenses and notices for open source software used in this product.
Read more >
Android Indeterminate Progressbar Is Not Animating - ADocLib
My Android prototype had a circular one but I'm not sure how to achieve the same thing in Change the doDegrees and duration...
Read more >
httparchive_js_2021_09_28.txt - Index of /
matchHeight.min.js launcher.js jquery-3.2.1.slim.min.js torimochi.js skip-link-focus-fix.js instagram-feed.js tilda-forms-1.0.min.js ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found