Comments (15)
Same problem happen to me on nexus 5x 7.0. stoyicker solution doesn't work
from cameraview.
Happens to me if you lock/unlock the screen. Same code added to a different empty Activity works just fine. Yet didn't find what so special about the first one.
from cameraview.
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!
from cameraview.
Note that this also seems to happen when you put your .stop call AFTER the super call in your onPause, instead of before. Could be the issue here as well.
from cameraview.
I can see the pull request, but is it going to be merged? The bug still exists
from cameraview.
I guess some devices don't support some aspect ratios. The default aspect ratio is 4:3 and I was getting this error on LG G4. I tried changing the aspect ratio in onCameraOpened
callback to 16:9 and it worked fine.
The code:
@Override
public void onCameraOpened(CameraView cameraView) {
mCameraView.setAspectRatio(AspectRatio.of(16, 9));
}
Edit: Actually, just set the aspectRatio before starting the camera.
from cameraview.
Seems like this is happening when the views visibility is initially set to GONE
from cameraview.
I am facing the same issue when trying the sample: on first start after granting permission the app crashes. Subsequent starts are successful and the app is working as expected. I added a longer logcat output from my device - Sony Xperia Z3 / running on Android 6.0.1
9-17 17:11:19.133 31706-31783/com.google.android.cameraview.demo I/OpenGLRenderer: Initialized EGL, version 1.4
09-17 17:11:19.258 31706-31706/com.google.android.cameraview.demo I/Timeline: Timeline: Activity_idle id: android.os.BinderProxy@8d59087 time:634371044
09-17 17:11:22.079 31706-31706/com.google.android.cameraview.demo I/CameraManagerGlobal: Connecting to camera service
09-17 17:11:22.143 31706-31712/com.google.android.cameraview.demo W/art: Suspending all threads took: 16.824ms
09-17 17:11:22.161 31706-31706/com.google.android.cameraview.demo I/CameraManager: Using legacy camera HAL.
09-17 17:11:22.669 31706-31706/com.google.android.cameraview.demo D/MainActivity: onCameraOpened
09-17 17:11:22.675 31706-31706/com.google.android.cameraview.demo I/CameraDeviceState: Legacy camera service transitioning to state CONFIGURING
09-17 17:11:22.675 31706-32161/com.google.android.cameraview.demo I/RequestThread-0: Configure outputs: 2 surfaces configured.
09-17 17:11:22.675 31706-32161/com.google.android.cameraview.demo D/Camera: app passed NULL surface
09-17 17:11:22.680 31706-32161/com.google.android.cameraview.demo I/RequestThread-0: configureOutputs - set take picture size to 5248x3936
09-17 17:11:22.746 31706-31706/com.google.android.cameraview.demo I/CameraDeviceState: Legacy camera service transitioning to state IDLE
09-17 17:11:22.757 31706-31706/com.google.android.cameraview.demo I/CameraDeviceState: Legacy camera service transitioning to state CONFIGURING
09-17 17:11:22.758 31706-32161/com.google.android.cameraview.demo I/RequestThread-0: Configure outputs: 2 surfaces configured.
09-17 17:11:22.758 31706-32161/com.google.android.cameraview.demo D/Camera: app passed NULL surface
09-17 17:11:22.760 31706-32161/com.google.android.cameraview.demo W/RequestThread-0: configureOutputs - Will need to crop picture 2048x1536 into smallest bound size 1600x1200
09-17 17:11:22.761 31706-32161/com.google.android.cameraview.demo I/RequestThread-0: configureOutputs - set take picture size to 2048x1536
09-17 17:11:22.780 31706-31706/com.google.android.cameraview.demo I/CameraDeviceState: Legacy camera service transitioning to state IDLE
09-17 17:11:22.783 31706-31706/com.google.android.cameraview.demo W/PathParser: Points are too far apart 4.000000596046461
09-17 17:11:22.786 31706-31706/com.google.android.cameraview.demo D/AndroidRuntime: Shutting down VM
09-17 17:11:22.787 31706-31706/com.google.android.cameraview.demo E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.google.android.cameraview.demo, PID: 31706
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:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:234)
at android.app.ActivityThread.main(ActivityThread.java:5526)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
from cameraview.
Seeing this as well. Happens specifically when the camera view is hidden (in my case, the camera view is behind another view which is shown later after the user taps a button).
from cameraview.
When I remove the callback in mPreview I no longer get this exception (i.e. remove https://github.com/google/cameraview/blob/master/library/src/main/api21/com/google/android/cameraview/Camera2.java#L191...L196). Is this safe to remove or would that have unintended consequences?
from cameraview.
try to update to compile "com.android.support:support-v4:25.2.0"
finally it worked with me
from cameraview.
Well, after try many ways, I got a kind of solution.
I just wanted when I stop the camera, I also want to hide the CameraView.
My first trying was like that, and I got the issue Session has been closed; further changes are illegal.
mCameraView.setVisibility(View.VISIBLE);
mCameraView.start();
mCameraView.stop();
mCameraView.setVisibility(View.GONE);
Then, I just had a look at the callback CameraView.Callback and I realised that it has two methods onCameraOpened() and onCameraClosed(). I just put the setVisibles in those methods and I didn't get more issues anymore.
private CameraView.Callback mCallback = new CameraView.Callback() {
@Override public void onCameraOpened(CameraView cameraView) {
Timber.v("onCameraOpened");
mCameraView.setVisibility(View.VISIBLE);
}
@Override public void onCameraClosed(CameraView cameraView) {
Timber.v("onCameraClosed");
mCameraView.setVisibility(View.GONE);
}
@Override public void onPictureTaken(CameraView cameraView, final byte[] data) {}
}
Sorry for my english.
from cameraview.
Ended up switching to Fotoapparat.
from cameraview.
Was this closed just because the reporter ended up using a different solution? I'm still seeing this in my own project running on a Pixel.
from cameraview.
No success here, what I had to do (no time as always) is that I implemented a onCrash() callback
so if it happens, I restart the camera activity and now all works well.
Yes yes, I know.
from cameraview.
Related Issues (20)
- how to store a click photos in gallery
- FLASH_TORCH sticks until FLASH_OFF is used
- camera preview showing black ,Please look my code below to solve. HOT 2
- java.lang.NullPointerException@android.hardware.camera2.CameraCaptureSession.capture HOT 6
- Black preveiw for front facing camera
- Why fall back to Camera1
- rotate
- CameraView shows green color when turn the screen OFF and turn ON in Redmi note 5 only HOT 2
- NPE while setting the aspect ratio HOT 1
- How to install BurstMode in this ?
- when add android:configChanges="orientation|keyboardHidden|screenSize" toCameraActivity Screen Rotation show Black Screen HOT 1
- Caused by: java.lang.RuntimeException: Fail to connect to camera service HOT 2
- TakePicture flash problem
- Pinch to zoom with Google Android Calendar
- android.view.TextureView.onSizeChanged (TextureView.java:367)
- Exit Interface always returns 0 for Google pixel with Google camera
- OPPO R17 Redmi 8A Android 9 crash
- Demo app crashes when trying to switch camera front facing camera
- Camera
- Security Policy violation Binary Artifacts HOT 23
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cameraview.