RenderHeads / UnityPlugin-AVProVideo

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

Oculus Quest Black Screen Issue #776

Closed d-d-d-d-d closed 3 years ago

d-d-d-d-d commented 3 years ago

I'm having a similar problem to what is described here: https://github.com/RenderHeads/UnityPlugin-AVProVideo/issues/686

And unfortunately Streaming Assets is not workable for me--both apps I'm experiencing it on use large videos I need to upload as expansion files. I've done a number of apps this way and the issue is new as of two weeks ago.

Traditionally, I use an absolute URL - /sdcard/Android/obb/com.[org].[app]/videofile.mp4 - to load videos. This no longer seems to work.

I've guessed that it's a permissions issue, but including READ_EXTERNAL_STORAGE and WRITE_EXTERNAL_STORAGE in my manifest does not solve it. The files are there, but something is preventing AVPro from loading them.

I'm currently trying to use a legacy version of Oculus Integration to see if that works--there's been some changes in 28.0, including that the Quest and Quest II are using Android 10--but even if this works I'd love to understand how to get around this in the future in case the legacy Oculus stuff isn't an option. Is there something I need to be doing differently to load large videos?

Thanks!

Ste-RH commented 3 years ago

It isn't the size of the video that is an issue, but as you say...permissions.

Android changed file access permissions in Android 10, and more so in Android 11. Take a look at #596 and #544. Also check out this forum thread, and this and this developer documentation.

Hope this information helps. Regarding accessing videos on device storage, there is nothing we can really do at AVPro Video asset level.

d-d-d-d-d commented 3 years ago

Thanks for your response! Unfortunately, following the steps at #596 has not fixed the issue. I've got the MediaPlayer set to Absolute Path/URL, and I'm passing in file:///sdcard/Android/obb/com.[org].[appname]/[moviename] but still no luck. Is there anything else you can think of that I can try? Or is there anything wrong in my Player settings or manifest?

My player settings: Screenshot 2021-05-13 02 09 05

and my manifest:

<?xml version="1.0" encoding="utf-8" standalone="no"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:installLocation="auto">

  <application android:requestLegacyExternalStorage="true" android:label="@string/app_name" android:icon="@mipmap/app_icon" android:allowBackup="false">
    <activity android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen" android:configChanges="locale|fontScale|keyboard|keyboardHidden|mcc|mnc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|touchscreen|uiMode" android:launchMode="singleTask" android:name="com.unity3d.player.UnityPlayerActivity" android:excludeFromRecents="true">
      <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.INFO" />
        <category android:name="com.oculus.intent.category.VR" />
      </intent-filter>
      <meta-data android:name="com.oculus.vr.focusaware" android:value="true" />
    </activity>
    <meta-data android:name="unityplayer.SkipPermissionsDialog" android:value="false" />
    <meta-data android:name="com.samsung.android.vr.application.mode" android:value="vr_only" />
    <meta-data android:name="com.oculus.supportedDevices" android:value="quest|quest2" />
  </application>
  <uses-feature android:name="android.hardware.vr.headtracking" android:version="1" android:required="true" />
  <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
</manifest>
Ste-RH commented 3 years ago

If you can send over a full logcat output from a ‘run’ I will be able to see better what is going on.

edit: you can lose the file:// on your path. /sdcard/... works just fine. Also, paths to the sdcard are different between Quest and Quest2. So make sure you are using the right one for the right device.

d-d-d-d-d commented 3 years ago

Here's this, thanks again. log.txt

Re: paths different between Quest / Quest II, I haven't seen that in their documentation, which I suppose is not surprising. Do you happen to have the difference handy?

Ste-RH commented 3 years ago

Thanks for the log...will look over it.

Check out this forum thread for path differences.

Ste-RH commented 3 years ago

Your log shows that the plugin has not been loaded (line 2018). This can happen for a few reasons. Take a look at #728 maybe. If that doesn't help, if you could post up all of your player settings, I might be able to spot the issue.

d-d-d-d-d commented 3 years ago

Hmm, the arm64-v8a libraries weren't being used--I'd recently changed from Mono to IL2CPP and I guess they didn't transfer over, but I'm still not managing to load anything. Currently the x86 libs are also assigned to Android, and the ameabi-v7a were but caused a build error so I unchecked them.

Here's another log: log2.txt

And here's my player settings:

settings1 settings2 settings3 settings4

Ste-RH commented 3 years ago

We have a script that sets up the plug-in files metadata as part of the build process, so that isn’t a concern. Not having the files is definitely gonna cause issues.

Have you tried switching to mono to narrow the issue down?

d-d-d-d-d commented 3 years ago

Ah, yes, it works again when building with Mono. Hopefully Oculus will have clearer guidelines for this before the warning about 64-bit apps being a requirement gains enforcement. I'm going to keep investigating the issue, and if you think of anything more I'd love to hear it, but it's been heartening to have your guidance through this process. Again, thank you for all your help.

