Skip to content

Commit

Permalink
Merge pull request #590 from gini/PP-823_QR-code-not-initialized-dial…
Browse files Browse the repository at this point in the history
…og-is-appearing-randomly

fix(capture-sdk): Make sure that frame will not be closed before all …
  • Loading branch information
GeraltRiv authored Oct 8, 2024
2 parents 81cc9d0 + 3dd3b38 commit baec695
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1856,9 +1856,14 @@ void initCameraController(final Activity activity) {
public void onPreviewFrame(@NonNull Image image, @NonNull Size imageSize, int rotation, @NonNull CameraInterface.PreviewFrameCallback previewFrameCallback) {
AtomicInteger previewFrameReferenceCount = new AtomicInteger();
if (ibanRecognizerFilter != null) {
try {
previewFrameReferenceCount.getAndIncrement();
previewFrameReferenceCount.getAndIncrement();
}
if (mPaymentQRCodeReader != null) {
previewFrameReferenceCount.getAndIncrement();
}

if (ibanRecognizerFilter != null) {
try {
if (cropToCameraFrameTextRecognizer != null) {
cropToCameraFrameTextRecognizer.setCameraPreviewSize(new Size(mCameraPreview.getWidth(), mCameraPreview.getHeight()));
cropToCameraFrameTextRecognizer.setImageSizeAndRotation(imageSize, rotation);
Expand All @@ -1881,8 +1886,6 @@ public void onPreviewFrame(@NonNull Image image, @NonNull Size imageSize, int ro
}

if (mPaymentQRCodeReader != null) {
previewFrameReferenceCount.getAndIncrement();

mPaymentQRCodeReader.readFromImage(image, imageSize, rotation, () -> {
previewFrameReferenceCount.getAndDecrement();
if (previewFrameReferenceCount.get() == 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public void onQRCodesDetected(@NonNull final List<String> qrCodes) {
public void onQRCodeScannerError(Exception e) {

//TODO: check content of exception if there will be more use cases in the future
if (!(e instanceof IllegalStateException)) {
if (!(e instanceof CancellationException)) {
mListener.onQRCodeReaderFail();
}
}
Expand Down

0 comments on commit baec695

Please sign in to comment.