datalist-polyfill icon indicating copy to clipboard operation
datalist-polyfill copied to clipboard

Does not work on Android WebView

Open vpodk opened this issue 5 years ago • 6 comments

Console About WevView
screen shot 2018-07-30 at 12 03 34 am screen shot 2018-07-30 at 12 04 03 am

Feature detection from datalist-polyfill.js file:

19 // Feature detection - let's break here, if it's even already supported
20 if (
21	'list' in dcmnt.createElement('input') &&
22	Boolean(dcmnt.createElement('datalist') && window.HTMLDataListElement)
23 ) {
24	return false;
25 }

Also tested on WebView-based app on real devices:

  • Google Pixel 2
  • Google Pixel
  • Google Pixel XL
  • Moto G4 Play
  • Moto G3

vpodk avatar Jul 30 '18 07:07 vpodk

@vpodk, thanks a lot for your feedback. Does including the JavaScript file itself lead to any JavaScript errors? And do you mean by that it doesn‘t work that the behaviour of the polyfill wouldn‘t get executed? Because in general I would expect that the feature detection works correctly as the datalist functionality should be provided natively on Chrome for Android according to caniuse. I‘m not that familiar with Android so that I wouldn‘t know about the differences to their WebView by myself.

mfranzke avatar Jul 30 '18 08:07 mfranzke

@mfranzke, the script itself does not throw any errors. Its feature detection considers that this feature is supported by Android WebView, but it's not.

The caniuse shows just a random numbers for Android column: May be these are versions of Android operation system, or versions of WebView component, or something completely different.

I came to this script from datalist's Polyfill section on official mozilla.org site where this feature is also marked as supported by WebView in Browser compatibility table:

Need to ask @mdn to update datalist.json file.

There are list of user agents of tested devices where 100% native datalist and this polyfill does not work:

  • Mozilla/5.0 (Linux; Android 6.0.1; MotoG3 Build/PMIS24.107-55-2-17; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/67.0.3396.87 Safari/537.36
  • Mozilla/5.0 (Linux; Android 7.1.1; Moto G Play Build/NPI26.48-43; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/67.0.3396.87 Safari/537.36
  • Mozilla/5.0 (Linux; Android 8.1.0; Pixel Build/OPM4.171019.021.D1; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/67.0.3396.87 Safari/537.36
  • Mozilla/5.0 (Linux; Android 9; Pixel 2 Build/PPP5.180610.010; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/67.0.3396.87 Safari/537.36

For simple test just run WebView from Android Studio and open your demo page:

Example About WebView
screen shot 2018-07-30 at 12 56 09 pm screen shot 2018-07-30 at 1 04 14 pm

To detect Android WebView you can use User Agent Strings described on developer.chrome.com website. In my case, I added navigator.userAgent.indexOf('; wv) ') to the feature detection.

Hope this helps.

vpodk avatar Jul 30 '18 20:07 vpodk

Hmm, this is interesting 🤔 Ideally, we shouldn't need to check the UA, we should either detect the feature and do nothing, or not detect the feature and polyfill. It's strange that it's not behaving properly.


The caniuse shows just a random numbers for Android column

For what it's worth:

  • For all Android versions up to 4.4.4 (KitKat), the Android webview version was tied to the OS. Updates for the OS would update the webview
  • For Android versions 5.0+, the Android webview version is now decoupled from the OS version, allowing more frequent updates. So, whenever there's a Chrome desktop release, there's an associated Chrome for Android release as well (so, the "67" shown on caniuse is referring to the Chrome version)

reference

Although WebView has been based on Chromium since Android 4.4, the Chromium layer is now updatable from Google Play.

mitchhentges avatar Jul 30 '18 20:07 mitchhentges

Totally agreed on this, @mitchhentges. What I‘m mostly wondering about is that these UA strings actually report quite new versions of Chrome like e.g. „Chrome 67 on Android (Marshmallow)“, in which I would expect to have the datalist functionality work natively.

mfranzke avatar Jul 31 '18 03:07 mfranzke

@vpodk, do you have the possibility to even also report this back to the official Google channels (and probably provide the ticket no. as a reference both for caniuse and here) ?

mfranzke avatar Sep 25 '18 16:09 mfranzke

@mfranzke, I did not report any issue to Google's bug tracking system, but I found this one: https://bugs.chromium.org/p/chromium/issues/detail?id=242455

screen shot 2018-09-27 at 10 54 58 pm

vpodk avatar Sep 28 '18 05:09 vpodk