Ste-RH commented 3 years ago

Ther is no reason il2cpp should not work. Let’s dig a bit deeper?

Can you send a screen grab of your XR (oculus) settings?

d-d-d-d-d commented 3 years ago

Here's these. For this project I've rolled back Oculus Integration to 25.0, and updated Oculus Tools to 1.57. I'm also not using XR Toolkit / Management, though I'm having the same problem in another project that is. XR Settings xrsettings I'm also using the OES path for this one, though in the other project I've tried the non-OES path and it didn't seem to make a difference.

Ste-RH commented 3 years ago

Could you send over another log using IL2CPP now you have the arm64 plugin files in the correct place?

Ste-RH commented 3 years ago

Just tested here:

The video plays and everything renders exactly as one would expect. Maybe you are missing one of the steps here?

d-d-d-d-d commented 3 years ago

Here's the log for the new IL2CCP build--same deal, no video play. log3.txt Again, this project isn't using Unity's new(er) XR Plugin framework / Toolkit.

As for my other project, which does use Unity's new XR suite:

  1. I haven't added an UpdateMultiPassStereo component--is this something needed even for monoscopic video?
  2. I haven't yet done a build with requestLegacyExternalStorage; am doing it now and will let you know the results.
  3. I'm testing on a Quest 1, but based on how recent the problems have been, and that Unity updated Quest 1 to run the same version of Android as Quest 2, I've gotta suspect this is the source of recent pains.
d-d-d-d-d commented 3 years ago

Hmm, I'm getting a failed Gradle build when I add android:requestLegacyExternalStorage to my manifest in my other project. I'm using the JDK/Android SDK/NDK/Gradle installed with Unity. Tried the manifest posted above, as well as just adding it to the Oculus-generated one, to no avail. Same Minimum/Target Android levels as the first project, same computer....

Here's the most informative output from the console gradlebuildfailure.txt

Ste-RH commented 3 years ago

Hmm, I'm getting a failed Gradle build when I add android:requestLegacyExternalStorage to my manifest in my other project. I'm using the JDK/Android SDK/NDK/Gradle installed with Unity. Tried the manifest posted above, as well as just adding it to the Oculus-generated one, to no avail. Same Minimum/Target Android levels as the first project, same computer....

Here's the most informative output from the console gradlebuildfailure.txt

What version of the Android SDK are you using?

Ste-RH commented 3 years ago
  1. I haven't added an UpdateMultiPassStereo component--is this something needed even for monoscopic video?

No, not required if you are not playing back a stereo video (or more accurately, the material properties are not setting up the shader to render as stereo).

Ste-RH commented 3 years ago

Do you have a Quest 2 to hand? I can grab hold a Quest 1 maybe tomorrow to test on.

I will test using the legacy VR now...

d-d-d-d-d commented 3 years ago

Using what's bundled with Unity 2019.4. Looks like SDK: android 28 Build tools: 28..0.3

I'm also getting the message "Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0

