UnityPlugin-AVProVideo icon indicating copy to clipboard operation
UnityPlugin-AVProVideo copied to clipboard

Reopening: Long delay before playback starts [macOS]

Open peoplepilot opened this issue 3 years ago • 7 comments

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:

  • wait a few seconds for a scene to appear with various low poly objects on top of each other and some video playback controls at the bottom of the screen
  • press the 'p' key on the keyboard - this should start playback of a video, but for me it usually takes several seconds at least
  • if you press the 'p' key again, it will pause the video, and then pressing again makes it play again and again for me there is a big delay
  • if you switch away from the app and then back while the delay is happening, playback will begin immediately when the app regains focus

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!

peoplepilot avatar Apr 11 '22 00:04 peoplepilot

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.

MorrisRH avatar Apr 12 '22 12:04 MorrisRH

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

peoplepilot avatar Apr 18 '22 23:04 peoplepilot

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.

stale[bot] avatar Apr 29 '22 00:04 stale[bot]

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)

christianYS avatar Apr 29 '22 11:04 christianYS

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.

peoplepilot avatar May 02 '22 01:05 peoplepilot

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

MorrisRH avatar May 18 '22 15:05 MorrisRH

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.

Chris-RH avatar Jun 29 '23 13:06 Chris-RH