Closed thnk2wn closed 4 years ago
That issue normally occurs either when:
a) A user attempts to use the camera after the Broadcom library has been unloaded. b) Resources haven't been released cleanly, either due to an issue with the user's code, or the application has been forced to close.
A reboot would usually fix this, but if it's happening reliably in your application then there's something going wrong somewhere.
I believe the AddHostedService
method in your Startup class adds the background service as a Singleton object which is correct for what MMALSharp needs (only one instance of the camera can ever be created at a given time). Does this error start happening after your Dispose method is called in MotionSensorHostedService
? I wonder whether there is an issue bootstrapping the Broadcom library after it's been unloaded?
Thanks again @techyian. Yeah it appeared to happen only after stopping the app then starting it again. This appeared to be this issue: https://github.com/dotnet/extensions/issues/1363 (Hang when calling start/stop on IHost). There was a workaround at the end that appeared to allow proper shutdown. So far I can't reproduce it since.
Excellent, glad you got it fixed!
One more thing I'm noticing while testing. Same code, setup and version as #128. I see this error and then see the warning logged "Buffer null, could not release" every second without stop. Let me know of any ideas of things to check.