RenderHeads / UnityPlugin-AVProVideo

AVPro Video is a multi-platform Unity plugin for advanced video playback
https://www.renderheads.com/products/avpro-video/
238 stars 28 forks source link

Unity crash on Quest 3 just after loading AVPro #1676

Closed AntonioStissi closed 9 months ago

AntonioStissi commented 1 year ago

Please DO NOT LINK / ATTACH YOUR PROJECT FILES HERE

Describe the issue Hello, my VR app crash on Quest 3 when the AVPRO plugin is loaded (the same app works fine on Quest 2). I use 360 videos (4K and 5K) encoded with h265.

Your Setup (please complete the following information):

Logs 2023-11-01 09:14:43.153 15115-15140 AVProVideo com.warpindustries.warpvr D UnityPluginLoad CALLED 2023-11-01 09:14:43.157 15115-15140 Unity com.warpindustries.warpvr I s_Interface UnityEngine.AndroidJavaObject RenderHeads.Media.AVProVideo.AndroidMediaPlayer:.ctor(OptionsAndroid) RenderHeads.Media.AVProVideo.MediaPlayer:CreateMediaPlayer(OptionsAndroid) RenderHeads.Media.AVProVideo.MediaPlayer:CreateMediaPlayer() RenderHeads.Media.AVProVideo.MediaPlayer:Initialise() RenderHeads.Media.AVProVideo.MediaPlayer:Start() 2023-11-01 09:14:43.236 15115-15140 Unity com.warpindustries.warpvr I m_Video UnityEngine.AndroidJavaObject RenderHeads.Media.AVProVideo.AndroidMediaPlayer:.ctor(OptionsAndroid) RenderHeads.Media.AVProVideo.MediaPlayer:CreateMediaPlayer(OptionsAndroid) RenderHeads.Media.AVProVideo.MediaPlayer:CreateMediaPlayer() RenderHeads.Media.AVProVideo.MediaPlayer:Initialise() RenderHeads.Media.AVProVideo.MediaPlayer:Start() 2023-11-01 09:14:43.255 15115-15140 Unity com.warpindustries.warpvr W A Canvas named "[2D-UI]" with a render mode of ScreenSpaceOverlay is being used while VR is also enabled. This Canvas will continue to incur a rendering cost, but will not be visible while in VR. Is this intentional? 2023-11-01 09:14:43.624 16750-16750 DEBUG pid-16750 A #01 pc 00000000019ba7f0 /data/app/~~SgSylF3N5WB2ZJeAg5EF9Q==/com.warpindustries.warpvr-iHFsBb9MwgEF3Dqsi9bgZg==/lib/arm64/libunity.so (ApiGLES::ClearBufferSubData(unsigned int, gl::BufferTarget, long, long)+164) (BuildId: 8eb6f76eaa752548) 2023-11-01 09:14:43.624 16750-16750 DEBUG pid-16750 A #02 pc 000000000199595c /data/app/~~SgSylF3N5WB2ZJeAg5EF9Q==/com.warpindustries.warpvr-iHFsBb9MwgEF3Dqsi9bgZg==/lib/arm64/libunity.so (BufferManagerGLES::AcquireBuffer(unsigned long, DataBufferGLES::BufferUsage, GfxBuffer*, bool)+572) (BuildId: 8eb6f76eaa752548) 2023-11-01 09:14:43.624 16750-16750 DEBUG pid-16750 A #03 pc 00000000019ab73c /data/app/~~SgSylF3N5WB2ZJeAg5EF9Q==/com.warpindustries.warpvr-iHFsBb9MwgEF3Dqsi9bgZg==/lib/arm64/libunity.so (GfxDeviceGLES::UpdateComputeConstantBuffers(unsigned int, ConstantBufferHandle*, unsigned int, unsigned long, unsigned char const*, unsigned int const*, unsigned int const*, int const*)+312) (BuildId: 8eb6f76eaa752548) 2023-11-01 09:14:43.624 16750-16750 DEBUG pid-16750 A #04 pc 0000000001bb7e7c /data/app/~~SgSylF3N5WB2ZJeAg5EF9Q==/com.warpindustries.warpvr-iHFsBb9MwgEF3Dqsi9bgZg==/lib/arm64/libunity.so (GfxDeviceWorker::RunCommand(ThreadedStreamBuffer&)+18760) (BuildId: 8eb6f76eaa752548) 2023-11-01 09:14:43.624 16750-16750 DEBUG pid-16750 A #05 pc 0000000001bb34cc /data/app/~~SgSylF3N5WB2ZJeAg5EF9Q==/com.warpindustries.warpvr-iHFsBb9MwgEF3Dqsi9bgZg==/lib/arm64/libunity.so (GfxDeviceWorker::RunExt(ThreadedStreamBuffer&)+84) (BuildId: 8eb6f76eaa752548) 2023-11-01 09:14:43.624 16750-16750 DEBUG pid-16750 A #06 pc 0000000001bb346c /data/app/~~SgSylF3N5WB2ZJeAg5EF9Q==/com.warpindustries.warpvr-iHFsBb9MwgEF3Dqsi9bgZg==/lib/arm64/libunity.so (GfxDeviceWorker::Run()+140) (BuildId: 8eb6f76eaa752548) 2023-11-01 09:14:43.624 16750-16750 DEBUG pid-16750 A #07 pc 0000000001bb31f0 /data/app/~~SgSylF3N5WB2ZJeAg5EF9Q==/com.warpindustries.warpvr-iHFsBb9MwgEF3Dqsi9bgZg==/lib/arm64/libunity.so (GfxDeviceWorker::RunGfxDeviceWorker(void*)+4) (BuildId: 8eb6f76eaa752548) 2023-11-01 09:14:43.624 16750-16750 DEBUG pid-16750 A #08 pc 00000000010bb5e8 /data/app/~~SgSylF3N5WB2ZJeAg5EF9Q==/com.warpindustries.warpvr-iHFsBb9MwgEF3Dqsi9bgZg==/lib/arm64/libunity.so (Thread::RunThreadWrapper(void*)+1048) (BuildId: 8eb6f76eaa752548) 2023-11-01 09:14:43.656 15115-15195 Unity com.warpindustries.warpvr D NativeCrashSerializer::EndReport() Success! 2023-11-01 09:14:43.672 15115-15195 CRASH com.warpindustries.warpvr E #01 pc 00000000019ba7f0 /data/app/~~SgSylF3N5WB2ZJeAg5EF9Q==/com.warpindustries.warpvr-iHFsBb9MwgEF3Dqsi9bgZg==/lib/arm64/libunity.so (ApiGLES::ClearBufferSubData(unsigned int, gl::BufferTarget, long, long)+164) (BuildId: 8eb6f76eaa752548) 2023-11-01 09:14:43.672 15115-15195 CRASH com.warpindustries.warpvr E #02 pc 000000000199595c /data/app/~~SgSylF3N5WB2ZJeAg5EF9Q==/com.warpindustries.warpvr-iHFsBb9MwgEF3Dqsi9bgZg==/lib/arm64/libunity.so (BufferManagerGLES::AcquireBuffer(unsigned long, DataBufferGLES::BufferUsage, GfxBuffer*, bool)+572) (BuildId: 8eb6f76eaa752548) 2023-11-01 09:14:43.672 15115-15195 CRASH com.warpindustries.warpvr E #03 pc 00000000019ab73c /data/app/~~SgSylF3N5WB2ZJeAg5EF9Q==/com.warpindustries.warpvr-iHFsBb9MwgEF3Dqsi9bgZg==/lib/arm64/libunity.so (GfxDeviceGLES::UpdateComputeConstantBuffers(unsigned int, ConstantBufferHandle*, unsigned int, unsigned long, unsigned char const*, unsigned int const*, unsigned int const*, int const*)+312) (BuildId: 8eb6f76eaa752548) 2023-11-01 09:14:43.672 15115-15195 CRASH com.warpindustries.warpvr E #04 pc 0000000001bb7e7c /data/app/~~SgSylF3N5WB2ZJeAg5EF9Q==/com.warpindustries.warpvr-iHFsBb9MwgEF3Dqsi9bgZg==/lib/arm64/libunity.so (GfxDeviceWorker::RunCommand(ThreadedStreamBuffer&)+18760) (BuildId: 8eb6f76eaa752548) 2023-11-01 09:14:43.672 15115-15195 CRASH com.warpindustries.warpvr E #05 pc 0000000001bb34cc /data/app/~~SgSylF3N5WB2ZJeAg5EF9Q==/com.warpindustries.warpvr-iHFsBb9MwgEF3Dqsi9bgZg==/lib/arm64/libunity.so (GfxDeviceWorker::RunExt(ThreadedStreamBuffer&)+84) (BuildId: 8eb6f76eaa752548) 2023-11-01 09:14:43.672 15115-15195 CRASH com.warpindustries.warpvr E #06 pc 0000000001bb346c /data/app/~~SgSylF3N5WB2ZJeAg5EF9Q==/com.warpindustries.warpvr-iHFsBb9MwgEF3Dqsi9bgZg==/lib/arm64/libunity.so (GfxDeviceWorker::Run()+140) (BuildId: 8eb6f76eaa752548) 2023-11-01 09:14:43.672 15115-15195 CRASH com.warpindustries.warpvr E #07 pc 0000000001bb31f0 /data/app/~~SgSylF3N5WB2ZJeAg5EF9Q==/com.warpindustries.warpvr-iHFsBb9MwgEF3Dqsi9bgZg==/lib/arm64/libunity.so (GfxDeviceWorker::RunGfxDeviceWorker(void*)+4) (BuildId: 8eb6f76eaa752548) 2023-11-01 09:14:43.672 15115-15195 CRASH com.warpindustries.warpvr E #08 pc 00000000010bb5e8 /data/app/~~SgSylF3N5WB2ZJeAg5EF9Q==/com.warpindustries.warpvr-iHFsBb9MwgEF3Dqsi9bgZg==/lib/arm64/libunity.so (Thread::RunThreadWrapper(void*)+1048) (BuildId: 8eb6f76eaa752548) 2023-11-01 09:14:44.194 16774-16774 DEBUG pid-16774 A #01 pc 00000000019ba7f0 /data/app/~~SgSylF3N5WB2ZJeAg5EF9Q==/com.warpindustries.warpvr-iHFsBb9MwgEF3Dqsi9bgZg==/lib/arm64/libunity.so (ApiGLES::ClearBufferSubData(unsigned int, gl::BufferTarget, long, long)+164) (BuildId: 8eb6f76eaa752548) 2023-11-01 09:14:44.194 16774-16774 DEBUG pid-16774 A #02 pc 000000000199595c /data/app/~~SgSylF3N5WB2ZJeAg5EF9Q==/com.warpindustries.warpvr-iHFsBb9MwgEF3Dqsi9bgZg==/lib/arm64/libunity.so (BufferManagerGLES::AcquireBuffer(unsigned long, DataBufferGLES::BufferUsage, GfxBuffer*, bool)+572) (BuildId: 8eb6f76eaa752548) 2023-11-01 09:14:44.194 16774-16774 DEBUG pid-16774 A #03 pc 00000000019ab73c /data/app/~~SgSylF3N5WB2ZJeAg5EF9Q==/com.warpindustries.warpvr-iHFsBb9MwgEF3Dqsi9bgZg==/lib/arm64/libunity.so (GfxDeviceGLES::UpdateComputeConstantBuffers(unsigned int, ConstantBufferHandle*, unsigned int, unsigned long, unsigned char const*, unsigned int const*, unsigned int const*, int const*)+312) (BuildId: 8eb6f76eaa752548) 2023-11-01 09:14:44.194 16774-16774 DEBUG pid-16774 A #04 pc 0000000001bb7e7c /data/app/~~SgSylF3N5WB2ZJeAg5EF9Q==/com.warpindustries.warpvr-iHFsBb9MwgEF3Dqsi9bgZg==/lib/arm64/libunity.so (GfxDeviceWorker::RunCommand(ThreadedStreamBuffer&)+18760) (BuildId: 8eb6f76eaa752548) 2023-11-01 09:14:44.194 16774-16774 DEBUG pid-16774 A #05 pc 0000000001bb34cc /data/app/~~SgSylF3N5WB2ZJeAg5EF9Q==/com.warpindustries.warpvr-iHFsBb9MwgEF3Dqsi9bgZg==/lib/arm64/libunity.so (GfxDeviceWorker::RunExt(ThreadedStreamBuffer&)+84) (BuildId: 8eb6f76eaa752548) 2023-11-01 09:14:44.194 16774-16774 DEBUG pid-16774 A #06 pc 0000000001bb346c /data/app/~~SgSylF3N5WB2ZJeAg5EF9Q==/com.warpindustries.warpvr-iHFsBb9MwgEF3Dqsi9bgZg==/lib/arm64/libunity.so (GfxDeviceWorker::Run()+140) (BuildId: 8eb6f76eaa752548) 2023-11-01 09:14:44.194 16774-16774 DEBUG pid-16774 A #07 pc 0000000001bb31f0 /data/app/~~SgSylF3N5WB2ZJeAg5EF9Q==/com.warpindustries.warpvr-iHFsBb9MwgEF3Dqsi9bgZg==/lib/arm64/libunity.so (GfxDeviceWorker::RunGfxDeviceWorker(void*)+4) (BuildId: 8eb6f76eaa752548) 2023-11-01 09:14:44.194 16774-16774 DEBUG pid-16774 A #08 pc 00000000010bb5e8 /data/app/~~SgSylF3N5WB2ZJeAg5EF9Q==/com.warpindustries.warpvr-iHFsBb9MwgEF3Dqsi9bgZg==/lib/arm64/libunity.so (Thread::RunThreadWrapper(void*)+1048) (BuildId: 8eb6f76eaa752548) 2023-11-01 09:14:44.216 1060-16787 ActivityTaskManager pid-1060 W Force finishing activity com.warpindustries.warpvr/com.unity3d.player.UnityPlayerActivity

