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 ?
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: