Is Three.js experimental-webgl context available in Ionic2 on Android?


#1

Hello everybody. I was trying to adapt a panorama viewer made with Three.js in my Ionic2 android app. I need a WebGL renderer but the function THREE.WebGLRenderer() unfortunately returns null.
So i tried to investigate and i did these test:

var canvas = document.createElement( 'canvas' );
console.log("TEST 2d : " + canvas.getContext('2d')) // returns the context
console.log("TEST 3d : " + canvas.getContext('experimental-webgl')) // returns null

Is somehow possible to have a WebGLRenderer in Ionic2? Notice that everything works well when I test the project on Firefox, but it doesn’t work when I test it on Android.


#2

I don’t think the lack of WebGL render support is related to Ionic2, but to the Android version you’re using. You can use
http://caniuse.com/#search=webgl to check for WebGL support in Android and other browsers. Don’t know which version you’re using however.
As an alternative you could use the crosswalk plugin (https://github.com/crosswalk-project/cordova-plugin-crosswalk-webview) and embed a webview based on a specific Chrome version in your application. That way you know all your users who installed your app are running the same webview with the same modern features - e.g. WebGL support.


#3

I’m using Android 5.1.1 (CyanogenMod) and it should be compatible. I also installed Crosswalk but it isn’t working the same. Maybe the lack of GPU in both my sartphone and tablet has a part in this. I’ll try my app over other devices.

EDIT: getContext functions are null in both smartphone (Galaxy Nexus) and tablet. Instead, THREE.WebGLRenderer() works on tablet.