StickerCamera
StickerCamera copied to clipboard
Hang problem in CameraActivity
Dear StickerCamera Developers, I am implementing a hang-bug detection tool and I am analyzing StickerCamera (master version downloaded today) with it. I found that the main thread of StickerCamera, frequently calls:
com.stickercamera.app.camera.ui.CameraActivity$SurfaceCallback.surfaceCreated
at line 422 which correspond to:
android.hardware.Camera.open
and frequently calls:
com.stickercamera.app.camera.ui.CameraActivity.initCamera
at code line 492, which correspond to
android.hardware.Camera.startPreview.
In my experiments, the execution of those functions on the main thread may be the main cause of the eye-detectable delays (i.e., hang-bug) experienced with StickerCamera while taking pictures.
Moving work off the main thread leads to higher responsiveness of the app.The android development guide in the explanation of the "android.hardware.Camera.open" method, suggests indeed "Caution: On some devices, this method may take a long time to complete. It is best to call this method from a worker thread (possibly using AsyncTask) to avoid blocking the main application UI thread." Also, startPreview could probably be moved off the main thread to improve responsiveness of the app.
Do you think that it is possible to move off the main thread those functions to improve responsiveness?
Did you know about these two problems with your code?
Thanks for any information, I hope I can help improve StickerCamera.
Thank you for your reporting,There are some problems with StickerCamera in camera feature,If you can fix this,please send me a pull request,Thanks!
Hi, sorry for the late reply. I will try to fix those problems soon and send you a pull request accordingly.
In the meaning time, I have found also another possible cause of hang-bugs. In particular, the following API is frequently called by the main thread while using StickerCamera:
com.common.util.ImageUtils.decodeBitmapWithSize(ImageUtils.java:130)->android.graphics.BitmapFactory.decodeFile
I think that also in this case we can fix the hang-bug by moving this API execution to a background task. What do you think?
Thanks for any information, I hope to help improving StickerCamera