简体   繁体   English

WebGL无法在PhoneGap Android KitKat中运行

[英]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. 我正试图在我的PhoneGap / Cordova应用程序中渲染一些WebGL,但我没有运气。

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. gl变量始终为null。

I've tried with a OnePlus One and a Nexus 5 which are both Android KitKat v4.4.4 Chrome 38. 我尝试使用OnePlus One和Nexus 5,它们都是Android KitKat v4.4.4 Chrome 38。

The same code works fine on iOS8 and on a desktop. 相同的代码在iOS8和桌面上运行良好。

The code works on a normal webpage loaded in chrome on those devices. 该代码适用于在这些设备上以chrome方式加载的普通网页。 So does http://get.webgl.org/ http://get.webgl.org/也是如此

I've even tried using CCA which uses crosswalk to bundle Chrome into the app. 我甚至尝试使用CCA ,它使用人行横道将Chrome捆绑到应用程序中。

I've tried Googling bug I'm flooded with people having problems from when devices didnt support it (iOS < v8 and Android < v4.4). 我已经尝试了谷歌搜索错误我被充斥着设备不支持它的人(iOS <v8和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. 即使我安装了Chrome 38,但WebView实际上并未使用已安装的Chrome版本,而是另一个随操作系统附带的版本,并且不会自动更新。

The WebView is actually Chrome 33 which doesn't support WebGL . WebView实际上是Chrome 33, 它不支持WebGL

When Android L comes out, it will support WebGL in the WebView which will automatically update too. 当Android L问世时,它将支持WebView中的WebGL,它也将自动更新。

In regards to the CCA version, it bundles Chrome 37 which supports WebGL. 关于CCA版本,它捆绑了支持WebGL的Chrome 37。 It works on devices that don't have blacklisted GPUs . 它适用于没有列入黑名单的GPU的设备 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. 如果您想在Android 4.0+上使用WebGL,Ludei( http://ludei.com )有一个名为WebView +的项目,允许您在Android上使用最新的Chromium项目。 The drawback is that 15Mb are added to your final APK. 缺点是15Mb被添加到你的最终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. 您可以使用CocoonJS Launcher应用程序对其进行测试: https//play.google.com/store/apps/details? id = com.ideateca.cocoonjslauncher &hl = es,您可以在其中指向URL(即使使用QRCode也可以不必在移动设备上键入整个URL),甚至可以上传整个ZIP文件与您的项目进行脱机测试。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM