Enabling WebGL support for Android WebView

2020-02-03 06:27发布

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

5条回答
Ridiculous、
2楼-- · 2020-02-03 07:06

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

查看更多
成全新的幸福
3楼-- · 2020-02-03 07:06

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 .

查看更多
手持菜刀,她持情操
4楼-- · 2020-02-03 07:08

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.

查看更多
干净又极端
5楼-- · 2020-02-03 07:15

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.

查看更多
趁早两清
6楼-- · 2020-02-03 07: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

查看更多
登录 后发表回答