RenderHeads / UnityPlugin-AVProVideo

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

Unity 2020.2.1 Android Crash #580

Closed pmb1701 closed 3 years ago

pmb1701 commented 3 years ago

Describe the bug AVPro Video crashes on Quest 1 and 2 when loading a video. This was observed first in our application and then found to happen also with the AVPro Video sample scenes.

Your Setup (please complete the following information):

To Reproduce

  1. Import AVPro Video - Core Edition.unitypackage in Unity 2020.2.1f1
  2. Add the Demo_DisplayComponents sample scene in Build Settings and make an Android build
  3. Install and run apk in Quest 1 or 2

Logs https://clients.glue.work/s/NkS23aXzx6CTH2n

Ste-RH commented 3 years ago

From the log:

[AVProVideo] Initialising AVPro Video v2.0.1 (native plugin v2.0.0f1-core) on Adreno (TM) 540/Vulkan 1.0.0 [512.513.0] (MT False) on Android

@pmb1701 I think you have your Graphics API set to Vulkan (it might be set to Auto), not OpenGLES3 or OpenGLES2. Can you check this please? We do not currently support Vulkan.

pmb1701 commented 3 years ago

Our application is set to OpenGLES3, but I did indeed forget to change it from Vulkan for the test project this log is from. However, changing it has no effect on the outcome, the demo scene still crashes with the same fatal exception.

Ste-RH commented 3 years ago

Oki, I will look deeper :)

Can I get a log from the OpenGLES3 run please Just in case there is something different.

pmb1701 commented 3 years ago

Of course, here it is: https://clients.glue.work/s/Fbbn8RKNxmGzeHC

Ste-RH commented 3 years ago

Log reports:

FATAL EXCEPTION: Loader:ProgressiveMediaPeriod Process: com.DefaultCompany.AVProTest2, PID: 15665 java.lang.Error: FATAL EXCEPTION [Loader:ProgressiveMediaPeriod] Unity version : 2020.2.1f1 Device model : Oculus Quest Device fingerprint: oculus/vr_monterey/monterey:7.1.1/NGI77B/1201830.9360.0:user/release-keys Build Type : Release Scripting Backend : Mono ABI : armeabi-v7a Strip Engine Code : false

Caused by: java.lang.AbstractMethodError: abstract method "void com.google.android.exoplr2avp.extractor.TrackOutput.sampleData(com.google.android.exoplr2avp.util.ParsableByteArray, int)"   at com.google.android.exoplr2avp.extractor.mp4.Mp4Extractor.readSample(Mp4Extractor.java:536)   at com.google.android.exoplr2avp.extractor.mp4.Mp4Extractor.read(Mp4Extractor.java:200)   at com.google.android.exoplr2avp.source.BundledExtractorsAdapter.read(BundledExtractorsAdapter.java:127)   at com.google.android.exoplr2avp.source.ProgressiveMediaPeriod$ExtractingLoadable.load(ProgressiveMediaPeriod.java:1046)   at com.google.android.exoplr2avp.upstream.Loader$LoadTask.run(Loader.java:415)   at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)   at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)   at java.lang.Thread.run(Thread.java:761)

I have ran the Demo_MediaPlayer scene here with the Cones 2K HEVC video on a Quest1 in Unity 2018.4.15f1 and everything is as it should be. Will try Unity 2020.2.x now

Ste-RH commented 3 years ago

Have reproduced here in Unity 2020.2.1f1. Didn't have to use a Quest to reproduce.

Ste-RH commented 3 years ago

It appears the issue is the same as this.

We do have...

android.enableDexingArtifactTransform=false

...set in the Android plugin build environment, but it appears this needs to be set when building with Unity 2020.2.x. This is done by exporting the project out of Unity, opening in android Studio, adding that property to the 'gradle.properties' file, building and deploying. This is far from ideal. I will continue to see if I can find a work-around without having to export the project.

Ste-RH commented 3 years ago

And here is the solution to avoid exporting the project each time you want to build/run...

Go to the 'Player Settings', 'Publishing Settings', 'Build' and tick 'Custom Gradle Properties Template' Edit the file shown in the path (\Assets\Plugins\Android\gradleTemplate.properties) and add the line:

android.enableDexingArtifactTransform=false

Save the file and build/run your project out of Unity.

image

image

Ste-RH commented 3 years ago

If you could try this fix and let me know how it works out for you @pmb1701 I would very much appreciate it

pmb1701 commented 3 years ago

I added that custom gradle property in our application project, and I can confirm that does indeed solve the crashing issue - unfortunately, only to reveal another issue, which is that Info.GetVideoWidth() and Info.GetVideoHeight() return zero for the dimensions of all videos in the Android build, which makes useless my own aspect ratio preservation solution that I had to implement in order to use the Apply To Mesh component. In the Editor, as well as Mac and Windows builds those methods seem to return correct dimensions as the aspect ratios get correctly adjusted. I will create a new issue for that.

Ste-RH commented 3 years ago

That sounds very strange indeed! Looking forward to getting some details :)

Will close this issue now.

pmb1701 commented 3 years ago

As a matter of fact I was able to fix it by getting the dimensions and calculating the aspect ratio upon a different MediaPlayer event. In Editor as well as Windows and Mac builds the dimensions seem to be correctly reported when the Started event fires, but in the Android build I had to react in FirstFrameReady instead, which seems like a more logical place anyway so I'll refrain from creating another issue. :) Thank you for the fix for the crash issue!

Ste-RH commented 3 years ago

Ahh, oki...this is interesting!

You are seeing this because the Started event fires when the plugin says 'IsPlaying' is true. The width/height returned back from the c# AndroidMediaPlayer are actually local class members that are set when there is a texture to return. The log time between these is 13ms...so the next frame in essence. I might look at bringing this into line with other platforms for consistency.

Thanks for reporting it!

bonsenz commented 3 years ago

I had this problem too. Setting android.enableDexingArtifactTransform=false did not solve the issue for me (working with Unity 2021.1.10f1). I found this. I added -keepnames class com.google.common.* { ; } to my produard-user file and more more crashing.