15

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

tshepang
  • 10,772
  • 21
  • 84
  • 127
arun8
  • 1,121
  • 2
  • 13
  • 25

5 Answers5

16

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

Cypress Frankenfeld
  • 2,001
  • 1
  • 26
  • 37
yarons
  • 284
  • 2
  • 3
  • 1
    (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: http://developer.android.com/about/versions/lollipop.html#WebView – rbarriuso Nov 25 '14 at 20:30
  • 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 :( – Bay Sep 25 '19 at 08:27
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.

krisrak
  • 12,622
  • 3
  • 28
  • 45
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.

Autumn
  • 11
  • 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! – Bay Sep 25 '19 at 08:36
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

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 .

Hitesh Sahu
  • 31,496
  • 11
  • 150
  • 116
  • This doesn't help with new update of Google Chrome for Android after version v77.0.3865.92 – Bay Sep 24 '19 at 06:49