Git Product home page Git Product logo

Comments (10)

JeetSingh4 avatar JeetSingh4 commented on April 29, 2024 2

I solved it by giving a delay of 500 mS while creating capture session because the camera configurations are not fully loaded until then, hence this delay.

void startCaptureSession() {
        if (!isCameraOpened() || !mPreview.isReady() || mImageReader == null) {
            return;
        }
        previewSize = chooseOptimalSize();
        mPreview.setBufferSize(previewSize.getWidth(), previewSize.getHeight());
        new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {
                try {
                    Surface surface = mPreview.getSurface();
                    mPreviewRequestBuilder = mCamera.createCaptureRequest(CameraDevice.TEMPLATE_PREVIEW);
                    mPreviewRequestBuilder.addTarget(surface);
                    mCamera.createCaptureSession(Arrays.asList(surface, mImageReader.getSurface()),
                            mSessionCallback, mBackgroundHandler);
                } catch (CameraAccessException e) {
                    throw new RuntimeException("Failed to start camera session");
                }
            }
        }, 500);
    }

from cameraview.

lukaspili avatar lukaspili commented on April 29, 2024

Same on nexus 6p, android 7.1.1.
Right after authorising camera permission:
java.lang.RuntimeException: Failed to start camera session

Next calls work properly.

from cameraview.

protocol10 avatar protocol10 commented on April 29, 2024

It appeared on Nexus 5x for android 7.1.1 , after granting permission for Camera
java.lang.RuntimeException: Failed to start camera session at com.google.android.cameraview.Camera2.startCaptureSession(Camera2.java:462) at com.google.android.cameraview.Camera2$1.onOpened(Camera2.java:64) at android.hardware.camera2.impl.CameraDeviceImpl$1.run(CameraDeviceImpl.java:134) 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:6119) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)

from cameraview.

xiaoyunfei avatar xiaoyunfei commented on April 29, 2024

It appeared on LGE Nexus 5x for android O,API25 , after granting permission for Camera

java.lang.RuntimeException: Failed to start camera session
at com.google.android.cameraview.Camera2.startCaptureSession(Camera2.java:486)
at com.google.android.cameraview.Camera2$1.onOpened(Camera2.java:75)
at android.hardware.camera2.impl.CameraDeviceImpl$1.run(CameraDeviceImpl.java:139)
at android.os.Handler.handleCallback(Handler.java:769)
at android.os.Handler.dispatchMessage(Handler.java:98)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6535)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)

from cameraview.

yanxinmiao avatar yanxinmiao commented on April 29, 2024

I got this issue too on HuaWei Phone , but only the fisrt time to use camera 。

Who know how to solve this bug ?

from cameraview.

yanxinmiao avatar yanxinmiao commented on April 29, 2024

@JeetSingh4 Thanks
Your solution solved my issue .

from cameraview.

zweinz avatar zweinz commented on April 29, 2024

Calling cameraView.start() on a delay also solved this issue for me but now I'm running into #11 instead.

from cameraview.

JeetSingh4 avatar JeetSingh4 commented on April 29, 2024

@zweinz buddy I hope this helps https://stackoverflow.com/questions/40146485/session-has-been-closed-further-changes-are-illegal/48019131#48019131

from cameraview.

srikanthnama avatar srikanthnama commented on April 29, 2024

@JeetSingh4 I am still facing issue even after using your solution

from cameraview.

Seckawijoki avatar Seckawijoki commented on April 29, 2024

@JeetSingh4 Crash that the mCamera will sometimes become null will happen in some devices like Mi and Huawei, so it need a prerequisite sentence before calling createCaptureRequest inside Runnable.

from cameraview.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.