Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(barcode-scanning): add delay before starting camera session #188

Merged
merged 2 commits into from
Oct 7, 2024

Conversation

robingenz
Copy link
Member

Pull request checklist

Please check if your PR fulfills the following requirements:

  • The changes have been tested successfully.
  • A changeset has been created (npm run changeset).
  • I have read and followed the pull request guidelines.

Close #176

@robingenz robingenz added bug/fix Something isn't working package: barcode-scanning labels Sep 25, 2024
Copy link

pkg-pr-new bot commented Sep 25, 2024

Open in Stackblitz

@capacitor-mlkit/barcode-scanning

npm i https://pkg.pr.new/capawesome-team/capacitor-mlkit/@capacitor-mlkit/barcode-scanning@188

@capacitor-mlkit/face-detection

npm i https://pkg.pr.new/capawesome-team/capacitor-mlkit/@capacitor-mlkit/face-detection@188

@capacitor-mlkit/face-mesh-detection

npm i https://pkg.pr.new/capawesome-team/capacitor-mlkit/@capacitor-mlkit/face-mesh-detection@188

@capacitor-mlkit/selfie-segmentation

npm i https://pkg.pr.new/capawesome-team/capacitor-mlkit/@capacitor-mlkit/selfie-segmentation@188

@capacitor-mlkit/translation

npm i https://pkg.pr.new/capawesome-team/capacitor-mlkit/@capacitor-mlkit/translation@188

commit: 8f2eb9b

@TimvdEijnden
Copy link

When will this be released?

@robingenz
Copy link
Member Author

@TimvdEijnden I was still waiting to see if there would be more feedback.

@TimvdEijnden
Copy link

I can try the pkg.new version, because I got an issue only on iOS that the camera is not showing up

@robingenz robingenz merged commit a0198b6 into main Oct 7, 2024
2 checks passed
@robingenz robingenz deleted the fix/issue-176 branch October 7, 2024 08:08
This was referenced Oct 7, 2024
@jimcase
Copy link

jimcase commented Oct 10, 2024

Thanks @robingenz for tackling the camera issue.

While the 0.1s delay might help in some cases, it feels more like a temporary workaround than a solid fix. The main issue is that commitConfiguration() sometimes runs asynchronously, causing startRunning() to be called prematurely. Ideally, the solution should ensure commitConfiguration() fully completes before proceeding, without relying on a fixed delay.

We've tested this approach in another project (PR: cardano-foundation/cf-identity-wallet#772) and found that the delay didn't consistently resolve the issue. A more reliable method would be preferable.

Error:

*** Terminating app due to uncaught exception 'NSGenericException', reason: '*** -[AVCaptureSession startRunning] startRunning may not be called between calls to beginConfiguration and commitConfiguration'
*** First throw call stack:
(0x18441908c 0x18171b2e4 0x1a25838f0 0x104a86d84 0x1063d8d68 0x1063d8de8 0x105a84a30 0x105a8671c 0x105a9ae58 0x105a9b618 0x20b78bc40 0x20b788488)
libc++abi: terminating due to uncaught exception of type NSException

@robingenz
Copy link
Member Author

@jimcase Yes, I know that's not an ideal solution. Unfortunately, I can't think of any other solution at the moment. If you have an idea, you are welcome to create a PR and I'll take a look at it.

@jimcase
Copy link

jimcase commented Dec 13, 2024

Hey @robingenz, I just created a PR with a solution using serial DispatchQueue(FIFO) to sequentially run the configuration and the start of the session

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bug: Fatal Exception: NSGenericException
3 participants