Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WebView fallback #15

Open
10 of 12 tasks
PEConn opened this issue Sep 4, 2019 · 24 comments
Open
10 of 12 tasks

WebView fallback #15

PEConn opened this issue Sep 4, 2019 · 24 comments
Labels
enhancement New feature or request
Milestone

Comments

@PEConn
Copy link
Collaborator

PEConn commented Sep 4, 2019

Investigate providing a WebView fallback when the device does not have a TWA provider.

  • Have a look at current usage.
  • Consider APK size increase.
  • Consider WebView Web API support.

Requirements for a WebView fallback:

  • Opens startUrl in full-screen
  • Supports multiple Origins
  • Handles external navigations using CustomTabs
  • New Intents should re-use an existing Activity / WebView
  • Handle orientation changes so that page state isn't lost
  • Handle onPause/onResume
  • Handle onBackPressed
  • Handle onSaveInstanceState
  • Enable domstorage, database, etc.
  • Splash screen support
  • Immersive mode
  • Sets android-app://<package-id> referrer.
@andreban
Copy link
Member

andreban commented Sep 6, 2019

On the normal flow, the browser will validate Digital Asset Links. In this case, everything is happening in the same application. Should the Support Library perform the validation in this case?

@andreban andreban added the enhancement New feature or request label Sep 18, 2019
@bthecorgi
Copy link

This enhancement will be a great improvement for users. The current implementation can fallback to the user's browser. This causes a very jarring and disruptive experience. The content is loaded in the browser. Often times, this has many tabs opened. And switching back to the app (from app switcher) doesn't do anything (just shows homescreen).

@andreban
Copy link
Member

I think an approach we can take here is to add a demo app that contains a WebView fallback. We can start with a naive implementation that will give us more understanding on what we will need to do to have solid implementation in the library and, once we are happy we can move the implementation there.

@PEConn, WDYT?
@b1tr0t, FYI

@andreban andreban added the good first issue Good for newcomers label Oct 18, 2019
@PEConn
Copy link
Collaborator Author

PEConn commented Oct 18, 2019 via email

@andreban
Copy link
Member

#46 kicked off a demo implementation. It's a naive implementation for now and more work is needed for it to be a good fallback implementation.

@naveedahmed1
Copy link

This would really help in improving overall user experience with TWA apps.

@strygo
Copy link

strygo commented Mar 2, 2020

The WebView fallback sample is a good starting point, but there are aspects of it that need further functionality to bring the WebView experience closer to parity with TWAs:

  • Handle orientation changes so that page state isn't lost
  • Handle onPause/onResume
  • Handle onBackPressed
  • Handle onSaveInstanceState
  • Enable domstorage, database, etc.
  • The navigation bar color behavior doesn't seem right. As of now, the sample uses transparent, which is optimal for the splash screen but not what you'd expect when the WebView is shown

@andreban
Copy link
Member

andreban commented Mar 2, 2020

Yes, that's why we haven't added it as a default to the library yet. We haven't been able to come back to this yet. Any contributions to improve the WebView fallback demo will be greatly appreciated, as we intend to merge it into the Support Library.

@strygo
Copy link

strygo commented Mar 2, 2020

OK. I am also experiencing an issue with audio playback that I haven't resolved. These are showing in the debug logs:

W/AudioManager: Use of stream types is deprecated for operations other than volume control
W/AudioManager: See the documentation of requestAudioFocus() for what to use instead with android.media.AudioAttributes to qualify your playback use case

@andreban
Copy link
Member

andreban commented Mar 2, 2020

What does the issue you are experience looks like?

One thing to keep in mind is that the WebView fallback will probably work on a best-effort to support PWA features - The WebView doesn't support all Web Platform APIs and, in many cases, feature detection also doesn't work as expected.

There's an interesting WebView for PWA implementation in this repo too, but I don't think it covers all the items you mentioned: https://github.com/wizeinsights/Android-PWA-Wrapper

@strygo
Copy link

strygo commented Mar 2, 2020

