-
Notifications
You must be signed in to change notification settings - Fork 29
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
Small videos freezing #1944
Comments
We are going to need a full unfiltered logcat file at very least. |
@Ste-RH , There can be a maximum of two players at the same time. But more often than not there is only one. After leaving the card, I call CloseMedia() and destroy game object with the mediaplayer component. I don’t think it’s a matter of system resources because the size of played thumbnail video is 600-800 kilobytes. And i did see this issue with the same code in AVPro v2. I changed to locally video and got worst result. It is freezed more frequntly. Do you want check my test project ? |
I think that would be very helpful, thanks. Do send it over to [email protected] with the subject 'Issue #1944' |
Just to double check. You did see the same issue in v2? |
I noticed in your scene you have a MediaPlayer that is loading the sample 'cones' video. When I disabled that MediaPlayer, videos went from playing back 19 times out of 20, to 1 in 20 ! With that failure rate, I tried using the BigBuckBunny sample video that we send out with AVPro Video. It is approximately 8 seconds in length, shorter than your video, and I did not see a video fail to open once. The primary difference between that video and yours being there is an audio track in the BBB video. I added a silent audio track to your video and it plays back flawlessly for me. I will send that test video over to you via email. I think the MediaPlayer you have in the scene essentially 'keeps ExoPlayer around/initialised'. At least that is my hunch for why it got very bad when I disabled it. I will have to take your word for it working in v2, but that in itself is odd. We did switch to using the newer media3 versionn of ExoPlayer when we moved to v3, so maybe there is some bug/difference we are now seeing with shorter videos with no audio track? Anyway, if you can put an audio track into your videos to test...do let us know. Oh, yeah, also...if you are going to be pulling videos off a cloud server then you absolutely want to have the MOV atom at the start of your videos. The one in your sample project has the MOV atom at the end, which means the whole video has to be downloaded off the server before playback can start. |
I've made the following to test it. I've removed at all mediaplayer and sphere with cones. I've got the same results. Video stacks. You can see two branches in my project:
Unfortunately, I cannot change the video format that will be used for video thumbs. |
In additional i made another test. I've got media3 repo (https://github.com/androidx/media/tree/1.1.0). How i understand you use tag 1.1.0 and a little bit rework demo-surface to init exoplayer on each change surface and changed video url to https://cdn-vr.deovr.com/preview/14x1/4260_300p.mp4.I installed builded apk to quest2 and i don't see issue with video start. Exoplayer reinited many times and video reloaded many times and it always start without problems. I understand that this is not a pure experiment. But maybe this will help you. |
Not in the slightest. We are completely custom code through the entirety of the plugin. This is a very strange issue and we are currently at a loss as to what is causing it. Like you, I checked and v2 seems to not suffer it. I am able to reproduce it now outside your app, and have logging side by side of when the video plays and when it does not. There is one callback that does not arrive from ExoPlayer when the video does not play : onVideoSizeChanged(...) and also the ExoPlayer state seems to sit in 'buffering'. I have noticed that if I call a seek then playback is then fine. The strangest thing about all this is that you (and me in my test project) are killing off the player completely. This internally kills off the ExoPlayer instance and then a new one is created when the new/next player is created. Next thing I am going to try is a pause between destroying the old and creating the new player. [Edit]: Nope, that did not help. |
I meant you use jetpack Media3 version 1.1.0 (https://developer.android.com/jetpack/androidx/releases/media3#1.1.0) |
As the core player API, yes. You can also switch to use the MediaPlayer component to use the Android MediaPlayer API. The issue does not happen for me using this. |
I know about Android MediaPlayer API. I wrote about it in the issue description. |
I went digging into ExoPlayer (media3) issues and found this: ...that led me to this: google/ExoPlayer#10021 (comment) ...which is actually an option we support: However, this appears to be a little bit broken in v3.x, though I am not sure it is 100% AVPro's fault! Enabling that spat a missing class error: java.lang.NoClassDefFoundError: Failed resolution of: Landroidx/collection/CircularIntArray; To remove this error I had to, in Unity, enable these two build properties: ...and add the following lines to the templates: Not ideal, and not really sure what we can do about it short of including androidx/collections in the AVPro Video asset package...which would likely throw issues for other developers out there using a different version of that library. Suggestions welcome! Give it a try and let me know what you get @Anton111111. |
@Ste-RH , i've tried enable forceEnableMediaCodecAsynchronousQueueing. It doesn't fix issue at all. And i don't see class error: java.lang.NoClassDefFoundError: Failed resolution of: Landroidx/collection/CircularIntArray after enabling. Also in additional. How i see i get ResolutionChanged event when video stucks. |
Hmm. If you are not getting the error, maybe it is not enabling as it should, or maybe you have the library pulled in by something else in your project? I was testing on a Xiaomi Mi 10T though. Will try on a Quest 2. I am 90% sure this is the issue. Another way you could address the problem in your project is to not continually create/destroy MediaPlayers, but instead have a pool of them (likely only needing 2) that you pick from and open the video/assign the player accordingly. Then close it on change and pull a different player for the next tile. This would be a hell of a lot better in terms of memory/GC as well. |
@Ste-RH , Initially, I had one mediaplayer that I reused and there was exactly the same problem. Currently i added _mediaPlayer?.Control?.SeekToFrame(0); when i get event MetaDataReady. And looks like this trick fixes issue. |
A pool of players would be the way I went about it...and I don't see the problem at all here in our testbed (that hammers through opening/closing videos as well as destroying/creating if desired) with open/close. |
@Anton111111 I have just emailed over to you a screen recording of it on Quest 2. It is working exactly as I think it should. This is with the forceEnableMediaCodecAsynchronousQueueing flag enabled on the MediaPlayer in the 'Prefab' GameObject in your test scene. Without it, I get a lot of none video loads. |
Can you push your changes? I build again with forceEnableMediaCodecAsynchronousQueueing enabled but it still doesn't work. |
We have released v3.0.7 a few hours ago. Maybe something in the latest code-base helps along with the flag enabled? Update and give it a go. |
I've checked with 3.0.7. I still see issue with forceEnableMediaCodecAsynchronousQueueing enabled. I've pushed after update changes to video-without-audio branch |
This is very strange. As you can see in the video I emailed over to you, I do not get the issue at all when I enable that flag. Are you enabling it in the editor on the MediaPlayer component, or in script? |
Aghh. My bad. Just noticed I was actually loading the video that I had put an audio track into. So yeah, that flag does not help :/ |
@Ste-RH , Any news? |
No, afraid nothing new to report yet. I hoped that a newer version of media3 would offer something, but having tried 1.4.1 it does not change anything - only brings a dependency issue such that we do not want to update to it's use just yet in AVPro Video. What I did notice is that when a video fails to load/play, the next cycle (when it is closed/destroyed) you get this exception:
|
We might have a work around for this issue now. This will be in the next release (v3.0.10) due by the end of the week. |
AVPro Video v3.0.10 has now been released. Do let us know if this fixes the issue for you. |
@Ste-RH , Looks like v3.0.10 fixed this issue. Thanks! |
That is great news :) |
I have grid with video cards and when user hover card i add a new instance of mediaplayer and DisplayUGUI and Load a small thumbnail video. But some times video freezing. This code works good with AVPro v2 without any freezings. And if i change exoplayer to mediaplayer (in AVPro v3) freez gone away.
I created a small project to learn this issue and after many tests and different videos i see that when video is freezed buffer is full. Why it doesn't start i don't know.
I also see this problem on very small videos up to 100kb. The faster the video loads, the more often the problem appears.
In attached video you can see issue. You can see events logs and buffer state (i write MinTime and MaxTime from TimeRanges that returned from GetBufferedTimes() in lower line) on this video.
Your Setup (please complete the following information):
Unity version: 2023.1.20f1
AVPro Video version (number and edition (trial/core/ultra/enterprise)): 3.0.6-ultra build 2407050949
Operating system version: Android
Device model: Quest2/Quest3
Videos
https://github.com/RenderHeads/UnityPlugin-AVProVideo/assets/987933/dccdd455-fea4-4ece-aed4-2e9561cfef6f
The text was updated successfully, but these errors were encountered: