收藏
回答

Cannot read property 'setWebGLContext' of undefine

问题类型 插件 AppID 插件版本号 AppID 微信版本 基础库版本
Bug wx6afed118d9e81df9 tansorflow wxf08655286f3196e9 6.5.3 2.10.0

安装TensorFlow后运行,出现以下错误提示,请问是哪里问题?

VM127:1 thirdScriptError

Cannot read property 'setWebGLContext' of undefined;at App lifeCycleMethod onLaunch function

TypeError: Cannot read property 'setWebGLContext' of undefined

    at t (http://127.0.0.1:56710/appservice/__onlineplugin__/wx6afed118d9e81df9/0.0.6/appservice.js:1089:384)

    at Object.exports.setupWechatPlatform (http://127.0.0.1:56710/appservice/__onlineplugin__/wx6afed118d9e81df9/0.0.6/appservice.js:1089:1537)

    at Object.exports.configPlugin (http://127.0.0.1:56710/appservice/__onlineplugin__/wx6afed118d9e81df9/0.0.6/appservice.js:1074:148)

回答关注问题邀请回答
收藏

4 个回答

  • 刘惠俊
    刘惠俊
    2020-06-22
    "plugins": {
        "tfjsPlugin": {
          "version": "0.0.6",
          "provider": "wx6afed118d9e81df9"
        }
      }
    将上面的version改为0.1.0,就好了
    
    2020-06-22
    有用 12
    回复 2
    • 小王子
      小王子
      2020-07-18
      谢谢
      2020-07-18
      回复
    • Lik-
      Lik-
      2022-04-01
      感谢感谢
      2022-04-01
      回复
  • waterbang
    waterbang
    2020-06-19

    应该是版本代代码不同的问题,修改一下版本

     "@tensorflow-models/posenet""^2.1.3",
     "@tensorflow/tfjs-converter""^1.2.2",
     "@tensorflow/tfjs-core""^1.2.2",
     "fetch-wechat""^0.0.3",
      "regenerator-runtime""^0.13.2"
    
    


    删除node_modules 重新install 并且构建一下


    2020-06-19
    有用 1
    回复
  • James国俊
    James国俊
    2020-06-08

    都是按照腾讯课程的配置,检查过,没有问题。

    2020-06-08
    有用
    回复
  • 团团呗
    团团呗
    2020-06-08

    TensorFlow的配置参数正确吗

    2020-06-08
    有用
    回复 11
    • James国俊
      James国俊
      2020-06-09
      今天专门申请了一个干净的账号来测试,还是那个错误。用真机调测的时候,结果一大堆报错。请帮忙看下是什么问题,谢谢!
      2020-06-09
      回复
    • 团团呗
      团团呗
      2020-06-09回复James国俊
      检查配置参数是否正确,可以不用真机调试直接扫码预览看看,开发者工具上可以运行吗?腾讯课堂那个官方教程我之前也看过,按着教程走没问题
      2020-06-09
      回复
    • James国俊
      James国俊
      2020-06-09
      开发工具运行就是提示:Cannot read property 'setWebGLContext' of undefined;at App lifeCycleMethod onLaunch function

      TypeError: Cannot read property 'setWebGLContext' of undefined

      这个消息。运行不下去。
      教程没有过多的参数设定,基本就是如下几步:

      添加TensorFlow.JS插件
      https://mp.weixin.qq.com/wxopen/plugindevdoc?appid=wx6afed118d9e81df9&token=1076294821&lang=zh_CN

      安装Node.js
      https://nodejs.org

      npm安装第三方库
      在项目目录下:

      ```
      npm init
      npm install @tensorflow/tfjs-core
      npm install @tensorflow/tfjs-converter
      npm install @tensorflow/tfjs-layers
      npm install fetch-wechat
      npm install regenerator-runtime
      ```

      然后去微信小程序开发工具里面"构建npm"

      第三方库的导入
      ```
      var fetchWechat = require('fetch-wechat');
      var tf = require('@tensorflow/tfjs-core');
      var plugin = requirePlugin('tfjsPlugin');
      ```

      app.json里面添加
      "plugins": {
          "tfjsPlugin": {
            "version": "0.0.6",
            "provider": "wx6afed118d9e81df9"
          }
        }

      在app.js里配置插件
      ```
      App({
        onLaunch: function () {
          plugin.configPlugin({
            fetchFunc: fetchWechat.fetchFunc(),
            tf, canvas: wx.createOffscreenCanvas()
          })
        }
      })
      ```

      帮忙看下有无问题,谢谢!
      2020-06-09
      回复
    • 团团呗
      团团呗
      2020-06-09回复James国俊
      开发者工具基础调试库版本有用最新的吗,你这配置看起来没什么问题,tensorflow插件可以引用最新的试试
      2020-06-09
      回复
    • James国俊
      James国俊
      2020-06-09
      用了0.0.9版本的了,基础课2.10.0
      2020-06-09
      回复
    查看更多(6)
登录 后发表内容
问题标签