bubblewrap icon indicating copy to clipboard operation
bubblewrap copied to clipboard

Offline or Network Error causes Address Bar to show

Open markwylde opened this issue 3 years ago • 5 comments

Describe the bug When you have nothing cached, and have installed a fresh apk, if you are offline or your network errors, you will see your app with the address bar visible. I believe this is called Chrome Custom Tabs mode.

To Reproduce Steps to reproduce the behavior:

  1. Clear your browser cache and uninstall your example apk
  2. Install the apk
  3. Disconnect from the internet or cause a network error in some way
  4. Open the installed app
  5. Notice the address bar
  6. Close the app
  7. Connect to the internet or fix the network error
  8. Open the app again
  9. No address bar

Expected behavior I would expect the address bar to not be there in any case. Or at a minimum that the address bar would disappear as soon as the assetlinks file was confirmed.

I guess, in a way I kinda get why if you don't have internet on the first launch, why the address bar may show.

But why can't it (as soon as it fetches the .well-known/assetlinks.json file) remove the address bar. Or even better, don't show the address bar, until the assetlinks file has not validated and a site has loaded in the web view.

Screenshots

https://user-images.githubusercontent.com/5929807/116548626-d9f5eb80-a937-11eb-895f-c16fa17f91d7.mp4

Note: in the video above, I was connected to a fast and working wifi connection, despite the weird network error. But I get that that isn't really a bug for this project.

Smartphone (please complete the following information):

  • Device: Google Pixel 5g
  • OS: Android
  • Browser: stock browser
  • Version: whatever pwabuilder uses

Additional context

The also happens completly randomly sometimes when I open the app. So let's say I install the app, and it's all working fine. 9/10 when I open the app the address bar is gone. But then, for some unknown reason, I'll open it randomly, and the address bar will reappear.

Possible related: https://github.com/GoogleChromeLabs/bubblewrap/issues/50

markwylde avatar Apr 29 '21 12:04 markwylde

Is there a way I can detect, in code, if the app has launched in Custom Tabs mode. So I can just kill the app as a temporary fix?

markwylde avatar Apr 29 '21 12:04 markwylde

#50 depends on a change in Chrome - crbug.com/816798. Please, do star the issue.

The problem is that the browser is unable to validate Digital Asset Links while the user is offline.

  • One workaround is checking for connectivity before launching the application (see https://github.com/GoogleChrome/android-browser-helper/tree/main/demos/twa-offline-first). However, this wouldn't solve clearing storage / re-opening while offline.One workaround is checking for connectivity before launching the application (see https://github.com/GoogleChrome/android-browser-helper/tree/main/demos/twa-offline-first). However, this wouldn't solve clearing storage / re-opening while offline.

  • Another possible solution is validating Digital Asset Links before trying to launch the Trusted Web Activity, like this Custom Tabs sample does. However, that introduces a delay into the launch which may not be desirable.

  • Finally, failing to Digital Asset Links will be considered a crash in the future. It will be possible for applications to intercept that and handle in the Android app with a custom Quality Enforcer.

From the Bubblewrap perspective, we're aiming at supporting both Android and Chrome OS and, unfortunately, none of those would work for the latter.

andreban avatar Apr 29 '21 13:04 andreban

Thanks @andreban for taking the time to respond to me. I appreciate it a lot.

I didn't know about the android-browser-helper, and this seems like it would solve my active problem as perfectly as possible.

The twa-offline-first one seems the easiest. The custom tabs sample seems a bit more complicated, but I might try it too. The speed to open doesn't bother me, just the complexity.

I've starred and responded to that crbug.com, as I do think being able to bundle an app could really open up the possibilities of trusted web apps.

I managed to get the demo working on Android Studio, but only by manually editing the manifest and overriding with my own config.

Is there a way to use bubblewrap with those android-browser-helper demos? Like can I run:

bubblewrap --manifest=https://example.com/manifest.json --something=twa-offline-first

If not, would it be easy to implement, within the scope of this project and could I learn/do it easy enough?

markwylde avatar Apr 29 '21 22:04 markwylde

@markwylde it is possible to add something like this to Bubblewrap. However, we are prioritising solutions that will work across all platforms where Trusted Web Activities are supported (Android and Chrome OS) and, unfortunately, this solution doesn't work in Chrome OS.

CC @ibrahimkarahan

andreban avatar May 06 '21 08:05 andreban

Thanks @andreban for taking the time to respond to me. I appreciate it a lot.

I didn't know about the android-browser-helper, and this seems like it would solve my active problem as perfectly as possible.

The twa-offline-first one seems the easiest. The custom tabs sample seems a bit more complicated, but I might try it too. The speed to open doesn't bother me, just the complexity.

I've starred and responded to that crbug.com, as I do think being able to bundle an app could really open up the possibilities of trusted web apps.

I managed to get the demo working on Android Studio, but only by manually editing the manifest and overriding with my own config.

Is there a way to use bubblewrap with those android-browser-helper demos? Like can I run:

bubblewrap --manifest=https://example.com/manifest.json --something=twa-offline-first

If not, would it be easy to implement, within the scope of this project and could I learn/do it easy enough?

I would also like the same feature to be added to bubblewrap, because until this is available there is a very high chance that users will open the app first time while being offline,see a blank page and give 1/2-star rating on play store. Please add this to bubblewrap as of now because although I want to publish a PWA to play store, until this feature is available I won't take the risk. When a cross-platform solution(with chrome os) is available may be this feature can be deprecated, but as of now please enable offline-first support in bubblewrap through this method.

bil-ash avatar Nov 03 '21 01:11 bil-ash