Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash Android when switching between VideoKit and ARCore #110

Closed
alexandrefresnais opened this issue Mar 12, 2024 · 3 comments
Closed

Crash Android when switching between VideoKit and ARCore #110

alexandrefresnais opened this issue Mar 12, 2024 · 3 comments
Labels
android Issues that affect Android bug Something isn't working critical Issues of utmost importance

Comments

@alexandrefresnais
Copy link

alexandrefresnais commented Mar 12, 2024

Hi,

My team is developing an application using both AR Foundation and VideoKit.

As AR Foundation is not always required, but we need a camera feed, we switch between a VideoKit Camera Preview and an AR Camera to maximize performance and energy savings.

It works very well on iOS, but crashes on Android when switching camera feeds.

How to reproduce

The most no code solution I got is to create two scenes:

VideoKit scene

Just like the documentation, create a CameraManager and a CameraView.
Add a button to jump to AR Scene

AR Scene

Create the most simple AR scene, using either the AR template or by yourself.
Add a button to jump to Videokit scene

Symptoms

Crashing when going doing:
VideoKit -> AR -> VideoKit

At rare occasion no crash occurs, but repeating the process will crash very soon.

Logs

Logs upon entering VideoKit scene the second time.

2024/03/12 15:55:37.275 28891 28926 Debug VideoKit CameraDevice 0 preview resolution set to (1280,720)
2024/03/12 15:55:37.275 28891 28926 Debug VideoKit CameraDevice 0 photo resolution set to (4080,3072)
2024/03/12 15:55:37.275 28891 28926 Debug VideoKit CameraDevice 0 frame rate set to (15,30)
2024/03/12 15:55:37.277 28891 28926 Debug VideoKit CameraDevice 1 preview resolution set to (1280,720)
2024/03/12 15:55:37.277 28891 28926 Debug VideoKit CameraDevice 1 photo resolution set to (3440,2448)
2024/03/12 15:55:37.277 28891 28926 Debug VideoKit CameraDevice 1 frame rate set to (15,30)
2024/03/12 15:55:37.279 28891 28926 Debug VideoKit CameraDevice 0 preview resolution set to (1280,720)
2024/03/12 15:55:37.279 28891 28926 Debug VideoKit CameraDevice 0 frame rate set to (15,30)
2024/03/12 15:55:37.405 28891 29171 Error CameraCaptureSession Session 0: Exception while stopping repeating: 
2024/03/12 15:55:37.405 28891 29171 Error CameraCaptureSession android.hardware.camera2.CameraAccessException: CAMERA_ERROR (3): cancelRequest:612: Camera 0: Error clearing streaming request: Function not implemented (-38)
2024/03/12 15:55:37.405 28891 29171 Error CameraCaptureSession 	at android.hardware.camera2.CameraManager.throwAsPublicException(CameraManager.java:1633)
2024/03/12 15:55:37.405 28891 29171 Error CameraCaptureSession 	at android.hardware.camera2.impl.ICameraDeviceUserWrapper.cancelRequest(ICameraDeviceUserWrapper.java:99)
2024/03/12 15:55:37.405 28891 29171 Error CameraCaptureSession 	at android.hardware.camera2.impl.CameraDeviceImpl.stopRepeating(CameraDeviceImpl.java:1353)
2024/03/12 15:55:37.405 28891 29171 Error CameraCaptureSession 	at android.hardware.camera2.impl.CameraCaptureSessionImpl.close(CameraCaptureSessionImpl.java:579)
2024/03/12 15:55:37.405 28891 29171 Error CameraCaptureSession 	at android.hardware.camera2.impl.CameraCaptureSessionImpl$2.onDisconnected(CameraCaptureSessionImpl.java:805)
2024/03/12 15:55:37.405 28891 29171 Error CameraCaptureSession 	at android.hardware.camera2.impl.CameraDeviceImpl$7.run(CameraDeviceImpl.java:268)
2024/03/12 15:55:37.405 28891 29171 Error CameraCaptureSession 	at android.os.Handler.handleCallback(Handler.java:958)
2024/03/12 15:55:37.405 28891 29171 Error CameraCaptureSession 	at android.os.Handler.dispatchMessage(Handler.java:99)
2024/03/12 15:55:37.405 28891 29171 Error CameraCaptureSession 	at android.os.Looper.loopOnce(Looper.java:205)
2024/03/12 15:55:37.405 28891 29171 Error CameraCaptureSession 	at android.os.Looper.loop(Looper.java:294)
2024/03/12 15:55:37.405 28891 29171 Error CameraCaptureSession 	at android.os.HandlerThread.run(HandlerThread.java:67)
2024/03/12 15:55:37.405 28891 29171 Error CameraCaptureSession Caused by: android.os.ServiceSpecificException: cancelRequest:612: Camera 0: Error clearing streaming request: Function not implemented (-38) (code 10)
2024/03/12 15:55:37.405 28891 29171 Error CameraCaptureSession 	at android.os.Parcel.createExceptionOrNull(Parcel.java:3071)
2024/03/12 15:55:37.405 28891 29171 Error CameraCaptureSession 	at android.os.Parcel.createException(Parcel.java:3041)
2024/03/12 15:55:37.405 28891 29171 Error CameraCaptureSession 	at android.os.Parcel.readException(Parcel.java:3024)
2024/03/12 15:55:37.405 28891 29171 Error CameraCaptureSession 	at android.os.Parcel.readException(Parcel.java:2966)
2024/03/12 15:55:37.405 28891 29171 Error CameraCaptureSession 	at android.hardware.camera2.ICameraDeviceUser$Stub$Proxy.cancelRequest(ICameraDeviceUser.java:648)
2024/03/12 15:55:37.405 28891 29171 Error CameraCaptureSession 	at android.hardware.camera2.impl.ICameraDeviceUserWrapper.cancelRequest(ICameraDeviceUserWrapper.java:97)
2024/03/12 15:55:37.405 28891 29171 Error CameraCaptureSession 	... 9 more
2024/03/12 15:55:37.405 28891 29171 Warn CameraDevice(0) Device disconnected.
0001/01/01 00:00:00.000 -1 -1 Info  --------- beginning of crash
2024/03/12 15:55:37.407 28891 29173 Error AndroidRuntime FATAL EXCEPTION: DefaultDispatcher-worker-2
2024/03/12 15:55:37.407 28891 29173 Error AndroidRuntime Process: com.unity.template.ar_mobile, PID: 28891
2024/03/12 15:55:37.407 28891 29173 Error AndroidRuntime java.lang.Error: FATAL EXCEPTION [DefaultDispatcher-worker-2]
2024/03/12 15:55:37.407 28891 29173 Error AndroidRuntime Unity version     : 2022.3.21f1
2024/03/12 15:55:37.407 28891 29173 Error AndroidRuntime Device model      : Google Pixel 7 Pro
2024/03/12 15:55:37.407 28891 29173 Error AndroidRuntime Device fingerprint: google/cheetah/cheetah:14/UQ1A.240205.002/11224170:user/release-keys
2024/03/12 15:55:37.407 28891 29173 Error AndroidRuntime CPU supported ABI : [arm64-v8a]
2024/03/12 15:55:37.407 28891 29173 Error AndroidRuntime Build Type        : Release
2024/03/12 15:55:37.407 28891 29173 Error AndroidRuntime Scripting Backend : IL2CPP
2024/03/12 15:55:37.407 28891 29173 Error AndroidRuntime Libs loaded from  : lib/arm64
2024/03/12 15:55:37.407 28891 29173 Error AndroidRuntime Strip Engine Code : true
2024/03/12 15:55:37.407 28891 29173 Error AndroidRuntime 
2024/03/12 15:55:37.407 28891 29173 Error AndroidRuntime Caused by: java.lang.IllegalStateException: Session has been closed; further changes are illegal.
2024/03/12 15:55:37.407 28891 29173 Error AndroidRuntime 	at android.hardware.camera2.impl.CameraCaptureSessionImpl.checkNotClosed(CameraCaptureSessionImpl.java:902)
2024/03/12 15:55:37.407 28891 29173 Error AndroidRuntime 	at android.hardware.camera2.impl.CameraCaptureSessionImpl.stopRepeating(CameraCaptureSessionImpl.java:418)
2024/03/12 15:55:37.407 28891 29173 Error AndroidRuntime 	at cmq.a(PG:19)
2024/03/12 15:55:37.407 28891 29173 Error AndroidRuntime 	at cmt.b(PG:8)
2024/03/12 15:55:37.407 28891 29173 Error AndroidRuntime 	at cmr.b(Unknown Source:12)
2024/03/12 15:55:37.407 28891 29173 Error AndroidRuntime 	at fjm.aK(PG:5)
2024/03/12 15:55:37.407 28891 29173 Error AndroidRuntime 	at fnu.run(PG:12)
2024/03/12 15:55:37.407 28891 29173 Error AndroidRuntime 	at fst.run(PG:1)
2024/03/12 15:55:37.407 28891 29173 Error AndroidRuntime 	at ftu.run(PG:1)
2024/03/12 15:55:37.407 28891 29173 Error AndroidRuntime 	at fto.f(PG:1)
2024/03/12 15:55:37.407 28891 29173 Error AndroidRuntime 	at ftn.run(PG:6)
2024/03/12 15:55:37.407 28891 29173 Error AndroidRuntime 	Suppressed: fsm: [foy{Cancelling}@a0cd7ff, Dispatchers.IO]

More info

Tested using Unity 2022.3.21f1. VideoKit 0.0.17
Working well on all iPhones since iPhone 12.
Crashing on Google Pixel 7 pro running Android 14.

What makes me think it is a VideoKit bug, is that the following order works:
AR scene -> Videokit -> AR scene

So I do not believe that ARCore is restraining Camera usage.

This is affecting pretty badly our user experience as they have to stay in AR.
Thank you very much for any time spent on this.

@alexandrefresnais
Copy link
Author

Hi,

Did the same experiment but using WebcamTexture instead of VideoKit inside the simple camera feed scene.
I have no problem switching quickly and infinitely between my AR scene and my WebcamTexture scene.

So this should be possible with VideoKit right ?
Maybe VideoKit is not freeing all its resources ?

Regards

@olokobayusuf
Copy link
Contributor

@alexandrefresnais fix coming in 0.0.18.

@olokobayusuf olokobayusuf added android Issues that affect Android bug Something isn't working critical Issues of utmost importance labels Mar 13, 2024
@olokobayusuf
Copy link
Contributor

Fixed in VideoKit 0.0.18.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
android Issues that affect Android bug Something isn't working critical Issues of utmost importance
Projects
None yet
Development

No branches or pull requests

2 participants