Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-7401] Android: Titanium.Media.switchCamera() fails to switch camera and locks app on camera exit

GitHub Issuen/a
TypeBug
PriorityMedium
StatusClosed
ResolutionFixed
Resolution Date2014-05-28T16:08:52.000+0000
Affected Version/sRelease 1.8.1
Fix Version/s2013 Sprint 17, 2013 Sprint 17 API, Release 3.2.0
ComponentsAndroid
Labelscore, module_media, qe-and012312, qe-manualtest, qe-nfc
ReporterDustin Hyde
AssigneeBill Dawson
Created2012-01-25T14:04:49.000+0000
Updated2014-08-07T23:19:52.000+0000

Description

Titanium.Media.switchCamera() fails to load the front-facing camera, and locks the app with a slightly darker screen when the user exits the camera. Log Attached. This behavior occurs on the Galaxy Nexus 4.0.2. When run on the G-Slate 3.1, a runtime error is generated indicating 'switchCamera' does not exist. Ti.Media.switchCamera() did not exist in 1.8.0.1. for either device. This method is also undocumented. Steps to Reproduce: 1. Run Code:
// create window with vertical layout
var win = Ti.UI.createWindow();
win.backgroundColor = 'white';
win.layout = 'vertical';

// create button, register the modified click callback, add button to window
function addButton(title, clickCallback)
{
	var button = Ti.UI.createButton({title:title, width:'300', height:'50'});
	
	button.addEventListener('click', function() {
		Ti.Media.showCamera({mediaType:Ti.Media.MEDIA_TYPE_PHOTO});
		clickCallback();
		Ti.Media.vibrate();
		});
		
	win.add(button);
}

// camera with no switch
addButton('Default Camera', function(){
	
});

// camera with front specified
addButton('Front Camera Test 1', function(){
	Ti.Media.switchCamera(Ti.Media.CAMERA_FRONT);
});

// camera with front specified after switching to back
// checks if switch function actually works, opposed to it being the default
addButton('Front Camera Test 2', function(){
	Ti.Media.switchCamera(Ti.Media.CAMERA_BACK);
	Ti.Media.switchCamera(Ti.Media.CAMERA_FRONT);
});

// camera with back specified
addButton('Back Camera Test 1', function(){
	Ti.Media.switchCamera(Ti.Media.CAMERA_BACK);
});

// camera with back specified after switching to front
// checks if switch function actually works, opposed to it being the default
addButton('Back Camera Test 2', function(){
	Ti.Media.switchCamera(Ti.Media.CAMERA_FRONT);
	Ti.Media.switchCamera(Ti.Media.CAMERA_BACK);
});

// camera passed invalid (non-existent) argument
addButton('Invalid Camera', function(){
	Ti.Media.switchCamera(undefined);
});

// open window
win.open();
2. Click 'Front Camera Test 1'. Expected Result: The front (facing the user, showing their face on the screen) camera should load. Actual Result: The back camera loads. 3. Exit the camera (i.e., 'cancel', 'x'). Expected Result: App should resume. Actual result: App screen darkens and app locks up. Errors printed to the console. Note: This test code already exists in /titanium_mobile_tests_internal/FeatureTest/Media/module_media > TIMOB-3136. Note: Will test other devices for this behavior in future.

Attachments

FileDateSize
app.js2013-08-08T21:24:33.000+00003323
Ti.Media.switchCamera() android.txt2012-01-25T14:04:49.000+000014998

Comments

  1. Sitara Shylaja 2012-02-13

    Bugs still occurs on Titanium SDK version: 1.9.0.v20120207171634 Javascript Engine: Rhino Device Details: HTC phone(Android 2.3.4), Titanium Studio version: 1.0.8.201201262211
  2. Tamila Smolich 2012-02-13

    Also exists on devices: Android 3.1/LG-V909; Android 4.0.2/Galaxy Nexus Titanium SDK version: 1.9.0.v20120207171634 Javascript Engine: Rhino Titanium Studio version: 1.0.8.201201262211
  3. Shyam Bhadauria 2012-06-05

    This bug still occurs on android 2.2 also Tested with Titanium SDK: 2.1.0.v20120604151821 Tested with Titanium Studio: 2.1.0.201206010843 Android Runtimes: V8 OS: Windows 7 Devices Tested: Android 2.2
  4. Aaron K. Saunders 2012-10-15

    are there any work arounds for this issue?
  5. Allen Yeung 2013-02-26

    This ticket is not a bug. The API is undocumented, and is only implemented in iOS at this point. Since we launch the built in camera app via an intent, there is no way for us to launch it with the front facing camera enabled. There is a hack of putting the
       intent.putExtra("android.intent.extras.CAMERA_FACING", 1);
       
    however, this is used in native android for testing purposes only, and should not be relied on. Unfortunately, there is not a quick fix for this issue in titanium, unless we decide to rewrite the camera API to not use intents. There is actually a google bug to expose this feature legitimately, but it doesn't seem to be implemented: https://code.google.com/p/android/issues/detail?id=13724 Normally when you show the camera, the user can just switch to the front facing camera anyways via the UI for the camera app. If you really wanted a quick fix for this, the solution would be to create a module that launches the front facing camera.
  6. Bill Dawson 2013-08-09

    Testing Notes

    * Use the attached app.js with a device that has both front and rear cameras. * When the app launches, you should see (in the large label at the bottom of the window) information about the cameras that were discovered. Make sure this info is correct. * Click the Show Camera button. * When the camera preview appears, click Snap to take a photo. You'll be taken back to the app's main window and the log should show you the size of the image it captured. * Click the Show Camera button again. * When the camera preview appears, click Switch to switch the camera. * When the switched camera preview appears, click Snap to take a photo. You'll be taken back to the app's main window and the log should show you the size of the image it captured. * Exit out of the app. * Open the Gallery app and you should see the two photos you took.
  7. Bill Dawson 2013-08-09

    PR ready: https://github.com/appcelerator/titanium_mobile/pull/4566
  8. Michael Gangolf 2013-10-04

    camera switching and taking picture is working (Nexus 4, 4.3, SDK 3.2.0 09.04.) but the images are distorted. Here is a log {noformat} 10-04 21:54:42.630: I/ActivityManager(528): START u0 {cmp=com.m.test2/ti.modules.titanium.media.TiCameraActivity} from pid 11334 10-04 21:54:42.780: I/AwesomePlayer(176): setDataSource_l(URL suppressed) 10-04 21:54:42.820: I/AwesomePlayer(176): setDataSource_l(URL suppressed) 10-04 21:54:42.860: I/CameraClient(176): Opening camera 0 10-04 21:54:42.930: E/qcom_sensors_hal(528): hal_process_report_ind: Bad item quality: 11 10-04 21:54:42.950: E/mm-camera(216): sensor_load_chromatix: libchromatix_imx111_preview.so: 30 10-04 21:54:43.060: E/mm-camera(216): vfe_ops_init: E 10-04 21:54:43.060: E/mm-camera(216): vfe_legacy_stats_buffer_init: AEC_STATS_BUFNUM 10-04 21:54:43.060: E/mm-camera(216): vfe_legacy_stats_buffer_init: AEC_STATS_BUFNUM 10-04 21:54:43.070: E/mm-camera(216): mctl_init_stats_proc_info: snap_max_line_cnt =30096 10-04 21:54:43.100: V/PhoneStatusBar(659): setLightsOn(true) 10-04 21:54:43.140: E/QCameraHWI(176): android::status_t android::QCameraHardwareInterface::setPreviewWindow(preview_stream_ops_t*): mPreviewWindow = 0x0xb7e8ac48, mStreamDisplay = 0x0xb7e9ffb0 10-04 21:54:43.140: D/QCameraHWI(176): android::status_t android::QCameraHardwareInterface::startPreview(): start preview now 10-04 21:54:43.140: I/QCameraHWI(176): android::status_t android::QCameraHardwareInterface::startPreview2():Setting ZSL mode 10-04 21:54:43.140: E/mm-camera(216): config_proc_CAMERA_SET_INFORM_STARTPREVIEW 10-04 21:54:43.140: E/mm-camera(216): config_proc_CAMERA_SET_INFORM_STARTPREVIEW : AF_SET_INFORM_STARTPREVIEW! 10-04 21:54:43.150: E/mm-camera(216): config_update_stream_info Storing stream parameters for video inst 1 as : width = 1280, height 720, format = 1 inst_handle = 810081 cid = 0 10-04 21:54:43.180: E/mm-camera(216): config_update_stream_info Storing stream parameters for video inst 3 as : width = 640, height 480, format = 1 inst_handle = 830083 cid = 0 10-04 21:54:43.180: E/mm-camera(216): config_update_stream_info Storing stream parameters for video inst 4 as : width = 512, height 384, format = 1 inst_handle = 840084 cid = 0 10-04 21:54:43.190: E/mm-camera(216): config_decide_vfe_outputs: Ports Used 3, Op mode 1 10-04 21:54:43.190: E/mm-camera(216): config_decide_vfe_outputs Current mode 0 Full size streaming : Disabled 10-04 21:54:43.190: E/mm-camera(216): config_decide_vfe_outputs: Primary: 1280x720, extra_pad: 0x0, Fmt: 1, Type: 1, Path: 1 10-04 21:54:43.190: E/mm-camera(216): config_decide_vfe_outputs: Secondary: 640x480, extra_pad: 0x0, Fmt: 1, Type: 3, Path: 4 10-04 21:54:43.190: E/mm-camera(216): config_update_inst_handles Updated the inst handles as 810081, 830083, 0, 0 10-04 21:54:43.331: E/mm-camera(216): sensor_load_chromatix: libchromatix_imx111_zsl.so: 26 10-04 21:54:43.421: E/mm-camera(216): camif_client_set_params: camif has associated with obj mask 0x1 10-04 21:54:43.421: E/mm-camera(216): config_v2_CAMERA_START_common CAMIF_PARAMS_ADD_OBJ_ID failed -1 10-04 21:54:43.421: E/mm-camera(216): vfe_operation_config: format 3 10-04 21:54:43.421: E/mm-camera(216): vfe_operation_config:vfe_op_mode=5 10-04 21:54:43.421: E/mm-camera(216): Invalid ASD Set Params Type 10-04 21:54:43.421: E/mm-camera(216): vfe_set_bestshot: Bestshot mode not changed 10-04 21:54:43.481: E/mm-libcamera2(176): PROFILE HAL: First preview frame received: 1380916483.495783494 10-04 21:54:43.481: E/QCameraHWI_Preview(176): processPreviewFrameWithDisplay: buffer to be enqueued is not locked 10-04 21:54:43.521: I/ActivityManager(528): Displayed com.m.test2/ti.modules.titanium.media.TiCameraActivity: +880ms 10-04 21:54:43.571: E/QCameraHWI_Preview(176): processPreviewFrameWithDisplay: buffer to be enqueued is not locked 10-04 21:54:48.606: E/mm-camera(216): PROFILE set_parm_AF: : 1380916488.609960206 10-04 21:54:48.606: E/mm-camera(216): af_lg_caf_status 1, af_lg_caf_fv_status 2, first_af 0 10-04 21:54:48.606: E/mm-camera(216): NO ADDITIONAL af HERE! 10-04 21:54:48.606: E/mm-camera(216): config_proc_CAMERA_SET_LG_CAF_LOCK : TAKE PICTURE! 10-04 21:54:48.686: E/mm-libcamera2(176): mm_camera_dispatch_buffered_frames: mframe 0x0, sframe = 0x0 10-04 21:54:48.826: D/morpho_NoiseReduction_Version(176): = Morpho Denoiser for LGE mako Ver.1.0.3 2012/10/23 10-04 21:54:48.826: D/morpho_NoiseReduction_getBufferSize =(176): 195292 10-04 21:54:48.826: D/morpho_NoiseReduction_getBufferSize buffer malloc =(176): b7ee0fd8 10-04 21:54:48.826: D/morpho_NoiseReduction_initialize(176): EngineVersion= Morpho Denoiser for LGE mako Ver.1.0.3 2012/10/23 10-04 21:54:48.826: D/Version info :(176): Morpho Denoiser for LGE mako Ver.1.0.3 2012/10/23 10-04 21:54:48.826: D/morpho_NoiseReduction_initialize ret =(176): 0 10-04 21:54:48.826: D/morpho_NoiseReduction_initialize IMAGE_FORMAT =(176): YVU420_SEMIPLANAR 10-04 21:54:48.826: D/morpho_NoiseReduction_setLumaNoiseReductionLevel y_level for LGE =(176): 0 10-04 21:54:48.826: D/morpho_NoiseReduction_setChromaNoiseReductionLevel c_level =(176): 1 10-04 21:54:48.826: D/morpho_NoiseReduction_setRemoveSpikeNoise SpikeNoise =(176): 1 10-04 21:54:48.826: D/morpho_NoiseReduction allocateImage c_level =(176): 0 10-04 21:54:48.826: D/morpho_NoiseReduction_start ret =(176): 0 10-04 21:54:48.886: D/morpho_NoiseReduction_reduceNoise ret =(176): 0 10-04 21:54:48.886: D/morpho_NoiseReduction_finalize ret =(176): 0 10-04 21:54:48.896: E/mm-camera-DENOISE(216): wavelet_denoise_process: Wavelet Denoise Success 10-04 21:54:48.896: D/audio_hw_primary(176): out_set_parameters: enter: usecase(1: low-latency-playback) kvpairs: routing=2 10-04 21:54:48.896: D/audio_hw_primary(176): out_set_parameters: exit: code(1) 10-04 21:54:48.896: D/audio_hw_primary(176): start_output_stream: enter: usecase(1: low-latency-playback) devices(0x2) 10-04 21:54:48.896: D/audio_hw_primary(176): select_devices: out_snd_device(2: speaker) in_snd_device(0: none) 10-04 21:54:48.896: D/audio_hw_primary(176): enable_snd_device: sending audio calibration for snd_device(2) acdb_id(14) 10-04 21:54:48.896: D/ACDB-LOADER(176): ACDB -> send_afe_cal 10-04 21:54:48.896: D/audio_hw_primary(176): enable_snd_device: snd_device(2: speaker) 10-04 21:54:48.906: D/audio_hw_primary(176): enable_audio_route: apply mixer path: low-latency-playback 10-04 21:54:48.916: E/mm-camera-DENOISE(216): wavelet_denoise_process: Wavelet Denoise Success 10-04 21:54:48.916: D/audio_hw_primary(176): start_output_stream: exit 10-04 21:54:48.947: D/MediaScannerReceiver(18324): action: android.intent.action.MEDIA_SCANNER_SCAN_FILE path: /storage/emulated/0/Pictures/test2/tia-976860953.jpg 10-04 21:54:48.967: E/mm-libcamera2(176): PROFILE HAL: stopPreview(): E: 1380916488.973305238 10-04 21:54:48.967: E/mm-camera(216): config_MSG_ID_STOP_ACK: streamon_mask is not clear. Should not call PP_Release_HW 10-04 21:54:48.977: V/PhoneStatusBar(659): setLightsOn(true) 10-04 21:54:48.977: E/mm-libcamera2(176): PROFILE HAL: stopPreview(): E: 1380916488.984353612 10-04 21:54:48.977: E/QCameraHWI(176): android::status_t android::QCameraHardwareInterface::setPreviewWindow(preview_stream_ops_t*):Received Setting NULL preview window 10-04 21:54:48.977: E/QCameraHWI(176): android::status_t android::QCameraHardwareInterface::setPreviewWindow(preview_stream_ops_t*): mPreviewWindow = 0x0x0, mStreamDisplay = 0x0xb7e9ffb0 10-04 21:54:48.977: W/QCameraHWI_Preview(176): Setting NULL preview window 10-04 21:54:48.977: I/CameraClient(176): Destroying camera 0 10-04 21:54:48.977: E/mm-camera(216): config_shutdown_pp Camera not in streaming mode. Returning. 10-04 21:54:48.987: E/mm-camera(216): vfe_ops_deinit: E 10-04 21:54:49.037: E/qcom_sensors_hal(528): hal_process_report_ind: Bad item quality: 11 10-04 21:54:49.057: W/AudioFlinger(176): session id 278 not found for pid 176 10-04 21:54:49.057: W/AudioFlinger(176): session id 279 not found for pid 176 {noformat}
  9. Lokesh Choudhary 2013-10-23

    Verified the fix. The Titanium.Media.switchCamera() switches camera and does not lock app on camera exit. Thus closing. Environment: Appcel Studio : 3.2.0.201310230601 Ti SDK : 3.2.0.v20131022171645 Mac OSX : 10.8.5 CLI - 3.2.0 with hash 72f7426b4ee6c2d2883c666d5b7e03906a16012f Device: Samsung Galaxy S4 running android 4.2.2, sony experia running android 2.3.7
  10. Stevo Perisic 2013-11-12

    What is Ti SDK 3.2.0.v20131022171645, and when is it going to be available?
  11. Michael Gangolf 2013-11-12

  12. Stevo Perisic 2013-11-12

    @ Michael G - do you recommend updating to the 3.2.*?
  13. Dustin Hyde 2013-11-12

    http://builds.appcelerator.com.s3.amazonaws.com/index.html#master 3_2_X is a test branch, use with discretion.

JSON Source