I resolved my audio issue. After more testing, I discovered the device itself wasn't outputting any sound. It seems the Xiaomi Mi Box S is incompatible with certain TVs. I switched my display and audio is working.

Thanks for that link. I'll make other notes as I round out functionality.

@andreban andreban added this to the 1.2.0 milestone Mar 3, 2020
@andreban
Copy link
Member

andreban commented Mar 9, 2020

@strygo Implemented most of the missing things. Not sure about this one though:

The navigation bar color behavior doesn't seem right. As of now, the sample uses transparent, which is optimal for the splash screen but not what you'd expect when the WebView is shown

The demo uses the color set in the AndroidManifes.xml. It is parsed in LauncherActivityMetadata here and used in the fallback here. Not sure I fully understand the issue. PS: the WebViewFallback doesn't have a Splash Screen.

@naveedahmed1
Copy link

@andreban awesome, great job 👍

Can you please guide how do we update our current TWA to incorporate this change?

@strygo
Copy link

strygo commented Mar 9, 2020

Apologies. This may have been my issue - I was coming from a project derived from the earlier TWA sample. In that project, the navigation bar color was set to transparent. This caused issues when using the fallback WebView.

@andreban
Copy link
Member

andreban commented Mar 9, 2020

@naveedahmed1 Right now, the best source of information is the demo itself. We will move the fallback into the support library, which should make things easier. We probably won't enable it by default, but the idea is that it could be enabled with a flag. Probably with a warning that it's still experimental.

@strygo thanks for the confirmation!

@naveedahmed1
Copy link

Thanks for your reply @andreban .

How about integrating this in svgomg-twa? while it is added to the support library?

@andreban
Copy link
Member

andreban commented Mar 9, 2020

It will be integrated into llama-pack

@naveedahmed1
Copy link

That's awesome 👍

@strygo
Copy link

strygo commented Mar 9, 2020

From my perspective, a few more items to consider for the WebView:

  • Splash screen support (ideally rendered the same as when using TWAs)
  • Send activity to background when you can't go back in the WebView (similar to TWAs I believe)
  • An identifier included in the User-Agent header to indicate this mode (for TWAs, we rely on the initial Referer header, but I'm not sure that approach is possible here, if it is, that would be better)
  • setMediaPlaybackRequiresUserGesture to false (I'm not sure TWAs do this, I think so)
  • Support for earlier API levels (this required not setting status bar color on downlevel, and also handling the alternate signature for shouldOverrideUrlLoading)
  • I noticed that we set our WebView to focusable = true and focusableintouchmode = true, not sure if this should be applied generally
  • In cases where no browser exists at all (like Fire TV/Android TV), when a user opens an external link, you should ideally open another activity with a webview. Fortunately, we don't have this issue on our end, but I figured I would raise it for consideration

@andreban
Copy link
Member

andreban commented Mar 9, 2020

I've just added support for earlier APIs on the last PR.

Regarding Fire TV / Android TV, my guess is that developers should probably use store targeting to deploy a different APK that uses the WebView in those platforms. I don't know about Fire TV, but Android TV doesn't come with a browser. And Chrome can't be installed from the store.

I'll check out the best approach for the others.

@rulim34
Copy link

rulim34 commented Apr 29, 2020

How about the WebView splashscreen? It just directly open the url without showing any splashscreen. on the WebView fallback.
And also how to do caching on WebView?

@Andrew67
Copy link

Andrew67 commented Oct 3, 2020

Hi @andreban ,
I've been trying to find some consistent information about the expectations around the android-app:// referrer, as it seems Firefox's TWA support is not populating it at all and I was thinking of bringing it up to them.
I'm seeing some conflicting information regarding the / at the end:

@andreban
Copy link
Member

andreban commented Oct 4, 2020

@Andrew67 thanks for catching this #191 adds a trailing slash to the WebView fallback. The trailing slash helps differentiate android-app://com.example/ from android-app://com.example.subdomain, so user-agents should add it.

@kudlav
Copy link

kudlav commented Mar 10, 2022

similar issue: #309

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

8 participants