trev3d / QuestDisplayAccessDemo

Inefficient sample code for getting screen contents in Unity on Meta Quest to workaround lack of 'camera access'
MIT License
136 stars 18 forks source link

Starting capture crashes app #6

Closed JaredBBraun closed 1 month ago

JaredBBraun commented 1 month ago

crash.txt Hello,

After cloning and building the unity project for my quest pro I keep getting the same crash after allowing the permission to start capture. I am running the quest pro on version 68 and Im using the AprilTagDemo scene. I kept everything in the project as is.

Here is the ADB Log of the crash: 2024/09/04 11:31:16.307 24088 24088 Info ContentValues Starting screen capture... 2024/09/04 11:31:16.329 24088 24116 Debug aprojectiondem PlayerBase::stop() from IPlayer 2024/09/04 11:31:16.329 24088 24116 Debug AudioTrack stop(203): called with 5376 frames delivered 2024/09/04 11:31:16.343 24088 24116 Warn Unity Audio source failed to initialize audio spatializer. An audio spatializer is specified in the audio project settings, but the associated plugin was not found or initialized properly. Please make sure that the selected spatializer is compatible with the target. 2024/09/04 11:31:16.388 24088 24088 Debug AndroidRuntime Shutting down VM 0001/01/01 00:00:00.000 -1 -1 Info --------- beginning of crash 2024/09/04 11:31:16.389 24088 24088 Error AndroidRuntime FATAL EXCEPTION: main 2024/09/04 11:31:16.389 24088 24088 Error AndroidRuntime Process: ph.anagly.mediaprojectiondemo, PID: 24088 2024/09/04 11:31:16.389 24088 24088 Error AndroidRuntime java.nio.BufferOverflowException 2024/09/04 11:31:16.389 24088 24088 Error AndroidRuntime at java.nio.ByteBuffer.put(ByteBuffer.java:611) 2024/09/04 11:31:16.389 24088 24088 Error AndroidRuntime at java.nio.DirectByteBuffer.put(DirectByteBuffer.java:256) 2024/09/04 11:31:16.389 24088 24088 Error AndroidRuntime at com.trev3d.UnityPlayerActivityWithMediaProjector.lambda$startScreenCaptureWithPermission$0$com-trev3d-UnityPlayerActivityWithMediaProjector(UnityPlayerActivityWithMediaProjector.java:76) 2024/09/04 11:31:16.389 24088 24088 Error AndroidRuntime at com.trev3d.UnityPlayerActivityWithMediaProjector$$ExternalSyntheticLambda0.onImageAvailable(Unknown Source:2) 2024/09/04 11:31:16.389 24088 24088 Error AndroidRuntime at android.media.ImageReader$1.run(ImageReader.java:837) 2024/09/04 11:31:16.389 24088 24088 Error AndroidRuntime at android.os.Handler.handleCallback(Handler.java:938) 2024/09/04 11:31:16.389 24088 24088 Error AndroidRuntime at android.os.Handler.dispatchMessage(Handler.java:99) 2024/09/04 11:31:16.389 24088 24088 Error AndroidRuntime at android.os.Looper.loopOnce(Looper.java:214) 2024/09/04 11:31:16.389 24088 24088 Error AndroidRuntime at android.os.Looper.loop(Looper.java:304) 2024/09/04 11:31:16.389 24088 24088 Error AndroidRuntime at android.app.ActivityThread.main(ActivityThread.java:7960) 2024/09/04 11:31:16.389 24088 24088 Error AndroidRuntime at java.lang.reflect.Method.invoke(Native Method) 2024/09/04 11:31:16.389 24088 24088 Error AndroidRuntime at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548) 2024/09/04 11:31:16.389 24088 24088 Error AndroidRuntime at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1010) 2024/09/04 11:31:16.394 24088 24319 Warn AudioTrack Use of stream types is deprecated for operations other than volume control 2024/09/04 11:31:16.394 24088 24319 Warn AudioTrack See the documentation of AudioTrack() for what to use instead with android.media.AudioAttributes to qualify your playback use case 2024/09/04 11:31:16.394 24088 24319 Warn VrosSpatialAudio automaticAssociate called with no token set, did init() happen? 2024/09/04 11:31:16.398 24088 24088 Info Process Sending signal. PID: 24088 SIG: 9

also attached the same log in a txt file for easier reading

JaredBBraun commented 1 month ago

I found a fix for this issue. I had to go the unity project settings > XR Plugin Management > Oculus. Then go to Target devices and check Quest Pro. I also changed QuestScreenCaptureTextureManager.Size so that it matches the passthrough resolution.

julienkay commented 1 month ago

What resolution worked for you with the Quest Pro if you don't mind sharing?

JaredBBraun commented 1 month ago

What resolution worked for you with the Quest Pro if you don't mind sharing?

I ended up using 1280 by 1024 for performance reasons here: https://github.com/trev3d/QuestDisplayAccessDemo/blob/master/Assets/QuestScreenCapture/QuestScreenCaptureTextureManager.cs#L32C47-L32C59

julienkay commented 4 weeks ago

Awesome, thank you! Can confirm it works. Also good catch with adding Quest Pro in the Target Devices. I was sure I had checked that this is set, but turns out that for some reason, the target devices in OculusProjectConfig are completely separate settings.