html52.com
我爱小程序-开发者交流社区

canvasToTempFilePath 安卓无法执行 iOS正常

问题模块 框架类型 问题类型 API/组件名称 终端类型 操作系统 微信版本 基础库版本
API和组件 小程序 Bug canvasToTempFilePath 客户端 Android 6.6.7 2.2.1

家中两部安卓

一部魅蓝note5

一部小米MIX2


版本都是微信版本 6.6.7

2.2.1 在canvasPutImageData的 success回调中执行draw 后无法再次执行canvasToTempFilePath


但是IOS上的基础库版本2.1.3 微信版本6.6.7 相同的代码却正常执行


let windowSize = this.windowSize
      let bookmark = this.bookmark
      let mainCtx = this.mainCtx
      let $store = this.$store
      let that = this
      wx.canvasGetImageData({
        canvasId: 'canvas',
        x: 0,
        y: ((windowSize.windowHeight * 0.9) - bookmark.backgroundImage.style.height) / 2,
        width: windowSize.windowWidth,
        height: bookmark.backgroundImage.style.height,
        success (res) {
          let d = res.data
          let filterData = filters[type](d, {
            height: bookmark.backgroundImage.style.height,
            width: bookmark.backgroundImage.style.width
          })
          wx.canvasPutImageData({
            canvasId: 'canvas',
            data: filterData,
            x: 0,
            y: ((windowSize.windowHeight * 0.9) - bookmark.backgroundImage.style.height) / 2,
            width: windowSize.windowWidth,
            height: bookmark.backgroundImage.style.height,

            success: (res) => {

// 安卓上执行到这一步没反应 打印mainCtx也有对象 iOS正常

              mainCtx.draw(true, () => {
                console.log(wx)
                wx.canvasToTempFilePath({
                  canvasId: 'canvas',
                  height: windowSize.windowHeight * 0.9,
                  y: 0,
                  success: (e) => {
                    console.log(e)
                    $store.dispatch('SET_BACKGROUND_IMAGE', e.tempFilePath)
                  },
                  fail: (e) => {
                  },
                  complete: (e) => {
                    console.log('complete')
                  }
                }, that)
              })
            }
          })
        }
      })



    我提交到体验版了 不知管理员能不能直接打开体验版查一下问题

网友回复

好哇你个狗东西:

同遇到这个问题,draw()的回调不执行

Jeff:

同遇到,不执行

瑰意琦行:

同问,ios可以缓存下来,没有问题,安卓总是不行,并且保存图片的时候红米和华为mate10经常出现只保存了图片的一个角落的图

mss。:

同样的问题,安卓ctx.draw回调不执行

娇华:

你好,请提供一下出现问题的机型和微信版本,以及能复现问题的简单代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html)。

坠入莱茵河:

而且mainCtx.draw(true, () => {这行直接没执行 也就是说 没有报错信息也没有执行fail回调

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

真正的个人免签约支付接口

云免签H5支付