Please DO NOT LINK / ATTACH YOUR PROJECT FILES HERE

Instead email the link to us unitysupport@renderheads.com

Ste-RH commented 1 year ago

I am afraid that log is unreadable. Can you attach a full, unfiltered log file?

Is the issue reproducible in a new project using our MediaPlayer Demo Scene?

AntonioStissi commented 1 year ago

Sure I copied the whole logcat without the "Unity" filtering. logcat.txt

I haven't tried it on a new project yet, I but I can do that. Also one thing I noticed, the issue happen often, but not 100% of the time (with the same exact app and video).

Chris-RH commented 1 year ago

The logcat you have provided seems to be missing lines referring to AVPro.

  1. If you can repeat it in a fresh project running just AVPro Video, please can you provide the full logcat for that.
  2. Are you using Exoplayer or Android Mediaplayer?
  3. Are you using OES rendering?
  4. Which shader are you using?
  5. Are you playing a single video or are you trying to play multiple videos?
AntonioStissi commented 1 year ago

Hi, thanks for your reply. Since I was not on the latest AVPro version I updated to version 2.8.5. After the update the crash does not happen at video loading anymore, so the first video is loaded, then when I switch to another video I use a render texture to keep the current frame during the loading of the new video (in order to avoid the black screen in between), the crash now happens there. If I remove this feature the crash does not happen so I guess the issue is there. I use this code to keep the frame:

if (mediaPlayer.MediaOpened && (Texture2D)mediaPlayer.TextureProducer.GetTexture() != null)
            {
                // Pause current scene.
                mediaPlayer.Control.Pause();
                // Get a reference to the current frame as Texture2D.
                Texture2D currentFrame = (Texture2D)mediaPlayer.TextureProducer.GetTexture();
                // Check if the frame is flipped vertically.
                bool requireFlip = mediaPlayer.TextureProducer.RequiresVerticalFlip();
                //requireFlip = false;
                // Blit the pixels on texture to the RenderTexture
                Graphics.Blit(currentFrame, TransitionRenderTexture);
                // Set the Texture on the Transition Screen Mesh Renderer Material.
                TransitionScreenMeshRenderer.material.SetTexture("_MainTex", TransitionRenderTexture);
                // Flip Vertically the Transition Screen if necessary (it depends on the video player / platform)
                TransitionScreenObject.transform.localScale = new Vector3(TransitionScreenObject.transform.localScale.x, (requireFlip ? -1.0f : 1.0f) * Mathf.Abs(TransitionScreenObject.transform.localScale.y), TransitionScreenObject.transform.localScale.z);
                // Enable the Transition Screen.
                TransitionScreenObject.SetActive(true);
                // Close current video.
                mediaPlayer.CloseMedia();
            }

