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
CloseMedia takes about a second hanging the main thread #983
Comments
Could you provide a little code snippet of how you're using mediaPlayer.CloseMedia() please? |
Thank you for a quick reply. The provided code comes from the branch before our experimental update to AVPro v2 trial, but it is basically the same code after the update - just replacing "Video" methods with "Media" ones. We call a Here comes the code snippet.
|
Thanks for the details. So, this is actually happening on 1.x? Have you run these tests on your updated 2.x trial version? Also would be useful to know where your media is stored (if local) or if you're streaming it. It would also be useful to see your video if it's possible for you to share - if so, please send to unitysupport@renderheads.com with "983" in the subject line. Thanks! |
Yes, as stated in the original post we have tried to upgrade to 2.2.1 trial version - it also hangs for about a second on the same line. Thank you for the support! |
This does not sound right at all. I will run some timing analysis on various aspects of the close process and see if I can narrow down what might be causing it. Have you profiled your close/open procedure at all? IF so, anything to report? |
From the Unity profiler the application hangs the whole time on this line |
If I can help you profile this thing any further, I will be happy to do so. If so let me know how please. |
I have looked into the close routine in our MediaPlayer API path and narrowed down the culprit to I think a single call: m_MediaPlayer.reset(); This, however, is essential. Without resetting the player it will not be possible to open another video on that player. See here for an explanation. I have looked at possible spinning the reset up on a thread, and so far not seen any bad results - though that is not to say it is thread safe. Moving this call to a thread would also likely require deeper changes (e.g. defer opening a video if the reset has not completed yet). I will look into the ExoPlayer path next. |
Thank you for narrowing that down. I tried to create a prototype of CloseMediaAsync method. I used the body of CloseMedia and called |
I have offloaded the expensive reset in the close onto a thread, and also moved almost the entire open' ExoPlayer is a different animal and such a change will not be quick and quite a bit architecture change. I am putting into the 'more thought required' category of our roadmap. Hopefully, all being well, this change should make it into v2.2.4. It is unfortunately not possible to back-port this to v1 even if we were still adding features/fixes and so will be v2 only. |
So glad to hear that. This solution will do for us. Many thanks! |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
AVPro Video 2.3.0 has been released and includes a fix for this issue. Thanks, |
Thank you! |
When closing a video on Android, calling
MediaPlayer.CloseMedia()
, the operation sometime (I would say with 33% probability) takes over a second for some videos, freezing the main thread, which is unacceptable for our VR app. Profiler says that this single line inAndroidMediaPlayer::CloseMedia()
takes the whole processing time.m_Video.Call("CloseVideo");
We have tried multiple setups using both MediaPlayer and ExoPlayer, we tried AVPro1 paid and a trial version of AVPro2. It's all the same. Any help would be much appreciated.
Thank you.
Your Setup (please complete the following information):
The text was updated successfully, but these errors were encountered: