janusw / Camera.Maui

A CameraView Control for .NET Maui
MIT License
17 stars 3 forks source link

Sometimes StartCameraAsync blocks the UI #12

Open LBoullosa opened 4 months ago

LBoullosa commented 4 months ago

Hi janusw,

First of all, Thanks about forking and let us have a more recent version for this library.

In my view I have an ActivityIndicator to show the progress about initializing the Camera. Sometimes this ActivityIndicator freezes and the UI blocks. I noticed this happens when the startCameraAsync is call from the MainThreadBeginInvoke.

Do you have something in mind how to solved in the library? I saw an ugly way in the library to wait....

image

Thanks in advance,

janusw commented 3 months ago

Can you tell us on which OS you see this problem? I assume it's Android (since the code in your screenshot is Android-specific), right?

janusw commented 3 months ago

Do you have something in mind how to solved in the library? I saw an ugly way in the library to wait....

I guess a clean way to get rid of this (admittedly ugly) Sleep call would be to use a SurfaceTextureListener ...

punxrok commented 3 months ago

Hi, I have the same problem while running on iOS. Basically, it seems that the StartCameraAsync is "blocking" the UI thread. If I'm lucky, after 10 clicks on the button and waiting for 15 seconds, the button action triggers. The only viable solution is to find a code and successfully scan it. After the StopCameraAsync completes, the collection of previously blocked UI events starts to fire all over the code.

Related issues for the "base" library: https://github.com/hjam40/Camera.MAUI/issues/50 https://github.com/hjam40/Camera.MAUI/issues/94