Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-20202] Android: Camera.open() can throw a RuntimeException.

GitHub Issuen/a
TypeStory
PriorityCritical
StatusClosed
ResolutionFixed
Resolution Date2016-01-08T03:04:01.000+0000
Affected Version/sn/a
Fix Version/sRelease 5.4.0
ComponentsAndroid
Labelsn/a
ReporterCollin Price
AssigneeAshraf Abu
Created2016-01-06T16:20:18.000+0000
Updated2017-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)

Comments

  1. Collin Price 2016-01-06

    Pull request created: https://github.com/appcelerator/titanium_mobile/pull/7616
  2. Ashraf Abu 2016-01-08

    PR merged.
  3. Stephen Feather 2016-01-10

    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
  4. Ashraf Abu 2016-01-11

    [~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?
  5. Stephen Feather 2016-01-11

    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.
  6. Lee Morris 2017-03-31

    Closing ticket as fixed, if there are any problems, please file a new ticket.

JSON Source