takePhoto间隔设置为10ms, 导致无法complete
发布于 5 年前 作者 mingmo 13195 次浏览 来自 问答
  • 当前 Bug 的表现(可附上截图)

takePhoto() 间隔10ms, 几次调用之后无法complete, complete回调函数不被调用。

  • 预期表现

预期可以complete

  • 复现路径

按照代码复现。

  • 提供一个最简复现 Demo
captureTimer: function() {
  const self = this;
  setTimeout(() => {
    if (self.nextCaptureFlag && Date.now() >= 10 * 1 + self.lasttime) {
      self.nextCaptureFlag = false;
      self.addLog('start');
      self.takePhotoForDetection();
      self.lasttime = Date.now();
    }
    self.captureTimer();
  }, 10);
},
takePhotoForDetection() {
  const self = this;
  self.addLog('before take photo');
  let cameraCtx = wx.createCameraContext();
  cameraCtx.takePhoto({
    quality: 'low',
    success: (res) => {
      self.addLog('take photo');
    },
    complete: (ddd) => {
      self.addLog(`complete`);
      self.nextCaptureFlag = true;
    },
    fail: (err) => {
      self.addLog(`err`);
    },
  });
},

2 回复

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

机型是Galaxy J7 Prime, 其他都已经提供了。

回到顶部