Enabling WebGL support for Android WebView
Asked Answered
A

5

15

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

Anabatic answered 13/3, 2013 at 19:58 Comment(0)
L
17

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

Lydalyddite answered 13/3, 2013 at 20:37 Comment(2)
(Update) In case it's helpful for others: Android 4.4 (KitKat) included a Chrome-based WebView, but WebGL was disabled. Android 5.0 (Lollipop) includes a WebView based on Chromium M37, which supports, among others, WebGL. Additionally it can be upgraded via Google Play. See: developer.android.com/about/versions/lollipop.html#WebViewMacassar
With yesterday's update for Android devices Google Chrome v77.0.3865.92 update causes unsupport for WebGL on Android app's webView if you use. My projects are gone :(Mcfarland
O
6

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.

Orient answered 17/3, 2014 at 3:27 Comment(0)
P
1

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.

Pasahow answered 14/3, 2013 at 19:42 Comment(1)
Awesome help! Since WebGL is blocked for Android devices by Google Chrome v77.0.3865.92 update which causes unsupport for WebGL says your browser doesn't support WebGL, but actually it supports, and flags/settings of Chrome browser never help for Android webView, your solution of Google Chrome Beta fixed the problem for Android webView! Awesome!Mcfarland
M
1

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

Meander answered 4/6, 2013 at 3:22 Comment(0)
M
1

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

enable WebGl Chrome Android

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 :-

cloth demo

minecraft demo

I also tried everything on webview but I was unable to set webgl flags. Probably it is not possible to use webgl in webviews .

Morgun answered 2/12, 2015 at 18:49 Comment(1)
This doesn't help with new update of Google Chrome for Android after version v77.0.3865.92Mcfarland

© 2022 - 2024 — McMap. All rights reserved.