[TIMOB-20202] Android: Camera.open() can throw a RuntimeException.
GitHub Issue | n/a |
---|---|
Type | Story |
Priority | Critical |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2016-01-08T03:04:01.000+0000 |
Affected Version/s | n/a |
Fix Version/s | Release 5.4.0 |
Components | Android |
Labels | n/a |
Reporter | Collin Price |
Assignee | Ashraf Abu |
Created | 2016-01-06T16:20:18.000+0000 |
Updated | 2017-03-31T22:06:44.000+0000 |
Description
Ti SDK 5.1 introduced permission checks on the camera module to prevent showCamera from being called when a user has denied permission but there are other possible scenarios besides permissions. The TiCameraActivity is missing a try catch block around Camera.open().
See Android documentation: http://developer.android.com/reference/android/hardware/Camera.html#open(int)
Pull request created: https://github.com/appcelerator/titanium_mobile/pull/7616
PR merged.
Yup. If the camera on an android device has locked up, the error callback on the js side is never called. ~~~ [WARN] [Nexus 6] CameraBase: An error occurred while connecting to camera: 0 ~~~ Wrapping in a try/catch on the js side doesnt help, as the app dies on the far side of the bridge. Nice fix @collinprice
[~sfeather] Thanks for the information. Is there a way that you are testing to get the camera locked up in order to get that error?
The easiest way has been to use a google branded nexus 6, ProjectFi version of 6.0.1, no January 2016 security patch, you can trigger an error by getting the autofocus to get confused (try to get the lense close enough to an object that the autofocus just tries its darndest to engage). If the app locks up, it usually leaves the camera hardware in an unstable state. Next app to try and grab the hardware will get an error. I'd add, that maybe look into extending Collin's pr, that we be sure the showCamera() error callback be sent back across the bridge to JS so the exception can be handled smoothly there. Power cycling a locked device should clear the hardware.
Closing ticket as fixed, if there are any problems, please file a new ticket.