Is there any other way to keep the current frame? I always used this way and had no issue until now with the Quest 3.

Regarding your questions, I use Exoplayer but the crash happen with Android Mediaplayer as well. I am not using OES, and I am using the standard shader provided in the AVPro package. I play only one video at once, so the sequence is:

Any suggestions?

Thanks, Antonio

Ste-RH commented 1 year ago

Have you tried waiting a frame or two before closing the media player? I suspect the mediaplayer is removing the texture at system level (via the our plugin) before the blit has happened.

AntonioStissi commented 1 year ago

Hi, I did more tests, unfortunately adding waiting time did not help. I created a new project for meta quest with only AVPro and the logic to switch video in sequence, the crash happens also there. I noticed that the crash does not happen all the time though, it worked a few times and then I just quit the app, started again and the crash happened. The crash seems to never happen if I remove the line with the Graphics.Blit() call. Can I share this project with you?

Chris-RH commented 12 months ago

Hi @AntonioStissi,

Unfortunately we don't have a Quest 3 to test with.
Could you update to AVPro Video version 2.9.0 please as there have been a few Android fixes and they may have inadvertently solved the issue.

You can absolutely send us a project to look at though in case there is something that we can spot. Please can you send a minimal reproducible test project to unitysupport@renderheads.comwith #1676 in the subject line.

AntonioStissi commented 12 months ago

Hi, the issue actually happens on both Quest 2 and 3 so you can test it on Quest 2 if you have it. I tried to update to 2.9.0 but no changes. I finally decided to go for a different approach and using two mediaplayers so using one to load the next video and then switching target mediaplayer in the ApplyToMesh component. Anyway I will send the project to you since it can help others in future.

StefanOber commented 4 months ago

Any news on this? It also happens on my Quest 3 randomly. After playing a few videos it eventually crashes.

AntonioStissi commented 4 months ago

One thing that helped me to avoid crash on Quest 2/3 was reducing the buffer time in the player, you may try that.

StefanOber commented 4 months ago

That seems to help indeed. Thanks