-
-
Notifications
You must be signed in to change notification settings - Fork 39
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
Possible race condition in CameraManager causing crashes in versions 1.5.9 and above #123
Comments
Hello.
which could be the issue, I can't find any relevant changes. I purposely used custom serial DispatchQueue with DispatchAsync to execute conflicting code serially and aslo get good UI responsivnes, but it looks like either I missed something or something gets executed out of order. Maybe DispatchBarrierAsync would be a solution? |
Hello @afriscic Thanks for your comments. I haven't been able to find a pattern. But it happens without even scanning. Usually when closing the scanner. Now, I'm more inclined to think that the root of the problem is a call to the To debug this, I suggest you make a class that inherits from I'm not sure if the class is sealed, the method allows it with override or new, and this can be done. public class CustomAVCaptureSession : AVCaptureSession
{
public override void StopRunning()
{
Console.WriteLine("Custom StopRunning called");
Console.WriteLine(Environment.StackTrace); // Log the stack trace for debugging
base.StopRunning(); // Call the original implementation
}
} If that is the case, then we will know what we should avoid within the begin/commit. |
My wild guess is that it happens on disposing. I'll try to push an update to change the code to |
Perfect, that's a good strategy! The barrier can help ensure the stop doesn't occur in the middle. I'll keep an eye on it. |
Hey All, just found the following error occured for one of our users on an iPhone XR (BarcodeScanning.Native.Maui 1.7.3):
i suspect this might be caused by the same underlying issue. |
With version 1.5.7 in production we do not have the following issue. However, after upgrading to later versions we started experiencing intermittent crashes, typical of race conditions. This may already be known and being fixed (perhaps it has already been fixed in development), but I am reporting it here anyway.
Affected Versions:
Platform
Steps to Reproduce:
Important
Race conditions are difficult to reproduce
Temporary Workaround:
Logs
Suspicions
There are two potential causes for this issue:
Design or Implementation Issue:
Stop
within theCameraManager
class, such as from theUpdateCameraEnabled
method or other internal logic, might interfere with ongoingbeginConfiguration
andcommitConfiguration
blocks. This could result from a design oversight whereStop
is enqueued at a point where it disrupts the configuration flow.Implicit
stopRunning
Invocations by the SDK:CameraManager
class may trigger the SDK to implicitly callstopRunning
on theAVCaptureSession
. Potential points include:RemoveInput
andAddInput
in theUpdateCamera
method.SessionPreset
property inUpdateResolution
._previewLayer
, such as removing it from its superlayer.stopRunning
, which could interfere with abeginConfiguration
block.Both possibilities should be investigated to determine whether the issue lies in the design or the behavior of the SDK.
Recommendation
It is highly recommended to review the changes made to the
CameraManager
class, specifically the fileBarcodeScanning.Native.Maui/Platform/MaciOS/CameraManager.cs
, between versions 1.5.7 and the latest affected version. This review may shed light on the root cause of this issue, whether it stems from changes in the design or implementation of the class, or from interactions with the SDK's internal behavior.The text was updated successfully, but these errors were encountered: