收藏
回答

canvasToTempFilePath:fail:create bitmap failed

框架类型 问题类型 操作系统 操作系统版本 手机型号 微信版本
小程序 Bug Android 安卓9 华为p10 微信8.0
saveImgToLocal() {
      const that = this;
      setTimeout(() => {
        wx.canvasToTempFilePath({
          canvasId: 'k-canvas',
          destWidth: that.canvasWidthInPx,
          destHeight: that.canvasHeightInPx,
          success: function (res) {
            that.getImageInfo(res.tempFilePath);
          },
          fail: function (error) {
            console.error(`canvasToTempFilePath failed, ${JSON.stringify(error)}`);
            that.triggerEvent('imgErr', {
              error: error
            });
  						const { errMsg } = error
  						if(errMsg === 'canvasToTempFilePath:fail:create bitmap failed') {
  							that.errorCount += 1;
  							if (that.errorCount < 3) {
  									that.saveImgToLocal();
  							} else {
  								// 错了这么多遍基本没救了
  								that.$u.toast('手机性能不够,绘制失败')
  							}
  						}
          },
        }, this);
      }, 300);
    }


微信小程序运行这段代码,华为p10 绘制失败,出现 canvasToTempFilePath:fail:create bitmap failed,延迟和重新调用都没用。

各位前端大神有办法吗?


最后一次编辑于  2021-02-06
回答关注问题邀请回答
收藏

1 个回答

  • 社区技术运营专员-Jahozheng
    社区技术运营专员-Jahozheng
    2021-02-06

    可能是图片过大导致的,缩小图片试试

    2021-02-06
    有用
    回复 1
    • ℡长城
      ℡长城
      2021-10-12
      如果无法缩小图片,这个问题该如何解决?
      2021-10-12
      回复
登录 后发表内容
问题标签