Kashif-E / CameraK

A camera library for Compose Multiplatform
MIT License
128 stars 8 forks source link

Scanning the QR code will only emit to Flow when the QR code image is removed from the screen #8

Open adamglin0 opened 4 weeks ago

qq2540040142 commented 3 weeks ago

Android has the same problem

qq2540040142 commented 3 weeks ago

After checking, the problem is Flow.debounce(debounce)

qrScannerPlugin.getQrCodeFlow(debounce = 0)

In the example given, the debounce value is 500, which may cause the latest data to not be sent out in time because it is filtered out. Set it to 0, and now the QR code content can be obtained immediately.

adamglin0 commented 3 weeks ago

After checking, the problem is Flow.debounce(debounce)

qrScannerPlugin.getQrCodeFlow(debounce = 0)

In the example given, the debounce value is 500, which may cause the latest data to not be sent out in time because it is filtered out. Set it to 0, and now the QR code content can be obtained immediately.

Yes, if the QR code remains on the screen, the debounce will continue to be triggered until 500ms after the screen no longer recognizes the QR code.

It would be ideal to add distinctUntilChanged before debounce.

Kashif-E commented 3 weeks ago

@adamglin0 nice idea but this is a different issue on ios and flow issue is a different one. I guess rather then using flow it should be an atomic operation ill look into it more and then update the issue