google-ar / arcore-android-sdk

ARCore SDK for Android Studio
https://developers.google.com/ar
Other
4.98k stars 1.22k forks source link

Black screen after switching front camera #456

Closed 01098996 closed 3 years ago

01098996 commented 6 years ago

I want to switch ARCoreCamera to normal camera while calling ARSession_Destory on another asyn thread , but black screen occured on my Pixel!

Below is the log:


05-10 10:57:19.571 I/QCamera (  662): <HAL><INFO> cameraDeviceOpen: 386: Open camera id 1 API version 768
05-10 10:57:19.572 I/vndksupport(  662): sphal namespace is not configured for this process. Loading /vendor/lib/hw/power.marlin.so from the current namespace instead.
05-10 10:57:19.573 W//system/bin/hw/android.hidl.allocator@1.0-service(  659): ashmem_create_region(32768) returning hidl_memory(0x76e802c330, 32768)
05-10 10:57:19.574 W//system/bin/hw/android.hidl.allocator@1.0-service(  659): ashmem_create_region(32768) returning hidl_memory(0x76e802c330, 32768)
05-10 10:57:19.574 I/QCamera (  662): <HAL><INFO> openCamera: 675: [KPI Perf]: E PROFILE_OPEN_CAMERA camera id 1
05-10 10:57:19.574 I/mm-camera(  662): <MCT   >< INFO> 64: mct_controller_new: Creating new mct_controller with session-id 3
05-10 10:57:19.574 I/mm-camera(  662): <MCT   >< INFO> 4162: mct_pipeline_start_session_thread: E sensor
05-10 10:57:19.574 W//system/bin/hw/android.hidl.allocator@1.0-service(  659): ashmem_create_region(32768) returning hidl_memory(0x76e802c330, 32768)
05-10 10:57:19.575 I/mm-camera(  662): <MCT   >< INFO> 4169: mct_pipeline_start_session_thread: Calling start_session on Module sensor
05-10 10:57:19.575 I/mm-camera(  662): <MCT   >< INFO> 4162: mct_pipeline_start_session_thread: E iface
05-10 10:57:19.575 I/mm-camera(  662): <MCT   >< INFO> 4169: mct_pipeline_start_session_thread: Calling start_session on Module iface
05-10 10:57:19.576 I/mm-camera(  662): <MCT   >< INFO> 4162: mct_pipeline_start_session_thread: E isp
05-10 10:57:19.576 I/mm-camera(  662): <MCT   >< INFO> 4169: mct_pipeline_start_session_thread: Calling start_session on Module isp
05-10 10:57:19.576 I/mm-camera(  662): <ISP   >< INFO> 190: isp_module_start_session: session id 3
05-10 10:57:19.578 W//system/bin/hw/android.hidl.allocator@1.0-service(  659): ashmem_create_region(32768) returning hidl_memory(0x76e802c330, 32768)
05-10 10:57:19.582 W//system/bin/hw/android.hidl.allocator@1.0-service(  659): ashmem_create_region(32768) returning hidl_memory(0x76e802c330, 32768)
05-10 10:57:19.584 I/mm-camera(  662): <MCT   >< INFO> 4162: mct_pipeline_start_session_thread: E stats
05-10 10:57:19.584 I/mm-camera(  662): <MCT   >< INFO> 4169: mct_pipeline_start_session_thread: Calling start_session on Module stats
05-10 10:57:19.586 W//system/bin/hw/android.hidl.allocator@1.0-service(  659): ashmem_create_region(32768) returning hidl_memory(0x76e802c330, 32768)
05-10 10:57:19.586 I/mm-camera(  662): <MCT   >< INFO> 4172: mct_pipeline_start_session_thread: Module iface start_session rc = 1
05-10 10:57:19.586 I/mm-camera(  662): <MCT   >< INFO> 4162: mct_pipeline_start_session_thread: E pproc
05-10 10:57:19.586 I/mm-camera(  662): <MCT   >< INFO> 4180: mct_pipeline_start_session_thread: started_num = 1, success = 1
05-10 10:57:19.586 I/mm-camera(  662): <MCT   >< INFO> 4187: mct_pipeline_start_session_thread: X iface
05-10 10:57:19.586 I/mm-camera(  662): <MCT   >< INFO> 4169: mct_pipeline_start_session_thread: Calling start_session on Module pproc
05-10 10:57:19.587 I/mm-camera(  662): <MCT   >< INFO> 4172: mct_pipeline_start_session_thread: Module isp start_session rc = 1
05-10 10:57:19.587 I/mm-camera(  662): <MCT   >< INFO> 4180: mct_pipeline_start_session_thread: started_num = 2, success = 2
05-10 10:57:19.587 I/mm-camera(  662): <MCT   >< INFO> 4187: mct_pipeline_start_session_thread: X isp
05-10 10:57:19.587 I/mm-camera(  662): <MCT   >< INFO> 4162: mct_pipeline_start_session_thread: E imglib
05-10 10:57:19.587 I/mm-camera(  662): <C2D   >< INFO> 394: c2d_module_start_session: Warning: Cannot open ION fd
05-10 10:57:19.587 I/mm-camera(  662): <MCT   >< INFO> 4169: mct_pipeline_start_session_thread: Calling start_session on Module imglib
05-10 10:57:19.587 I/mm-camera(  662): <IMGLIB>< INFO> 1768: module_imglib_start_session: module_imglib_start_session:1768 ###Img_Loglevel 1, moduleMask 65535
05-10 10:57:19.588 I/mm-camera(  662): <MCT   >< INFO> 4172: mct_pipeline_start_session_thread: Module imglib start_session rc = 1
05-10 10:57:19.588 I/mm-camera(  662): <MCT   >< INFO> 4180: mct_pipeline_start_session_thread: started_num = 3, success = 3
05-10 10:57:19.588 I/mm-camera(  662): <MCT   >< INFO> 4187: mct_pipeline_start_session_thread: X imglib
05-10 10:57:19.588 I/GoogGyro(  662): tripod Reset
05-10 10:57:19.588 I/GoogGyro(  662): enable tripod:1
05-10 10:57:19.588 I/GoogGyro(  662): tripod mode, average threshold: 0.004000
05-10 10:57:19.588 I/GoogGyro(  662): tripod mode, variance threshold: 0.001000
05-10 10:57:19.588 I/GoogGyro(  662): tripod mode, adaptive step: 0.001000
05-10 10:57:19.588 I/GoogGyro(  662): tripod mode, deque size: 100
05-10 10:57:19.588 I/GoogGyro(  662): tripod mode, damping duration: 5.000000
05-10 10:57:19.588 W//system/bin/hw/android.hidl.allocator@1.0-service(  659): ashmem_create_region(32768) returning hidl_memory(0x76e802c330, 32768)
05-10 10:57:19.589 I/mm-camera(  662): <MCT   >< INFO> 4172: mct_pipeline_start_session_thread: Module pproc start_session rc = 1
05-10 10:57:19.589 I/mm-camera(  662): <MCT   >< INFO> 4180: mct_pipeline_start_session_thread: started_num = 4, success = 4
05-10 10:57:19.589 I/mm-camera(  662): <MCT   >< INFO> 4187: mct_pipeline_start_session_thread: X pproc
05-10 10:57:19.589 I/mm-camera(  662): <STATS_AIS >< INFO> 334: gyro_port_use_dsps_iface: Native sensor interface is default
05-10 10:57:19.590 I/mm-camera(  662): <MCT   >< INFO> 4172: mct_pipeline_start_session_thread: Module stats start_session rc = 1
05-10 10:57:19.590 I/mm-camera(  662): <MCT   >< INFO> 4180: mct_pipeline_start_session_thread: started_num = 5, success = 5
05-10 10:57:19.590 I/mm-camera(  662): <MCT   >< INFO> 4187: mct_pipeline_start_session_thread: X stats
05-10 10:57:19.591 I/mm-camera(  662): <STATS_AIS >< INFO> 689: sensor_event_callback: Available: GYRO_TYPE
05-10 10:57:19.591 I/mm-camera(  662): <STATS_AIS >< INFO> 686: sensor_event_callback: Available: ACCELEROMETER_TYPE
05-10 10:57:19.591 I/mm-camera(  662): <STATS_AIS >< INFO> 692: sensor_event_callback: Available: GRAVITY_TYPE
05-10 10:57:19.591 I/mm-camera(  662): <STATS_AIS >< INFO> 695: sensor_event_callback: Available: LINEAR_ACCELERATION_TYPE
05-10 10:57:19.593 I/mm-camera(  662): <MCT   >< INFO> 4172: mct_pipeline_start_session_thread: Module sensor start_session rc = 1
05-10 10:57:19.593 I/mm-camera(  662): <MCT   >< INFO> 4180: mct_pipeline_start_session_thread: started_num = 6, success = 6
05-10 10:57:19.593 I/mm-camera(  662): <MCT   >< INFO> 4187: mct_pipeline_start_session_thread: X sensor
05-10 10:57:19.593 E/mm-camera(  662): <MCT   ><ERROR> 4342: mct_pipeline_start_session: No VFE HW available for another pixel-stream
05-10 10:57:19.593 E/mm-camera(  662): <MCT   ><ERROR> 74: mct_controller_new: Start session failed with status -2
05-10 10:57:19.593 I/mm-camera(  662): <MCT   >< INFO> 4240: mct_pipeline_stop_session: Initiating stop_session on session 3
05-10 10:57:19.593 E/mm-camera(  662): <MCT   ><ERROR> 742: mct_pipeline_unmap_parm: Cannot find session stream
05-10 10:57:19.593 E/mm-camera(  662): <MCT   ><ERROR> 4042: mct_pipeline_stop_stream_internal: stream unmap_parm failed
05-10 10:57:19.594 I/mm-camera(  662): <SENSOR>< INFO> 92: module_sensor_offload_init_config: E
05-10 10:57:19.598 I/mm-camera(  662): <MCT   >< INFO> 3974: mct_pipeline_stop_session_thread: Stop module name: sensor - E
05-10 10:57:19.598 I/mm-camera(  662): <MCT   >< INFO> 3974: mct_pipeline_stop_session_thread: Stop module name: iface - E
05-10 10:57:19.598 W//system/bin/hw/android.hidl.allocator@1.0-service(  659): ashmem_create_region(32768) returning hidl_memory(0x76e802c330, 32768)
05-10 10:57:19.598 I/mm-camera(  662): <MCT   >< INFO> 3982: mct_pipeline_stop_session_thread: Stop module name: iface - X
05-10 10:57:19.599 I/mm-camera(  662): <MCT   >< INFO> 3974: mct_pipeline_stop_session_thread: Stop module name: isp - E
05-10 10:57:19.599 I/mm-camera(  662): <ISP   >< INFO> 476: isp_module_stop_session: session id 3
05-10 10:57:19.599 W//system/bin/hw/android.hidl.allocator@1.0-service(  659): ashmem_create_region(32768) returning hidl_memory(0x76e802c330, 32768)
05-10 10:57:19.599 I/mm-camera(  662): <MCT   >< INFO> 3974: mct_pipeline_stop_session_thread: Stop module name: stats - E
05-10 10:57:19.600 I/mm-camera(  662): <MCT   >< INFO> 3982: mct_pipeline_stop_session_thread: Stop module name: isp - X
05-10 10:57:19.600 E/mm-camera(  662): <STATS_AF ><ERROR> 100: af_port_dummy_destroy: Uninitialized interface been use
05-10 10:57:19.600 W//system/bin/hw/android.hidl.allocator@1.0-service(  659): ashmem_create_region(32768) returning hidl_memory(0x76e802c330, 32768)
05-10 10:57:19.600 E/mm-camera(  662): <STATS_AWB ><ERROR> 118: awb_port_dummy_deinit: Error: Uninitialized interface been use
05-10 10:57:19.600 E/mm-camera(  662): <STATS_AEC ><ERROR> 116: aec_port_dummy_destroy: Error: Uninitialized interface been use
05-10 10:57:19.600 W//system/bin/hw/android.hidl.allocator@1.0-service(  659): ashmem_create_region(32768) returning hidl_memory(0x76e802c330, 32768)
05-10 10:57:19.601 I/mm-camera(  662): <MCT   >< INFO> 3982: mct_pipeline_stop_session_thread: Stop module name: stats - X
05-10 10:57:19.607 I/mm-camera(  662): <SENSOR>< INFO> 151: module_sensor_offload_init_config: SENSOR_INIT returned
05-10 10:57:19.607 I/mm-camera(  662): <SENSOR>< INFO> 187: module_sensor_offload_init_config: EEPROM set up
05-10 10:57:19.607 I/mm-camera(  662): <SENSOR>< INFO> 259: module_sensor_offload_init_config: Success
05-10 10:57:19.609 I/mm-camera(  662): <MCT   >< INFO> 3974: mct_pipeline_stop_session_thread: Stop module name: pproc - E
05-10 10:57:19.610 I/mm-camera(  662): <MCT   >< INFO> 3982: mct_pipeline_stop_session_thread: Stop module name: pproc - X
05-10 10:57:19.610 I/mm-camera(  662): <MCT   >< INFO> 4262: mct_pipeline_stop_session: Modules left: 5
05-10 10:57:19.610 I/mm-camera(  662): <MCT   >< INFO> 4262: mct_pipeline_stop_session: Modules left: 4
05-10 10:57:19.610 I/mm-camera(  662): <MCT   >< INFO> 4262: mct_pipeline_stop_session: Modules left: 3
05-10 10:57:19.610 I/mm-camera(  662): <MCT   >< INFO> 4262: mct_pipeline_stop_session: Modules left: 2
05-10 10:57:19.610 I/mm-camera(  662): <MCT   >< INFO> 3974: mct_pipeline_stop_session_thread: Stop module name: imglib - E
05-10 10:57:19.610 I/mm-camera(  662): <MCT   >< INFO> 3982: mct_pipeline_stop_session_thread: Stop module name: imglib - X
05-10 10:57:19.610 I/mm-camera(  662): <MCT   >< INFO> 4262: mct_pipeline_stop_session: Modules left: 1
05-10 10:57:19.616 I/mm-camera(  662): <MCT   >< INFO> 3982: mct_pipeline_stop_session_thread: Stop module name: sensor - X
05-10 10:57:19.616 I/mm-camera(  662): <MCT   >< INFO> 4262: mct_pipeline_stop_session: Modules left: 0
05-10 10:57:19.617 I/mm-camera(  662): <MCT   >< INFO> 4275: mct_pipeline_stop_session: Stopped session 3 successfully
05-10 10:57:19.617 E/QCamera (  662): <MCI><ERROR> mm_camera_open: 337: Failed to open session
05-10 10:57:19.617 E/QCamera (  662): <MCI><ERROR> camera_open: 2136: mm_camera_open err = -87
05-10 10:57:19.617 E/QCamera (  662): <HAL><ERROR> openCamera: 724: camera_open failed. rc = -87, mCameraHandle = 0x0
05-10 10:57:19.617 I/QCamera (  662): <HAL><INFO> openCamera: 685: [KPI Perf]: X PROFILE_OPEN_CAMERA camera id 1, rc: -87
05-10 10:57:19.619 E/CamDev@3.2-impl(  662): open: cannot open camera 1!
05-10 10:57:19.619 E/Camera3-Device(  692): Camera 1: initialize: Could not open camera session: Too many users (-87)
05-10 10:57:19.619 E/Camera2ClientBase(  692): initializeImpl: Camera 1: unable to initialize device: Too many users (-87)
05-10 10:57:19.619 E/CameraService(  692): connectHelper: Could not initialize client from HAL.
05-10 10:57:19.619 I/Camera2Client(  692): Camera 1: Closed
05-10 10:57:19.619 I/Camera3-Device(  692): disconnect: E
05-10 10:57:19.619 I/Camera3-Device(  692): disconnect: E
05-10 10:57:19.624 I/CameraService(  692): disconnect: Disconnected client for camera 1 for PID 7263
05-10 10:57:19.624 I/Camera2ClientBase(  692): Closed Camera 1. Client was: com.meitu.partynow (PID 7263, UID 12491)
inio commented 6 years ago

Do you ensure that ArSession_pause() has returned before trying to start the camera?

01098996 commented 6 years ago

Yes.

inio commented 6 years ago

Thanks for confirming. I'll have our camera team look at this.

inio commented 6 years ago

Our best guess is that the camera must be taking a bit longer to close than just the return of ArSession_pause(). Try waiting a few frames before starting the new session?

This is quite odd because the AR Stickers app in the Pixel Camera does exactly this: pauses an AR Session and then starts a non-AR camera capture session immediately, and we never saw this.

01098996 commented 6 years ago

@inio Thanks! I will try it.

devbridie commented 3 years ago

As a part of ongoing efforts to maintain ARCore repositories, I’m closing this issue as stale since it hasn’t had activity in more than 6 months. If this issue is still relevant, please feel free to file a new bug using the latest version of the SDK.