cordova-plugin-camera-preview / cordova-plugin-camera-preview

Cordova plugin that allows camera interaction from HTML code
MIT License
567 stars 559 forks source link

Android: cameraStop/cameraStart restart yields frozen preview with toBack: true #647

Open elpollodiablo opened 3 years ago

elpollodiablo commented 3 years ago

I'm using the latest cordova-plugin-camera-preview@0.12.2 with @ionic-native/camera-preview@5.32.1

When restarting, that is, starting, stopping and starting the camera again via cameraPreview.hide() and cameraPreview.stop(), the preview will be a frozen image of the time when cameraPreview.start() was called (as opposed to when it was stopped, so something is happening). It does not matter if I add .show() or .hide() to the start()/.stop() calls. I can also still focus/take pictures which seem to have the right content. Everything seems to work, except for the preview.

I tried removing all webview elements via debugger that might be artefacts or what have you, down to the ion-app container, to no avail. Only a frozen image remains.

The issue does not occur when toBack: false is set, but this invocation does not suffice for my use case, as I need overlay elements.

I tested with Redmi S2 / Android 9 and Galaxy S8 / Android 9, with recent updates.

These are the settings I'm using:

  cameraPreviewOpts = {
      x: 0,
      y: 0,
      width: window.screen.width,
      height: window.screen.height,
      camera: 'rear',
      tapPhoto: true,
      previewDrag: false,
      tapFocus: true,
      toBack: true,
      alpha: 1,
      storeToFile: true
  }

Any insight into this issue would be very much appreciated.