What's confusing to me is I don't remember setting this up any differently than the first project--it too is using the bundled Android libraries--and the only difference in the manifest and Player Settings and gradle file (when I've clicked to use a custom gradle) is that this project doesn't want me to requestLegacyExternalStorage.

I've got other SDKs installed via Android Studio, but have not tested them yet.

I can snag a Quest II tomorrow if necessary.

d-d-d-d-d commented 3 years ago

Ah okay, used the Android Studio SDKs and it compiled. Will let you know re: videos what happens.

Ste-RH commented 3 years ago

Interestingly, I am getting 'black screen' (but have audio playing from the video so I know it is playing back at least) when I use the legacy XR in Unity 2018.4.20f1 on the Quest 2 ...when using Mono!

d-d-d-d-d commented 3 years ago

So same issue with IL2CCP in app 2. Here's the logcat for that: app2log1.txt Going to build with Mono now but not sure I'll be able to test in the next 10 hours. Will let you know when I do.

Ste-RH commented 3 years ago

Can you check if the il2cpp apk has the file libAVProLocal.so in it? Thst is what the logs are complaining about - I guess it’s missing from the ARM64 folder.

d-d-d-d-d commented 3 years ago

Can you check if the il2cpp apk has the file libAVProLocal.so

Ah, so it had none of the AVPro libs. Screenshot 2021-05-14 03 04 08 Looked again at Unity, and when I was enabling them I'd just select all and tick "Android". Screenshot 2021-05-14 03 10 33 By only selecting one, I got to choose the architecture, and since I was switching to 64-bit... Screenshot 2021-05-14 03 10 16 Well, I rebuilt and now my new IL2CCP includes the AVPro libraries. Will test. Screenshot 2021-05-14 03 14 05

Ste-RH commented 3 years ago

Interesting. But more interesting is that we have a script that, as part of the build process, sets up the meta data for the library files according to what unity is building. Maybe there is an issue in/around that 🤔

Ste-RH commented 3 years ago

So on the point of our build processing setting up meta files according to the architecture being used...One of our team has questioned whether you have moved the plugins folder (or even the whole AVProVideo folder) ? This would cause the metafile setting up of plugin files to not work.

d-d-d-d-d commented 3 years ago

No, everything is where it was imported to--/Assets/AVProVideo/ and /Assets/Plugins/Android/libs/*

Good news is that the mono build is playing videos in the second app. Playback is choppy but I imagine that's a different issue. Will try with an IL2CCP build next.

Ste-RH commented 3 years ago

Screenshot 2021-05-14 03 10 16

This screen shot shows things have moved?

d-d-d-d-d commented 3 years ago

Huh, I definitely didn't manually move anything--I only touched the Android tickbox and the Platform Settings pictured. The path seems to be where the package wants them? Screenshot 2021-05-14 20 29 41

Ste-RH commented 3 years ago

Ahhhhhhh, this is AVPro v1.x !!!

Yeah, the metafile fixing-up was new in v2.x.

Note to everyone else reading this...this is why we ask for this kind of information in the initial template you fill out for an issue. (Note to self...always ask what version the dev is using)

So that makes sense then. Your files are in the right place, but you have to manually setup the arm64 plugin files (due to the backward compatibility v1.x offers in terms of Unity versions.

Throw a log this way if IL2CPP still does not work with the fixed up arm64 files.

d-d-d-d-d commented 3 years ago

That makes sense--sorry for not specifying!

I'm having a similar issue to what you described using IL2CCP. I get garbled audio and no video. With mono I get both, but it's extremely choppy.

Here's the logcat for the IL2CCP app2il2ccp.txt

The videos I'm using are well within supported specs for Oculus Quest (codec, resolution, bitrate). I tried both OES and non-OES path when using Mono but neither made a difference.

Ste-RH commented 3 years ago

Your log shows you had OES mode enabled.

Can you send over a test project (video and all) to unitysupport@renderheads.com so I can be absolutely sure I have the same setup for reproduction here. I will grab a Quest1 today if you can...

d-d-d-d-d commented 3 years ago

Will do, might be a little bit for the compress/upload, but I'll send it as soon as it's done

Ste-RH commented 3 years ago

Awesome, thanks. Sending it over WeTransfer is always a decent option.

d-d-d-d-d commented 3 years ago

Hey Ste, did you receive the files? Thanks again!

Ste-RH commented 3 years ago

Yes, received and I hope to look at this today

Ste-RH commented 3 years ago

I have reproduced your issue here on a Quest2 with the project you sent. Thoughts so far...

Your video plays back perfectly when I use one of the v1.x Demo scenes. Full frame rate and perfect audio.

In your project, if you disable the Oculus XR setting 'Low Overhead Mode' then the video renders. The audio is still choppy, but this is in line with the extremely bad frame rate being achieved during video playback - which can be seen now there are video frames rendering. As to why the frame rate is so terrible, I cannot say. But I am pretty confident that it is not due to the playback of the video with AVPro. I would suggest profiling to see if there is anything obvious.

Edit 1. I just replaced your video (in your project) with the Big Bick Bunny (720p, 30fps, 6Mbit) sample video. The render/audio is exactly the same...very choppy. This is an extremely lightweight video, and so would hardly be taxing the CPU/GPU of the device.

Edit 2: On a hunch, I disabled the game object 'VCR' in the Video1 scene. Your video in your project now renders perfectly. So whatever the problem is, it is something attached to the VCR game object. Hope this helps.

d-d-d-d-d commented 3 years ago

That's a huge help. Thanks again. Will post what I find after I get a chance to look at it tomorrow.

While doing this, did you find any difference between IL2CCP and Mono?

d-d-d-d-d commented 3 years ago

So, the choppiness was a feedback loop of directly updating the video seek slider every frame, which was then OnValueChanged calling a method to update frame position... Yeah, whoops :)

I have gotten it working with the non-OES path, but the OES path is giving me audio but no video. I do have the full/paid version, so that's not the issue. Here's logs from IL2CCP newil2ccp.txt and Mono eosmono.txt builds of that. Thanks again for your help!

d-d-d-d-d commented 3 years ago

To confirm, with non-OES path it works as expected with both Mono and IL2CCP.

Ste-RH commented 3 years ago

I am loading 'Video1' scene in the project you sent over. I...

Everything runs and renders as I would expect it to on a Quest2...video frames and audio.

Can you double check everything above is the same in your project there?

d-d-d-d-d commented 3 years ago

Everything's the same except for "Low Overhead Mode"--maybe that was the issue? I'll try again in the next couple days; focusing on other projects while Oculus reviews.

Ste-RH commented 3 years ago

Yeah, what you described is what I get when I enable 'Low Overhead Mode', so I am confident it's just that. Do let us know, and if all good and you are happy to, please close the issue :)