tensorflow / tfjs-wechat

WeChat Mini-program plugin for TensorFlow.js
https://tensorflow.org/js
552 stars 104 forks source link

Error: Cannot get WebGL rendering context, WebGL is disabled. #27

Closed Inchel214 closed 5 years ago

Inchel214 commented 5 years ago

TensorFlow.js version 1.2.6 tfjs-wechat plugin version 0.0.6 WeChat version 7.0.6 WeChat base API version 2.8.0 WeChat IDE version v1.02.1907300 platform windows10

Error:Cannot get WebGL rendering context,WebGL is disabled.

mini-program can run normally,but it has error messages:

VM1623:1 Initialization of backend wechat-webgl failed console.warn @ VM1623:1 t.initializeBackend @ index.js:17 (anonymous) @ index.js:17 (anonymous) @ index.js:17 (anonymous) @ index.js:17 (anonymous) @ index.js:17 r @ index.js:17 t.setBackend @ index.js:17 t.setBackend @ index.js:17 t @ VM1680 appservice.js:1089 exports.setupWechatPlatform @ VM1680 appservice.js:1089 exports.configPlugin @ VM1680 appservice.js:1074 onLaunch @ app.js? [sm]:8 (anonymous) @ WAService.js:1 (anonymous) @ WAService.js:1 pe @ WAService.js:1 (anonymous) @ WAService.js:1 (anonymous) @ WAService.js:1 (anonymous) @ app.js? [sm]:6 require @ WAService.js:1 (anonymous) @ VM1845:1 scriptLoaded @ appservice?t=1566032884110:7176 script.onload @ appservice?t=1566032884110:7219 load (async) loadBabelModule @ appservice?t=1566032884110:7213 window.loadBabelMod @ appservice?t=1566032884110:7227 (anonymous) @ slicedToArray.js:12 VM1623:1 Error: Cannot get WebGL rendering context, WebGL is disabled. at index.js:17 at Bt (index.js:17) at new e (index.js:17) at Object.factory (VM1680 appservice.js:1089) at t.initializeBackend (index.js:17) at t. (index.js:17) at index.js:17 at Object.next (index.js:17) at index.js:17 at new Promise ()

Inchel214 commented 5 years ago

i set plugin config API in app.js as you said,

`onLaunch: function () { plugin.configPlugin({

  fetchFunc: fetchWechat.fetchFunc(),
  tf, canvas: wx.createOffscreenCanvas()
}, true);

}`

the console show the messages that 'current backend = wechat-webgl',but it still has errors that initialization failed

pyu10055 commented 5 years ago

@Inchel214 Is this on a phone or the wechat devtool? If it is on the phone can you share the brand and model of the phone? thanks

uygnef commented 5 years ago

@Inchel214 Is this on a phone or the wechat devtool? If it is on the phone can you share the brand and model of the phone? thanks

I have the same issue on the wechat devtool.

Inchel214 commented 5 years ago

@Inchel214 Is this on a phone or the wechat devtool? If it is on the phone can you share the brand and model of the phone? thanks

on the wechat devtool

Inchel214 commented 5 years ago

@Inchel214 Is this on a phone or the wechat devtool? If it is on the phone can you share the brand and model of the phone? thanks

I have the same issue on the wechat devtool.

I have not worked out,but it seems not to make a difference when I run the model on a phone.

dklospace commented 5 years ago

I also see this issue when running inside DevTool. The model speed for running inside devtool vs running on real device can makes a huge difference (~5s vs 150ms). However I'm not entirely sure if the model runs on webgl backend even on real device, the speed seems to be on par with native CPU tflite models.

@pyu10055

pyu10055 commented 5 years ago

@dklospace @Inchel214 This looks like issue of WeChat IDE, @ele828 is looking into this.

@dklospace Regarding the the inference time, the speed depends on the type of devices (Android is couple time slower than iphone, we are looking into that as well). 150ms should be GPU, since our CPU is based on javascript implementation, the speed is at least 10 times slow than the GPU.

pyu10055 commented 5 years ago

@Inchel214 @dklospace you need to turn on the GPU support in the IDE to use WEBGL. 101568867221_ pic

dklospace commented 5 years ago

@pyu10055 Hi Ping, I just tried to turn on this flag and deploy it to my iphone, didn't observe speed difference. Seems like it will enable webgl backend no matter if I turn on this flag or not.

pyu10055 commented 5 years ago

@dklospace this is for fixing the error posted by @Inchel214.

pyu10055 commented 5 years ago

closing this thread, documentation has been updated with this information. thanks.