Enabling WebGL support for Android WebView - android

I need to display WebGL graphics in my webview. Is there any way to modify Android WebView to enable WebGL. If yes, How?

WebGL was not supported in WebViews before Android Lollipop. In KitKat, Android switched to Chromium as the native WebView implementation, but it is locked to Chromium 33, with no WebGL. In Lollipop, WebView is updated via the Play Store, and now supports WebGL. (source: https://developer.chrome.com/multidevice/webview/overview)
Trying to extend WebView to support it is next to impossible.
One thing you might consider, is use CSS 3D transformations instead of WebGL, those are supported on Android ICS and forward, see http://caniuse.com/#feat=transforms3d

WebGL is not supported in current Android webview, you can however use crosswalk-project which is a web runtime that supports WebGL and package it in a android app along with your WebGL app. The latest Intel XDK supports building Android apps with crosswalk runtime.

You can view WebGL on new Android devices using the Chrome Beta app or Firefox beta app. The only device I have tested and this worked on is the Asus Nexus 7 tablet running Android 4.2.2.
My Motorola Razr running Android 4.1.2 does not support WebGL with google Chrome Beta.
Not sure if this directly helps.. but FYI.

Although it is not possible to enable WebGL for Android WebView, there is an option to have native apps using WebGL for rendering using CocoonJS by Ludei (www.ludei.com). They even have a demo app in Google Play to show some known WebGL demos running even in Android 2.3 devices.
https://play.google.com/store/apps/details?id=com.ludei.demos.webgl
Even running on OUYA!
http://www.youtube.com/watch?v=ypyqkAo1jgo

I have chrome version 28.0 on OS 4.2.2 WebGl is not enabled by default you need to enable it by typying chrome://flags/ in seach bar just the way shwn in pic below
Once you have enabled web gl relaunch chrome and you will be able to run most of three.js experiments . I have shared screenshots for few :-
I also tried everything on webview but I was unable to set webgl flags. Probably it is not possible to use webgl in webviews .

Related

Using WebView WebGL from Android emulator

As I understand, WebGL is only supported in WebView in Android Lollipop (updating the WebView component in the Play Store), and newer versions (no Play Store update required).
However, I have an emulator using Android 7.1.1, and WebGL is not working. http://webglreport.com says "This browser supports WebGL 1, but it is disabled or unavailable.". I have also tried an Android 6.0 emulator, with the same result.
WebGL works fine in the emulator when using Chrome, but not in a WebView.
WebGL works fine in a WebView in a physical 6.0 phone.
What could be the reason why WebGL is not working in the same emulator, when using a WebView?
This turns out to be a limitation of the current version of the emulator: https://code.google.com/p/android/issues/detail?id=229984

What is the engine of Android native browser?

What is the engine of Android native browser? Wiki says that Android used WebKit before 4.4 and Blink for 4.4 and further versions. Is it right statement? Thanks in advance.
The default browser on Android is Google Chrome. This uses the Blink layout engine. For AOSP installations without the Google Apps, the default browser is the old "Browser" app that uses Webkit.
other third party browsers like Firefox uses Gecko, Opera uses Blink, Dolphin uses Webkit, and there are probably others. Additionally, also Samsung and HTC install different (non-Chrome) browsers on their phones. I do not know what they are, or what engine they use.
similar question answered you can see here
I had a similar question. Below is what I found.
1. Wikipedia article
List of features in Android:
Web browser
The web browser available in Android is based on the open-source Blink (previously WebKit) layout engine, coupled with Chromium's V8 JavaScript engine. Then the WebKit-using Android Browser scored 100/100 on the Acid3 test on Android 4.0 ICS; the Blink-based browser currently has better standards support. The old web browser is variably known as 'Android Browser', 'AOSP browser', 'stock browser', 'native browser', and 'default browser' (from the time it was always the default). Starting with Android 4.4 KitKat, Google has begun licensing Google Chrome (a proprietary software) separately from Android, but usually bundled with (what most device vendors did). Since Android 5.0 Lollipop, the WebView browser that apps can use to display web content without leaving the app has been separated from the rest of the Android firmware in order to facilitate separate security updates by Google.
2. HTML5test's slides
The Android Browser
ANDROID 4 DEVICES
ALSO COMMONLY SHIP WITH
GOOGLE CHROME
DEPENDING ON YOUR DEVICE
GOOGLE CHROME COULD BE
AN EXTRA BROWSER
THE DEFAULT BROWSER
THE ONLY BROWSER
OR NOT THERE AT ALL
ANDROID 4.4 SHIPS
WITH A NEW WEBVIEW
BASED ON
CHROMIUM 30
BUT NOT THE SAME AS
GOOGLE CHROME
THE CHROMIUM BASED WEBVIEW
WILL BE UPDATED REGULARLY
ANDROID 4.4.3 → CHROMIUM 33
ANDROID 5 → CHROMIUM 37
IN FACT ON ANDROID 5
THE WEBVIEW CAN BE UPDATED
INDEPENTENTLY OF THE OS
3. Release Notes on WebView
Android 4.4 KitKat
Chromium WebView
Android 4.4 includes a completely new implementation of WebView that's based on Chromium. The new Chromium WebView gives you the latest in standards support, performance, and compatibility to build and display your web-based content.
Chromium WebView provides broad support for HTML5, CSS3, and JavaScript. It supports most of the HTML5 features available in Chrome for Android 30. It also brings an updated version of the JavaScript Engine (V8) that delivers dramatically improved JavaScript performance.
In addition, the new Chromium WebView supports remote debugging using Chrome DevTools. For example, you can use Chrome DevTools on your development machine to inspect, debug, and analyze your WebView content live on a mobile device.
The new Chromium WebView is included on all compatible devices running Android 4.4 and higher. You can take advantage of the new WebView right away, and with minimum modifications to existing apps and content. In most cases, your content will migrate to the new implementation seamlessly.
Android 5.0 Lollipop
Chromium WebView
The initial release for Android 5.0 includes a version of Chromium for WebView based on the Chromium M37 release, adding support for WebRTC, WebAudio, and WebGL.
Chromium M37 also includes native support for all of the Web Components specifications: Custom Elements, Shadow DOM, HTML Imports, and Templates. This means you can use Polymer and its material design elements in a WebView without needing polyfills.
Although WebView has been based on Chromium since Android 4.4, the Chromium layer is now updatable from Google Play.
As new versions of Chromium become available, users can update from Google Play to ensure they get the latest enhancements and bug fixes for WebView, providing the latest web APIs and bug fixes for apps using WebView on Android 5.0 and higher.
Android 7.0 Nougat
WebView
Chrome + WebView, Together
Starting with Chrome version 51 on Android 7.0 and above, the Chrome APK on your device is used to provide and render Android System WebViews. This approach improves memory usage on the device itself and also reduces the bandwidth required to keep WebView up to date (as the standalone WebView APK will no longer be updated as long as Chrome remains enabled).
You can choose your WebView provider by enabling Developer Options and selecting WebView implementation. You can use any compatible Chrome version (Dev, Beta or Stable) that is installed on your device or the standalone Webview APK to act as the WebView implementation.
Multiprocess
Starting with Chrome version 51 in Android 7.0, WebView will run web content in a separate sandboxed process when the developer option "Multiprocess WebView" is enabled.
...

My app works fine in android chrome but not in webview which uses default web browser

I have written a webview app which opens a web url. However the experience is just like when I have opened it in the default web browser of my Samsung S3 phone (android ver 4.2) which is very poor (e.g. google map cannot be displayed). Is there a way to force the webview app to use other browsers that default one, for example using Chrome browser that i installed in my smartphone?
With Android 4.4, the WebView was switched to be based on the Chromium project. Prior to that it was an Android's specific implementation of WebKit. With Android 5.0 the WebView is now updatable without OS updates through the Google Play Store.
https://developer.chrome.com/multidevice/webview/overview
If you want consistent behavior in your WebView across multiple versions of Android you'll need to include your own browser engine. Once such project is Crosswalk.
What is a difference between intel xdk, appmobi, and crosswalk?

WebGL not working in PhoneGap Android KitKat

I'm trying to render some WebGL in my PhoneGap/Cordova app but I'm having no luck.
var canvas = document.createElement('canvas');
var gl = canvas.getContext("webgl") || canvas.getContext("experimental-webgl");
if (!gl) {
console.log('WebGL not supported');
}
The gl variable is always null.
I've tried with a OnePlus One and a Nexus 5 which are both Android KitKat v4.4.4 Chrome 38.
The same code works fine on iOS8 and on a desktop.
The code works on a normal webpage loaded in chrome on those devices. So does http://get.webgl.org/
I've even tried using CCA which uses crosswalk to bundle Chrome into the app.
I've tried Googling bug I'm flooded with people having problems from when devices didnt support it (iOS < v8 and Android < v4.4).
I'm thinking that it might be something that I have to enable in the build chain.
Thank you in advance.
Glen
I've figured it out with some help.
Even though I have Chrome 38 installed, the WebView is actually not using the installed chrome version but another version that ships with the OS and doesn't auto update.
The WebView is actually Chrome 33 which doesn't support WebGL.
When Android L comes out, it will support WebGL in the WebView which will automatically update too.
In regards to the CCA version, it bundles Chrome 37 which supports WebGL. It works on devices that don't have blacklisted GPUs. If you follow these instructions it tells you that you can make it ignore the blacklist and run on all devices but might have unstable results.
If you want to use WebGL on Android 4.0+ Ludei (http://ludei.com) has a project called WebView+ that allows you to use the latest Chromium project on Android. The drawback is that 15Mb are added to your final APK. You can test it using the CocoonJS Launcher App: https://play.google.com/store/apps/details?id=com.ideateca.cocoonjslauncher&hl=es where you can point to a URL (even use a QRCode so you do not have to type the whole URL on a mobile device) or even upload a whole ZIP file with your project to test it off-line.

Which rendering engine does Chrome Apps on Mobile use?

Apache Cordova apps use the default WebView control in Android.
Change default webkit on Apache Cordova - Android
So for Android 4.4, the WebView is using Chromium 30, and will never be updated (on 4.4).
http://www.mobilexweb.com/blog/android-4-4-kitkat-browser-chrome-webview
Does the "Chrome Apps on Mobile" version of Apache Cordova, package a Chrome Runtime with it to use for rendering? (please say yes)
https://github.com/MobileChromeApps/mobile-chrome-apps
The answer is no. The "Chrome Apps for Mobile" use the default WebView just like the normal Apache Cordova.
Do mobile chrome apps run in chrome?
The default system WebView’s are as follows:
OS: Mobile Safari WebKit based. Lots of web-platform overlap with Chrome, but not exact and diverging slowly.
Android 4.3 or older: Legacy Android WebView. Dated and occasionally buggy, but still fairly performant on certain tasks.
Android 4.4: Chrome based WebView. This initial release brought a slew of modern web apis, and enabled remote web
inspector. However, it also introduced some regressions, is stuck
at Chrome 30, and didn't bring all features, such as WebGL and
WebRTC.
Android Future: Since the first launch of Chrome based WebView, it was announced that work is ongoing to make the WebView
auto-update just like the Chrome Browser does.
Here's the good news quote from May 13th, 2014 from the same answer quoted above:
Excitingly, a significant portion of our recent work on
cordova-android has been on bundling a tip-of-tree chromium based
“webview” alongside your app, thanks to the Intel Crosswalk project (https://crosswalk-project.org/).
This would mean you ship your app to the Play Store together with your
very own modern build of Chromium webview. Best yet, it will work all
the way back to Android 4.0. Expect announcements on how to try it
yourself in the next month or so!

Categories

Resources