question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

When calling cameraView.start(); I get the following exception:

java.lang.IllegalStateException: Session has been closed; further changes are illegal. at android.hardware.camera2.impl.CameraCaptureSessionImpl.checkNotClosed(CameraCaptureSessionImpl.java:606) at android.hardware.camera2.impl.CameraCaptureSessionImpl.setRepeatingRequest(CameraCaptureSessionImpl.java:227) at com.google.android.cameraview.Camera2$3.onConfigured(Camera2.java:132) 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:751) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:154) at android.app.ActivityThread.main(ActivityThread.java:6077) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)

Note: I’m not calling it in onResume. Rather after the Camera permisison has been granted.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:2
  • Comments:15 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
gilshallemcommented, Sep 29, 2016

Same problem happen to me on nexus 5x 7.0. stoyicker solution doesn’t work

2reactions
instantiatorcommented, Aug 18, 2017

It seems like this was occurring for me when I setVisibility(VISIBLE) and then immediately attempted to start() the CameraView. My workaround: do the visibility change and post the start() to allow it time for the view to be ready.

view_main_camera.setVisibility(VISIBLE);
view_main_camera.post(new Runnable() {
  @Override
  public void run() {
    view_main_camera.start();
  }
});

Seems to work!

Read more comments on GitHub >

github_iconTop Results From Across the Web

android - Session has been closed; further changes are illegal
In my case problem was createCaptureRequest being called multiple when another is already in process(onConfigured/onConfigureFailed called).
Read more >
java.lang.IllegalStateException Session has been closed
Crash in Camera2, connected to ARCore: java.lang.IllegalStateException Session has been closed; further changes are illegal.
Read more >
core/java/android/hardware/camera2/impl ... - Google Git
import java.util.concurrent. ... This session is closed; all further calls will throw ISE */ ... "Session has been closed; further changes are illegal.");....
Read more >
CameraCaptureSession - Android Developers
IllegalStateException, if this session is no longer active, either because the session was explicitly closed, a new session has been created or the...
Read more >
java.lang.IllegalStateException thrown by the Session Manager
The exception, java.lang.IllegalStateException, is thrown by the Session Manager if the session object is invalid.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found