It would be easy to repeat the problem when I use an old device, which takes 1-2 secs to finish taking a picture.
So when I press HOME button, while the device is taking picture, often times it freezes at the preview picture. I have added camera stopPreview and release in onPause(), which will be called when HOME button is pressed. >From the LogCat, I find that the camera hardware is still processing some information, but Activity Manager kicks in, saying something about HOME activity. So I think HOME forces some camera procedure finished in a bad way, which makes the camera preview freezes, and the camera cannot be opened any more (e.g. when I try to open the default camera, it says it cannot access to camera) However, if I use the default camera of the old slow device :), I cannot repeat the crash. So it seems the default camera application might handle it well; it might access native libraries to handle the situation, or something else. If I use Nexus 4 device, it is very hard to repeat this experiment. A less powerful device is needed to repeat the experiment. [UPDATE] I put the Logcat at the end of the post (it is long). Here is a brief review. After click the capture button, 07-25 14:20:08.517: I/Camera Preview(1517): For Debug: begin mCamera.takePicture Then I press the HOME button, the log below shows that android.intent.action.MAIN kicks in. 07-25 14:20:08.867: I/ActivityManager(188): Starting activity: Intent { act=android.intent.action.MAIN cat=[android.intent.category.HOME] flg=0x10200000 cmp=com.htc.launcher/.Launcher } from pid 188 07-25 14:20:09.337: I/Camera Preview(1517): For Debug: after mCamera.takePicture 07-25 14:20:09.337: I/CameraActivity(1517): For Debug: in onPause(); Regarding how to process in onPause, which will be callsed by HOME button, I tried two options. One option is that onPause releases the camera. Another option is, I put Thread.sleep(1500) to let my activity has enough time to finish something. But with either option, the camear crashes, and cannot be launched any more. ******************************* Long logcat: 07-25 14:20:07.736: I/Camera Preview(1517): For Debug: begin: mCamera.autoFocus(mContinuousAutoFocusCallback); 07-25 14:20:07.736: I/Camera Preview(1517): For Debug: Unexpected exception while doing continuous focusingjava.lang.NullPointerException 07-25 14:20:07.766: I/Camera Preview(1517): For Debug: onClick mCamera.autoFocus and take a picture 07-25 14:20:07.766: D/CameraService(70): autoFocus (pid 1517) 07-25 14:20:07.766: D/QualcommCameraHardware(70): autoFocus E 07-25 14:20:07.766: D/QualcommCameraHardware(70): autoFocus X 07-25 14:20:07.766: D/QualcommCameraHardware(70): runAutoFocus E 07-25 14:20:07.766: D/QualcommCameraHardware(70): af start (fd 39) 07-25 14:20:07.766: I/mm-camera 8x vfe(70): ch=971 cw=1619 vof=485 hof=809 wh=485 ww=809 07-25 14:20:07.916: D/WifiStateTracker(188): Reset connections and stopping DHCP 07-25 14:20:07.916: I/wpa_supplicant(487): Rx Data Filter Remove [5] command 07-25 14:20:07.916: I/wpa_supplicant(487): auto ip disabled 07-25 14:20:07.916: I/wpa_supplicant(487): Rx Data Filter: do not support, ignore 07-25 14:20:07.926: D/NetUtils(188): ifc_get_info addr=0 ! 07-25 14:20:08.497: D/mm-camera af_core(70): af_beta is executing!! 07-25 14:20:08.517: D/QualcommCameraHardware(70): native_set_afmode: ctrlCmd.status == 2 07-25 14:20:08.517: D/QualcommCameraHardware(70): af done: 0 07-25 14:20:08.517: D/CameraService(70): focus lenPos 0 status 0 macro_threshold 10 07-25 14:20:08.517: D/CameraService(70): CameraService::Client::handleGenericNotify: msgType = CAMERA_MSG_FOCUS 07-25 14:20:08.517: D/CameraService(70): CameraService::Client::handleGenericNotify: callback 07-25 14:20:08.517: I/Camera Preview(1517): For Debug: onClick mCamera.autoFocus, onAutoFocus: want to know the time difference 07-25 14:20:08.517: I/Camera Preview(1517): For Debug: begin mCamera.takePicture 07-25 14:20:08.517: D/QualcommCameraHardware(70): runAutoFocus X 07-25 14:20:08.517: D/CameraService(70): setPreviewCallbackFlag(0) (pid 1517) 07-25 14:20:08.517: D/CameraService(70): takePicture (pid 1517) 07-25 14:20:08.517: D/QualcommCameraHardware(70): takePicture(463) 07-25 14:20:08.517: D/QualcommCameraHardware(70): val_ril_status = 0,val_wimax_status = 0,val_hotspot_status = 0,val_low_temp_limit = 10.000000,val_batt_temp = 36.500000,val_low_temp_limit = 15,val_batt_cap = 79 07-25 14:20:08.517: D/QualcommCameraHardware(70): FLASHLIGHT is ENABLED 07-25 14:20:08.517: E/mm-camera-af(70): af_algo_preview: FAILED.... 07-25 14:20:08.867: I/ActivityManager(188): Starting activity: Intent { act=android.intent.action.MAIN cat=[android.intent.category.HOME] flg=0x10200000 cmp=com.htc.launcher/.Launcher } from pid 188 07-25 14:20:08.927: D/WifiStateTracker(188): Disabling interface 07-25 14:20:08.927: W/wpa_supplicant(487): l2_packet_receive - recvfrom 07-25 14:20:08.977: D/NetSharing_NSReceiver(544): onReceive : android.net.wifi.STATE_CHANGE 07-25 14:20:08.977: I/NetSharing_NSReceiver(544): wifienabled:false 07-25 14:20:09.267: D/QualcommCameraHardware(70): stopPreviewInternal E: 1 07-25 14:20:09.267: D/QualcommCameraHardware(70): cancelAutoFocusInternal E 07-25 14:20:09.267: D/QualcommCameraHardware(70): cancelAutoFocusInternal X: 0 07-25 14:20:09.327: I/QualcommCameraHardware(70): deinitPreview E 07-25 14:20:09.327: I/QualcommCameraHardware(70): register_buf: camfd = 32, reg = 1 buffer = 0x41121000 07-25 14:20:09.327: I/QualcommCameraHardware(70): register_buf: camfd = 32, reg = 1 buffer = 0x41221000 07-25 14:20:09.327: I/QualcommCameraHardware(70): register_buf: camfd = 32, reg = 1 buffer = 0x41321000 07-25 14:20:09.327: I/QualcommCameraHardware(70): register_buf: camfd = 32, reg = 1 buffer = 0x41421000 07-25 14:20:09.327: I/QualcommCameraHardware(70): register_buf: camfd = 35, reg = 1 buffer = 0x41521000 07-25 14:20:09.327: I/QualcommCameraHardware(70): register_buf: camfd = 35, reg = 1 buffer = 0x41621000 07-25 14:20:09.327: I/QualcommCameraHardware(70): register_buf: camfd = 35, reg = 1 buffer = 0x41721000 07-25 14:20:09.327: I/QualcommCameraHardware(70): register_buf: camfd = 35, reg = 1 buffer = 0x41821000 07-25 14:20:09.327: I/QualcommCameraHardware(70): register_buf: camfd = 35, reg = 1 buffer = 0x41921000 07-25 14:20:09.327: I/QualcommCameraHardware(70): register_buf: camfd = 35, reg = 1 buffer = 0x41a21000 07-25 14:20:09.327: I/QualcommCameraHardware(70): register_buf: camfd = 35, reg = 1 buffer = 0x41b21000 07-25 14:20:09.327: I/QualcommCameraHardware(70): register_buf: camfd = 35, reg = 1 buffer = 0x41c21000 07-25 14:20:09.327: D/QualcommCameraHardware(70): frame_thread X 07-25 14:20:09.327: I/QualcommCameraHardware(70): deinitPreview X 07-25 14:20:09.327: D/QualcommCameraHardware(70): stopPreviewInternal X: 0 07-25 14:20:09.327: D/QualcommCameraHardware(70): initRaw: mFrameThreadWaitLock.lock() 07-25 14:20:09.327: D/QualcommCameraHardware(70): initRaw: mFrameThreadWaitLock.unlock() 07-25 14:20:09.327: D/QualcommCameraHardware(70): initRaw E: raw size=3264x2448 07-25 14:20:09.327: D/QualcommCameraHardware(70): initRaw: original raw ratio = 0.750000 07-25 14:20:09.327: D/QualcommCameraHardware(70): initRaw: raw ratio = 0.750000, display size=800x480 07-25 14:20:09.327: D/QualcommCameraHardware(70): initRaw: thumbnail_width=800, thumbnail_height=608, thumbnail_buffer_size=729600 07-25 14:20:09.327: D/QualcommCameraHardware(70): native_access_parm: fd 15, type 1, length 32 07-25 14:20:09.327: D/mm-camera-ov8810_u(70): cam_mode_sel 0 07-25 14:20:09.327: D/QualcommCameraHardware(70): initRaw: initializing mRawHeap. 07-25 14:20:09.327: E/MemoryHeapBase(70): error opening /dev/pmem_camera: No such file or directory 07-25 14:20:09.327: W/QualcommCameraHardware(70): failed to construct master heap for pmem pool /dev/pmem_camera 07-25 14:20:09.327: W/QualcommCameraHardware(70): initRaw X failed with pmem_camera, trying with pmem_adsp 07-25 14:20:09.327: I/QualcommCameraHardware(70): pmem pool /dev/pmem_adsp ioctl(fd = 37, PMEM_GET_SIZE) is 16777216 07-25 14:20:09.327: D/QualcommCameraHardware(70): mBufferSize=11985408, mAlignedBufferSize=11988992 07-25 14:20:09.327: E/QualcommCameraHardware(70): num_buffers = 1 07-25 14:20:09.327: I/QualcommCameraHardware(70): register_buf: camfd = 35, reg = 0 buffer = 0x4227f000 07-25 14:20:09.327: D/QualcommCameraHardware(70): do_mmap snapshot pbuf = 0x4227f000, pmem_fd = 37 07-25 14:20:09.327: D/QualcommCameraHardware(70): initRaw: initializing mJpegHeap. 07-25 14:20:09.337: I/QualcommCameraHardware(70): pmem pool /dev/pmem_adsp ioctl(fd = 40, PMEM_GET_SIZE) is 1048576 07-25 14:20:09.337: D/QualcommCameraHardware(70): mBufferSize=729600, mAlignedBufferSize=1048576 07-25 14:20:09.337: E/QualcommCameraHardware(70): num_buffers = 1 07-25 14:20:09.337: I/QualcommCameraHardware(70): register_buf: camfd = 38, reg = 0 buffer = 0x41521000 07-25 14:20:09.337: D/QualcommCameraHardware(70): initRaw X 07-25 14:20:09.337: I/Camera Preview(1517): For Debug: after mCamera.takePicture 07-25 14:20:09.337: I/CameraActivity(1517): For Debug: in onPause(); before Thread.sleep(1500) 07-25 14:20:09.337: I/CameraActivity(1517): For Debug: mPreview.mCameraTakePictureTF: true 07-25 14:20:09.337: I/CameraActivity(1517): For Debug: in onPause(); before Thread.sleep(1500) 07-25 14:20:09.337: D/QualcommCameraHardware(70): snapshot_thread E 07-25 14:20:09.367: D/QualcommCameraHardware(70): receiveRawPicture: E 07-25 14:20:09.377: W/ActivityManager(188): Activity pause timeout for HistoryRecord{409ff310 com.barclays.common.howtoMoreFun/com.barclays.common.howto.ui.screens.camera.CameraActivity} 07-25 14:20:09.388: D/mm-camera 8x-vfe snapshot(70): VFE_CAMIFCfgCmd.camifConfig.vSyncEdge 0 07-25 14:20:09.388: D/mm-camera 8x-vfe snapshot(70): VFE_CAMIFCfgCmd.camifConfig.hSyncEdge 0 07-25 14:20:09.388: D/mm-camera 8x-vfe snapshot(70): VFE_CAMIFCfgCmd.camifConfig.syncMode 0 07-25 14:20:09.388: D/mm-camera 8x-vfe snapshot(70): VFE_CAMIFCfgCmd.camifConfig.vfeSubSampleEnable 0 07-25 14:20:09.388: D/mm-camera 8x-vfe snapshot(70): VFE_CAMIFCfgCmd.camifConfig.busSubSampleEnable 0 07-25 14:20:09.388: D/mm-camera 8x-vfe snapshot(70): VFE_CAMIFCfgCmd.camifConfig.irqSubSampleEnable 0 07-25 14:20:09.388: D/mm-camera 8x-vfe snapshot(70): VFE_CAMIFCfgCmd.camifConfig.binningEnable 0 07-25 14:20:09.388: D/mm-camera 8x-vfe snapshot(70): VFE_CAMIFCfgCmd.camifConfig.misrEnable 0 07-25 14:20:09.388: D/mm-camera 8x-vfe snapshot(70): VFE_CAMIFCfgCmd.EFS.efsEndOfLine 0 07-25 14:20:09.388: D/mm-camera 8x-vfe snapshot(70): VFE_CAMIFCfgCmd.EFS.efsStartOfLine 0 07-25 14:20:09.388: D/mm-camera 8x-vfe snapshot(70): VFE_CAMIFCfgCmd.EFS.efsEndOfFrame 0 07-25 14:20:09.388: D/mm-camera 8x-vfe snapshot(70): VFE_CAMIFCfgCmd.EFS.efsStartOfFrame 0 07-25 14:20:09.388: D/mm-camera 8x-vfe snapshot(70): VFE_CAMIFCfgCmd.window.firstPixel 0 07-25 14:20:09.388: D/mm-camera 8x-vfe snapshot(70): VFE_CAMIFCfgCmd.window.lastPixel 3279 07-25 14:20:09.388: D/mm-camera 8x-vfe snapshot(70): VFE_CAMIFCfgCmd.window.firstLine 0 07-25 14:20:09.388: D/mm-camera 8x-vfe snapshot(70): VFE_CAMIFCfgCmd.window.lastLine 2455 07-25 14:20:09.388: D/mm-camera 8x-vfe snapshot(70): VFE_CAMIFCfgCmd.frame.pixelsPerLine 3280 07-25 14:20:09.388: D/mm-camera 8x-vfe snapshot(70): VFE_CAMIFCfgCmd.frame.linesPerFrame 2456 07-25 14:20:09.388: D/mm-camera 8x-vfe snapshot(70): VFE_CAMIFCfgCmd.subsample.pixelSkipMask 65535 07-25 14:20:09.388: D/mm-camera 8x-vfe snapshot(70): VFE_CAMIFCfgCmd.subsample.lineSkipMask 65535 07-25 14:20:09.388: D/mm-camera 8x-vfe snapshot(70): VFE_CAMIFCfgCmd.subsample.frameSkip 0 07-25 14:20:09.388: D/mm-camera 8x-vfe snapshot(70): VFE_CAMIFCfgCmd.subsample.frameSkipMode 0 07-25 14:20:09.398: D/mm-camera 8x-vfe snapshot(70): VFE_CAMIFCfgCmd.subsample.pixelSkipWrap 0 07-25 14:20:09.398: E/mm-camera 8x vfe(70): vfe_util_updaterollofftbl: sensor doesn't support rolloff correction by VFE 07-25 14:20:09.398: W/mm-camera-zoom(70): Output1 and Output2 aspect ratios differ. Frames may be distorted 07-25 14:20:09.398: D/mm-camera-ov8810_u(70): ov8810_set_snapshot_exposure_gain led_active = 0 07-25 14:20:09.398: D/mm-camera-ov8810_u(70): ov8810_set_snapshot_exposure_gain snapshot_config_ptr->antibanding 1, snapshot: gain 48 linecount 2496 07-25 14:20:09.398: D/mm-camera-ov8810_u(70): ov8810_set_snapshot_exposure_gain snapshot_linesPerFrame 2500 snapshot_fps 2472.434608 snapshot_exposuretime 0.103376 07-25 14:20:09.398: D/mm-camera-ov8810_u(70): Anti-banding 60Hz, new exp_time (ms) = 0.100000, no antiband exp_time = 0.103376 07-25 14:20:09.398: D/mm-camera-ov8810_u(70): actual snapshot: gain 48 linecount 2414 07-25 14:20:09.398: W/Rosie(433): mAddHtcWidgetByOtherActivity = false, mIsOpenSlideWhenLeaveLaunch = true 07-25 14:20:09.458: D/mm-camera-awb(70): awb_prepare_wb_for_snapshot r_gain 182, g_gain 141, b_gain 233 07-25 14:20:09.458: D/mm-camera-awb(70): agw_sample_decision=2 07-25 14:20:09.548: D/QualcommCameraHardware(70): notifyShutter size.width 800 size.height 608 07-25 14:20:09.548: D/CameraService(70): Snapshot image width=800, height=608 07-25 14:20:09.628: W/InputManagerService(188): [unbindCurrentClientLocked] Disable input method client. 07-25 14:20:09.628: W/InputManagerService(188): [startInputLocked] Enable input method client. 07-25 14:20:09.818: D/QualcommCameraHardware(70): native_access_parm: fd 15, type 67, length 4 07-25 14:20:09.818: D/CameraService(70): handleRawPicture: bActionScreen: 1 07-25 14:20:09.818: D/CameraService(70): handleRawPicture E, m_ReceivedRawCount: 0 07-25 14:20:09.818: D/CameraService(70): postProcess, bActionScreen:1, isoValue:297, prop_iso_midband_i:400, bUseNoise:0, bUseBoost:0 07-25 14:20:09.828: D/CameraService(70): handleRawPicture data Callback E 07-25 14:20:09.828: D/CameraService(70): handleRawPicture X 07-25 14:20:09.828: D/CameraService(70): handleRawPicture: bActionScreen: 0 07-25 14:20:09.828: D/CameraService(70): handleRawPicture E, m_ReceivedRawCount: 1 07-25 14:20:09.828: D/CameraService(70): postProcess, bActionScreen:0, isoValue:297, prop_iso_midband_i:400, bUseNoise:0, bUseBoost:0 07-25 14:20:09.828: D/QualcommCameraHardware(70): ###### PA: KPI CAPTURE TIME: 483 ms. ##### 07-25 14:20:09.828: D/QualcommCameraHardware(70): native_jpeg_encode, rotation = 90 07-25 14:20:09.828: D/QualcommCameraHardware(70): native_access_parm: fd 15, type 67, length 4 07-25 14:20:10.839: I/CameraActivity(1517): For Debug: in onPause(); after Thread.sleep(1500) 07-25 14:20:10.839: I/CameraActivity(1517): For Debug: begin: finishCamera(), super.onPause() 07-25 14:20:10.839: D/CameraService(70): stopPreview (pid 1517) 07-25 14:20:10.839: D/QualcommCameraHardware(70): stopPreview: E 07-25 14:20:10.839: D/QualcommCameraHardware(70): stopPreviewInternal E: 0 07-25 14:20:10.839: D/QualcommCameraHardware(70): stopPreviewInternal X: 0 07-25 14:20:10.839: D/QualcommCameraHardware(70): stopPreview: X 07-25 14:20:10.839: D/CameraService(70): setPreviewCallbackFlag(0) (pid 1517) 07-25 14:20:10.839: D/CameraService(70): setPreviewCallbackFlag(0) (pid 1517) 07-25 14:20:10.839: D/CameraService(70): disconnect E (pid 1517) 07-25 14:20:10.839: D/CameraService(70): hardware teardown 07-25 14:20:10.839: D/QualcommCameraHardware(70): stopPreview: E 07-25 14:20:10.839: D/QualcommCameraHardware(70): stopPreviewInternal E: 0 07-25 14:20:10.839: D/QualcommCameraHardware(70): stopPreviewInternal X: 0 07-25 14:20:10.839: D/QualcommCameraHardware(70): stopPreview: X 07-25 14:20:10.839: D/mm-camera-ctrlcmd(70): config_proc_CAMERA_STOP_SNAPSHOT: received CAMERA_STOP_SNAPSHOT!, ctrl->state = 13 07-25 14:20:10.839: D/mm-camera-ctrlcmd(70): config_proc_CAMERA_STOP_SNAPSHOT: snapshot is already stopped (state 13) 07-25 14:20:10.839: E/mm-camera 8x-vfe(70): Received VFE Stop ACK!!! ctrlCmd is NULL 07-25 14:20:10.839: D/QualcommCameraHardware(70): release E 07-25 14:20:10.839: D/QualcommCameraHardware(70): release: waiting for snapshot mode to complete. 07-25 14:20:10.989: I/mm-camera(70): signaling jpeg-encoding completion 07-25 14:20:10.989: W/CameraService(70): lockIfMessageWanted(256): enter sleep 07-25 14:20:11.560: I/ActivityManager(188): Starting activity: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.android.camera/.CameraEntry bnds=[360,586][477,704] } from pid 433 -- -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en --- You received this message because you are subscribed to the Google Groups "Android Developers" group. To unsubscribe from this group and stop receiving emails from it, send an email to android-developers+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.