简体   繁体   中英

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. 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) . I guess that's because of WebGL.

So now, as the crosswalk-project has ended a while ago I am searching for an alternative to run WebGL in my application. Or somehow just run my "game" in an Android App.

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 . WebGL should work there although some of WebGL extensions and WebGL 2 ( stats ) might not.

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.

Then you must find a WebView that supports that functionality. You can simply do that by opening webpages https://html5test.com/ and http://webglreport.com/ with the WebView you want on your Android device. IMPORTANT! If you for example open the webpage with installed Chrome browser, it doesn't guarantee the Native WebView is used! 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.

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.

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. But the Chrome browser (or other installed browsers) is likely to support WebGL there, because it comes with custom 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.
  • We ( GAMEE ) are using the Native WebView and XWalkView for Samsung and Android < 5.0 and WebGL games are working just fine right now.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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