Log in or register to post comments

Stopping the camera preview

June 20, 2018 - 1:32am #3

Hello,

I would like to being able to stop the camera preview on android. Don't ask me why, it's just that at some moment I don't want to display it for a game. I know how to not show the camera preview, but the Vuforia SDK keep processing it in background and the device is getting very hot and consumes a lot of battery despite not showing the video.

 

So instead of jsut not showing the video background, I tried to really stop the camera this way :

CameraDevice.getInstance().stop();

CameraDevice.getInstance().deinit();

On my device (Sony Xperia Z5) it works fine, but on a S8, it makes a crash :

java.lang.IllegalStateException: Session has been closed; further changes are illegal.

        at android.hardware.camera2.impl.CameraCaptureSessionImpl.checkNotClosed(CameraCaptureSessionImpl.java:665)

        at android.hardware.camera2.impl.CameraCaptureSessionImpl.capture(CameraCaptureSessionImpl.java:172)

        at com.vuforia.ar.pl.Camera2_Preview$AutofocusRunner.onCaptureCompleted(Camera2_Preview.java:605)

        at java.lang.reflect.Method.invoke(Native Method)

        at android.hardware.camera2.dispatch.InvokeDispatcher.dispatch(InvokeDispatcher.java:39)

        at android.hardware.camera2.dispatch.HandlerDispatcher$1.run(HandlerDispatcher.java:65)

        at android.os.Handler.handleCallback(Handler.java:789)

        at android.os.Handler.dispatchMessage(Handler.java:98)

        at android.os.Looper.loop(Looper.java:164)

        at android.os.HandlerThread.run(HandlerThread.java:65)

 

Any help on doing this ?

Stopping the camera preview

June 20, 2018 - 11:09am #2

Hello jptsetung,

Which version of Vuforia are you using? Are you on Native or Unity - if Unity which version of Unity? Are you able to test this on any other devices?

Thanks,

Vuforia Support

Stopping the camera preview

August 1, 2018 - 12:23am #1

The issue I have may be the same as that.

environment:

・Unity 2017.4.2f2

・Galaxy S8(Android 8.0.0)

issue:

When the scene with ARCamera transition to the scene without ARCamera, it was happend "java.lang.IllegalStateException: Session has been closed" sometimes.

At the time, the Application was crashed.

It does not happen with Zenfone3, Nexus5x, iPhone7Plus, and iPhone X.

The log when happend issue is following.

logcat:

08-01 14:19:52.201: E/AndroidRuntime(24970): java.lang.IllegalStateException: Session has been closed; further changes are illegal.

08-01 14:19:52.201: E/AndroidRuntime(24970):  at android.hardware.camera2.impl.CameraCaptureSessionImpl.checkNotClosed(CameraCaptureSessionImpl.java:665)

08-01 14:19:52.201: E/AndroidRuntime(24970):  at android.hardware.camera2.impl.CameraCaptureSessionImpl.capture(CameraCaptureSessionImpl.java:172)

08-01 14:19:52.201: E/AndroidRuntime(24970):  at com.vuforia.ar.pl.Camera2_Preview$AutofocusRunner.onCaptureCompleted(Camera2_Preview.java:605)

08-01 14:19:52.201: E/AndroidRuntime(24970):  at java.lang.reflect.Method.invoke(Native Method)

08-01 14:19:52.201: E/AndroidRuntime(24970):  at android.hardware.camera2.dispatch.InvokeDispatcher.dispatch(InvokeDispatcher.java:39)

08-01 14:19:52.201: E/AndroidRuntime(24970):  at android.hardware.camera2.dispatch.HandlerDispatcher$1.run(HandlerDispatcher.java:65)

08-01 14:19:52.201: E/AndroidRuntime(24970):  at android.os.Handler.handleCallback(Handler.java:789)

08-01 14:19:52.201: E/AndroidRuntime(24970):  at android.os.Handler.dispatchMessage(Handler.java:98)

08-01 14:19:52.201: E/AndroidRuntime(24970):  at android.os.Looper.loop(Looper.java:164)

08-01 14:19:52.201: E/AndroidRuntime(24970):  at android.os.HandlerThread.run(HandlerThread.java:65)

08-01 14:19:52.203: I/System.out(24970): (HTTPLog)-Static: isSBSettingEnabled false

08-01 14:19:52.203: I/System.out(24970): (HTTPLog)-Static: isSBSettingEnabled false

08-01 14:19:52.206: D/Camera3-Device(4904): clearStreamingRequest: mInterfaceLock.lock()

08-01 14:19:52.206: D/Camera3-Device(4904): clearStreamingRequest: mInterfaceLock.unlock()

08-01 14:19:52.206: D/Camera3-Device(4904): waitUntilDrained: mInterfaceLock.lock()

08-01 14:19:52.206: D/Camera3-Device(4904): waitUntilDrained: mInterfaceLock.unlock()

08-01 14:19:52.206: D/Camera3-Device(4904): disconnect: mInterfaceLock.lock()

08-01 14:19:52.206: I/Camera3-Device(4904): disconnect: E

08-01 14:19:52.207: I/CameraLatencyHistogram(4904): ProcessCaptureRequest latency histogram (152) samples:

08-01 14:19:52.207: I/CameraLatencyHistogram(4904):        40     80    120    160    200    240    280    320    360    inf (max ms)

08-01 14:19:52.207: I/CameraLatencyHistogram(4904):      95.39   3.95   0.66   0.00   0.00   0.00   0.00   0.00   0.00   0.00 (%)

08-01 14:19:52.214: I/CameraLatencyHistogram(4904): Stream 0 dequeueBuffer latency histogram (152) samples:

08-01 14:19:52.214: I/CameraLatencyHistogram(4904):         5     10     15     20     25     30     35     40     45    inf (max ms)

08-01 14:19:52.214: I/CameraLatencyHistogram(4904):      99.34   0.00   0.00   0.66   0.00   0.00   0.00   0.00   0.00   0.00 (%)

08-01 14:19:52.214: I/ExynosCamera3Interface(4904): INFO(HAL3_camera_device_close[170]):in =====

08-01 14:19:52.215: D/ExynosCamera3(4904): [CAM_ID(0)][]-DEBUG(releaseDevice[952]):

08-01 14:19:52.215: D/ExynosCameraFrameManager(4904): [CAM_ID(0)][CREATE FRAME WORKER]-DEBUG(workerMain[406]): Create worker stopped delete current frame(245)

08-01 14:19:52.217: D/Debug(5044): !@DumpState : SHIP

08-01 14:19:52.218: D/Debug(5044): !@DumpState : debug level:0x4f4c

08-01 14:19:52.218: D/Debug(5044): !@Dumpstate : Finally, system will skip dumpstate

08-01 14:19:52.218: W/ActivityManager(5044): crash : jp.co.harima.harimaar,0

08-01 14:19:52.222: W/ActivityManager(5044):   Force finishing activity jp.co.harima.harimaar/jp.co.wiznet.carm.unity.CarmUnityActivity

 

Log in or register to post comments