简体   繁体   English

Android WebView中的WebGL

[英]WebGL in Android WebView

I know this has been asked before but those questions are pretty old now. 我知道之前已经问过,但这些问题现在已经很久了。 I have a "game" that I developed some time ago with WebGL and I want to bring it to Android with a simple WebView. 我有一段时间用WebGL开发的“游戏”,我希望用简单的WebView将它带到Android。 The problem now is, that it won't really respond to the user input in the WebView (Chrome works just fine. Android 7.1.1) . 现在的问题是,它不会真正响应WebView中的用户输入(Chrome工作正常.Android 7.1.1)。 I guess that's because of WebGL. 我猜这是因为WebGL。

So now, as the crosswalk-project has ended a while ago I am searching for an alternative to run WebGL in my application. 所以现在,由于crosswalk项目已经结束了一段时间,我正在寻找在我的应用程序中运行WebGL的替代方案。 Or somehow just run my "game" in an Android App. 或者以某种方式在Android应用程序中运行我的“游戏”。

Do you have any idea of how I could bring it to work? 你知道我怎么能把它带到工作中吗?

From 5.0 Android comes with Android System WebView which is being updated and we might call it the Native WebView . 从Android 5.0开始, Android System WebView正在更新,我们可能将其称为Native WebView WebGL should work there although some of WebGL extensions and WebGL 2 ( stats ) might not. WebGL应该在那里工作,尽管一些WebGL扩展和WebGL 2( 统计数据 )可能不会。

The key to make your game work as an application is following. 让您的游戏作为应用程序工作的关键是遵循。

First you must identify what WebGL version, WebGL extensions, WebGL or Shader capabilities and other HTML5 functionality your game (and the game engine you use) requires. 首先,您必须确定您的游戏(以及您使用的游戏引擎)所需的WebGL版本,WebGL扩展,WebGL或Shader功能以及其他HTML5功能。

Then you must find a WebView that supports that functionality. 然后,您必须找到支持该功能的WebView。 You can simply do that by opening webpages https://html5test.com/ and http://webglreport.com/ with the WebView you want on your Android device. 您可以通过在Android设备上使用您想要的WebView打开网页https://html5test.com/http://webglreport.com/来实现这一目的。 IMPORTANT! 重要! If you for example open the webpage with installed Chrome browser, it doesn't guarantee the Native WebView is used! 例如,如果您打开安装了Chrome浏览器的网页,则无法保证使用Native WebView! So it is better to write a small custom application to make sure you are testing the WebView you want to use for the game. 因此,最好编写一个小型自定义应用程序,以确保您正在测试要用于游戏的WebView。

In the end you will probably end up with compiling your game in application with custom WebView which will add an additional size to your game. 最后,您可能最终会在应用程序中使用自定义WebView编译您的游戏,这将为您的游戏增加额外的大小。

Other useful informations 其他有用的信息

  • Android versions < 5.0 has a Native WebView that doesn't come with updates so it doesn't support WebGL and this will not change. Android版本<5.0有一个Native WebView,它没有更新,所以它不支持WebGL,这不会改变。 But the Chrome browser (or other installed browsers) is likely to support WebGL there, because it comes with custom WebView. 但Chrome浏览器(或其他已安装的浏览器)可能会支持WebGL,因为它带有自定义WebView。
  • Samsung really messed up. 三星真的搞砸了。 I mean it, they are customizing Android OS a lot including some black magic with WebViews => Native WebView doesn't work there properly, so custom WebView in your application is must. 我的意思是,他们正在定制Android操作系统很多,包括一些使用WebViews的黑魔法=> Native WebView无法在那里正常工作,因此您的应用程序中的自定义WebView是必须的。
  • We ( GAMEE ) are using the Native WebView and XWalkView for Samsung and Android < 5.0 and WebGL games are working just fine right now. 我们( GAMEE )正在使用Native WebView和XWalkView for Samsung和Android <5.0,而WebGL游戏现在正常运行。

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

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