Search Unity

Video Playing a video on Ubuntu

Discussion in 'Audio & Video' started by JohnBessGameCo, Oct 23, 2019.

  1. JohnBessGameCo

    JohnBessGameCo

    Joined:
    Oct 7, 2019
    Posts:
    2
    Hey there,

    I'm trying to play a video on Ubuntu in Unity, and each time I do I notice the memory usage for the process slowly creeps up. I've made a few test projects across multiple versions, and it seems to be most pronounced when streaming the video from a URL (in my case I'm streaming from a local folder). I've tried using the memory profiler, and it's pretty obvious something is wrong, as over time a byte array of about 100mb was allocated and never destroyed. I'm curious if anyone has ran into anything similar?

    For the record I'm re-using my video player object and am just passing in a new URL each time I want to change the video. I use the onLoopBack event to call "Stop()" on the video player and then, set the URL, call prepare, and on prepare I call play. Destroying the video player or its game object seems to have no effect.
     
  2. DominiqueLrx

    DominiqueLrx

    Unity Technologies

    Joined:
    Dec 14, 2016
    Posts:
    260
    Hi John!

    I just spent some time replicating your setup (local http server, serving a webm file). I also built Unity locally with memory debugging enabled, which will report many types of leaks and none were reported.

    One thing worth mentioning is that Unity's profiler itself uses about 100Mb to store its sample data, so the growth you observed could be just that. This is what I observe on the first run with the profiler enabled: the details area of the Memory profiler module shows a large amount of memory reserved for the "Profiler" area (147Mb used, 161Mb reserved in my last run). So for the scenario you're describing, you should probably try to stay away from Unity's profiler and maybe rely more on 'ps' or 'top' for process size info.

    Also, Unity will sometimes grow its internal allocations because of fragmentation. Therefore: when repeating actions multiple times, some - infrequent - process size growth is to be expected.

    Another point: do try to compare your process size growth observations between a scene that contains a VideoPlayer and one that does not (or where it is disabled). This may help isolating where the source of the problem (or at least, explanation) lies.

    And finally, you may want to explore this same sequence of events with a built game instead of in the editor. It'll have to be scripted (load clip, play a while, stop, load clip, play a while, stop, etc) but will further help identify if this growth is due to editor mechanisms.

    Once you get a clearer picture of what is happening, please submit a bug against this with a project that reproduces the issue and we'll take a deeper look. Also note that webm playback is backed by the same implementation on all desktop platforms. So if you happen to also use Unity on Windows / OSX, observations about what happens on these platforms would also help.

    Hope this helps!

    Dominique Leroux
    A/V developer at Unity
     
  3. JohnBessGameCo

    JohnBessGameCo

    Joined:
    Oct 7, 2019
    Posts:
    2
    Hey thanks for the reply,

    I ended up testing this by creating a player for Linux with the intention of running on Ubuntu 18.04.3 LTS. I only had a video player component in the scene and I would stream the video from a webm in the streaming assets folder. I then popped open the system monitor and watched the resources being used by the process as it ran. Over the course of an hour it allocated another 50mb, and continued to do so until the system ran out of memory. I can follow up with a more formal bug report and include my test project for you guys to review, I'll edit this ticket when that's done and link to it from here if that's ok.

    https://fogbugz.unity3d.com/default.asp?1196437_vre3kug6nbsin93k
     
    Last edited: Nov 5, 2019