kevalpatel2106 / android-hidden-camera

This library is to take picture using camera without camera preview.
Apache License 2.0
405 stars 155 forks source link

Running Service using Periodic workmanager, the device hangs after some time #58

Open rohit901 opened 4 years ago

rohit901 commented 4 years ago

My device is ROG Phone 2, (Android 10), and this issue was also observed on other android devices as well, I'm using the work manager class to periodically run this library as a service every 15 minutes.

The photo is captured in the background as desired, and also saved in the cache folder, but the problem is that this works for few photos (say like 15-20), and at one point it suddenly makes my device go in a hanged state, where I can't use my app drawer or any apps as such, but i can open the notification panel.

In the notification panel, I can see that my app is running in background (since I have enabled the foreground notification) and also there is a camera icon on the notification of the app as to denote that my app is using the camera. I can't use my face unlock also during this period to unlock my phone. Refer this image which shows my problem.

IMG-20200519-WA0049

So, to get my device in working state again, I have to reboot my device, but then after rebooting also the work manager starts again, and my app hangs after the toast of "Capturing Image" is displayed. When I tried to connect my device to my laptop and check the logcat, I got this from the logs. https://gist.github.com/rohit901/5bab426e4e9e5e93843ffd1e74450efb

Could someone please help me with this problem. Thank you so much for your time.

rohit901 commented 4 years ago

I have removed Firebase from the app thinking it was causing the problem, but still the problem exists.

rohit901 commented 4 years ago

Sorry for the spam, but after debugging i realized that this hanging of the app is happening whenever i reboot my device and right after the work manager fires the work. I tried to debug the issue and realized that safeToTakePicture variable is false and hence i'm not able to get desired results, so any fixes for this?