RenderHeads / UnityPlugin-AVProVideo

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

Reopening: Long delay before playback starts [macOS] #1146

Open peoplepilot opened 2 years ago

peoplepilot commented 2 years ago

Describe the issue

This issue was first reported here: https://github.com/RenderHeads/UnityPlugin-AVProVideo/issues/938 and is still occurring with the latest AVProVideo 2 version.

Using AVProVideo 1 on Unity 2018 LTS, everything worked perfectly, playing back an alpha-packed mp4 stored locally on an OSX macbook pro. Using AVProVideo 1 on Unity 2020.3.18f1, everything works perfectly except on OSX standalone, where there is a delay of several seconds before playback begins. Using AVProVideo 2 trial I get the same behaviour on OSX standalone.

Your Setup (please complete the following information):

Unity version: 2020.3.18f1

AVPro Video version: AVProVideo 1.11.3 AVProVideo 2.2.0 & 2.4.1 trials

Operating system version: Big Sur 11.4

Device model: Macbook Pro 13 2017

Video specs (resolution, frame-rate, codec, file size): Alpha packed mp4 (packed with FFMPEG as described here: https://www.renderheads.com/content/docs/AVProVideo/articles/feature-transparency.html

To Reproduce

I will send a minimal reproducible case by email again. Last time you said you had trouble compiling and running the project. Please give more details. I just tried extracting the zip and building for osx and running and it performed as expected.

Here are the steps I did when running the built project:

Note: the zip file is using AVProVideo 2.2.0. If you want to update to the latest version, you need to keep the modified Assets\AVProVideo\Demos\Scenes\Demo_MediaPlayer.unity file

Thanks for your help!

MorrisRH commented 2 years ago

This appears to be an issue with Unity. I've opened a bug report with them and will update here as and when I know more.

peoplepilot commented 2 years ago

Thanks. Could you please post the link to the bug in the Unity issue tracker?

stale[bot] commented 2 years ago

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.

christianYS commented 2 years ago

Is there any update on this? We are experiencing it and it's a very annoying issue. Can you share some more detail on why it happens? Perhaps we can find a workaround. If it can be of help, I have noticed that the videos get unstuck when there is some interaction with the window frame (for example, the windows goes in the background and back to foreground, or the cursor exits the window area)

peoplepilot commented 2 years ago

Here's some more information provided to me by the Renderheads team:

"The problem is that the built application's main dispatch queue is not being processed under certain conditions. This is when running windowed and the mouse is over the window. I've not been able to reproduce this when running fullscreen, nor with the mouse outside the window. This leads me to believe that Unity's input event handling for the mouse is starving the main dispatch queue when they want the most precision (i.e. when the mouse is over the window). I knocked together a reproducible test case (external to our plugin) and submitted it to their QA team so now I'm just waiting for them to get back to me.

Our plugin is built on top of AVFoundation which makes heavy use of the main dispatch queue for feeding back information about the state of playback, media, etc. so there is very little we can do from our end to work around this without rewriting significant chunks of the plugin (and not being certain that would resolve the issue anyway)."

I tried deactivating the mouse cursor as a workaround but it made no difference. The issue doesn't occur when running full screen.

MorrisRH commented 2 years ago

Unity have successfully reproduced the issue. You can track its progress here: https://issuetracker.unity3d.com/issues/macos-running-windowed-player-when-mouse-cursor-is-over-the-window-main-dispatch-queue-updates-become-intermittent

Chris-RH commented 1 year ago

Quick update: Unity has decided that this is an issue that they "won't fix". We'll have to think about this and see if there is anything that we can do to get around the problem.