Search Unity

Video Video Player memory leak, Unity 2019.3 Windows x86_64

Discussion in 'Audio & Video' started by simonkendrew, Dec 2, 2019.

  1. simonkendrew

    simonkendrew

    Joined:
    Aug 31, 2017
    Posts:
    17
    When playing a looping video (H.264, full HD, 25fps) in a Windows x86_64 executable made in Unity 2019.3, there appears to be a memory leak that steadily increases. I’ve seen this in several beta versions of 2019.3, and also 2019.3.0f1. Up to and including Unity 2019.2, I have not encountered a memory leak when playing looping video.

    I’ve made a simple looping video player Unity project to strip out all other elements from my project, and can consistently replicate this issue. I’ve made the simplified project in Unity 2019.2.14f1 and then built an exe from it. This works fine on 2 PCs, there is no memory leak. I then duplicated this Unity project, upgraded it to Unity 2019.3.0f1 and made another exe. This new exe has a memory leak.

    The video is an internal asset (I have also tried playing from a local URL), and is output to a render texture (I have also tried outputting to camera planes).

    My 2 test PCs are as follows:
    1. i7-6700K, GTX 970M (6 GB video RAM, GeForce driver 441.41), 32 GB RAM, Windows 10 Pro 1909 Build 18363.418
    2. i5-8400, GT 1030 (2 GB video RAM, GeForce driver 441.41), 8 GB RAM, Windows 10 Home 1909 Build 18363.476
    When running the exe made in Unity 2019.2, the app’s memory usage as shown in the Windows Task Manager stays consistent.

    When running the exe made in Unity 2019.3, the app’s memory usage as shown in the Windows Task Manager increases by approx. 375 MB over 60 minutes, and continues increasing at the same rate until the video output on screen goes black.

    Download the following 2 projects, publish as Windows x86_64 executable and run.
    https://github.com/simonjameskendrew/Looping-Video-Player-2019.2.git
    https://github.com/simonjameskendrew/Looping-Video-Player-2019.3.git

    Does anyone else see this issue, and if so, does anyone know a fix for it? I've submitted a bug report to Unity today (Case 1202525), and am awaiting a response from them.
     
  2. LostPanda

    LostPanda

    Joined:
    Apr 5, 2013
    Posts:
    129
    @simonkendrew test lts unity 2018.4.10,2018.4.11,2018.4.12,2018.4.13 and 2019.3.0f1 All video playback problems. 2018lts runtime exe long time (>5h) video player alway crash .Tip video unreadable memory leak.(Case 1202260).

    using 2019.3.0f1 a fews mins alway crash!Case 1202486

    when play h265 video a few mins using video player always crash and show

    2019/12/02/08:48:38:459 [ERROR] Unity: WindowsVideoMedia error 0x8007000e while reading D:/video03.mp4

    Context: Failed opening shared handle with ID3D11Device
    Error details: <Empty>
    Track types:
    Audio Track, type: %10%16
    Video Track [4000 x 2384], type: HEVC
    Resolution exceeds the Microsoft Media Foundation decoder limit of 4096 x 2304 on Windows 10 and above.
    Install HEVC Video Extensions to enable HEVC format support on compatible devices.
    https://www.microsoft.com/en-ca/p/hevc-video-extensions-from-device-manufacturer/9n4wgh0z6vhq
    https://www.microsoft.com/en-us/p/hevc-video-extensions/9nmzlz57r3t7

    I have updated the system and installed the decoder. This problem still exists. This is a serious bug.


    No solution is currently used unless a third-party video playback system is used.
     
    simonkendrew likes this.
  3. ismaxx

    ismaxx

    Joined:
    Apr 24, 2018
    Posts:
    2
    Having the problem too, in middle of a public presentation!!! Unity whats the problem?
    as it is possible that they have not warned of this with giant letters in the notes?
     
    simonkendrew likes this.
  4. simonkendrew

    simonkendrew

    Joined:
    Aug 31, 2017
    Posts:
    17
    I submitted a bug report to Unity about this on 2nd Dec 2019, case #1202525. Can we get a response from someone at Unity about this? Surely playing video is basic functionality?
     
  5. Shaunyowns

    Shaunyowns

    Unity Technologies

    Joined:
    Nov 4, 2019
    Posts:
    55
    Hey @simonkendrew, I'll chase this up for you!

    EDIT: Can confirm that we've received a report and it's being investigated as I speak! You can expect to hear back from us soon :D
     
    Last edited: Dec 5, 2019
    LostPanda and simonkendrew like this.
  6. LeonhardP

    LeonhardP

    Unity Technologies

    Joined:
    Jul 4, 2016
    Posts:
    1,828
    simonkendrew likes this.
  7. simonkendrew

    simonkendrew

    Joined:
    Aug 31, 2017
    Posts:
    17
    I've retested my Unity project in 2019.3.0f3 and the memory leak appears to be fixed, which I assume is due to this in the release notes...

    "Video: Disabled video hardware-assisted decoding on Windows/UWP while a GPU dedicated memory leak is being investigated.
    This is a change to a 2019.3 change, not seen in any released version, and will not be mentioned in final notes."


    However, an existing problem with the audio going out of sync on a looping video seems to have reappeared, and I wonder if the 2 problems are related?

    In summary, my experience with looping videos on Windows...

    Unity 2019.2 - No memory leak, but audio sync problem does exist.
    Unity 2019.3.0f1 - No audio sync problem, but there is a memory leak.
    Unity 2019.3.0f3 - No memory leak, but audio sync problem does exist.

    Can anyone from Unity provide any more information about the audio sync issue, and whether or not these two issues are related?
     
    LostPanda likes this.
  8. DominiqueLrx

    DominiqueLrx

    Unity Technologies

    Joined:
    Dec 14, 2016
    Posts:
    126
    Hi!

    We are introducing hardware-assisted video decoding for Windows/UWP in 2019.3 and as you've seen, there were some memory leaks that had gone unnoticed until the last minute. So we've disabled this code path while fixing the issues.

    Audio sync should not differ between situations where hw acceleration is enabled and situations where it's not. But since the movie-decoding logic differs between the two approaches, it's possible that somehow the hardware-accelerated code path eliminates a pre-existing audio sync issue. Nevertheless, it's important that both code paths - hw acceleration on or off - are clean regarding audio sync. There are situations where hardware-acceleration is not available (e.g. Windows 7, insufficient graphics hardware capability, ...), in which case we revert to the software-decoding code path.

    Can you submit a bug with a VideoPlayer that loops one of your clips the same way as it does in your project?

    Thanks for bringing this to our attention!

    Dominique
    A/V developer at Unity.
     
    LostPanda and simonkendrew like this.
  9. simonkendrew

    simonkendrew

    Joined:
    Aug 31, 2017
    Posts:
    17
    Many thanks @DominiqueLrx

    I've just submitted a report, case 1205811.
     
    LostPanda likes this.
  10. LostPanda

    LostPanda

    Joined:
    Apr 5, 2013
    Posts:
    129
  11. simonkendrew

    simonkendrew

    Joined:
    Aug 31, 2017
    Posts:
    17
    @LostPanda I've not heard anything more from Unity regarding the audio sync bug report (1205811) that I submitted, other than an automated 'Thank you for your bug report' email, however, this was only 2 days ago.
     
    LostPanda likes this.
  12. LostPanda

    LostPanda

    Joined:
    Apr 5, 2013
    Posts:
    129
    Maybe can only watting...:(
     
  13. LostPanda

    LostPanda

    Joined:
    Apr 5, 2013
    Posts:
    129
  14. simonkendrew

    simonkendrew

    Joined:
    Aug 31, 2017
    Posts:
    17
    @LostPanda What have you tested to be OK? The memory leak or audio sync issue? Also, can you confirm exactly which version of Unity you are referring to, as the latest version I can see is 2019.3.0f3 from 11th Dec 2019.
     
  15. LostPanda

    LostPanda

    Joined:
    Apr 5, 2013
    Posts:
    129
  16. simonkendrew

    simonkendrew

    Joined:
    Aug 31, 2017
    Posts:
    17
    @LostPanda. Thanks for the info. I've just tried 2019.3.0f4. The issue with audio / video going out of sync after a few loops of the video seems to be fixed. I think the memory leak is fixed, but I'll need to do longer testing before I can confirm.

    However, I have discovered a new bug that appears in both a Windows Exe and also the Unity editor. When a playing video reaches the end (or just before the end), the video appears to rewind back a few frames, then play forwards, then rewind back a few frames again and then play forwards, before actually reaching the end. I have output the video player .time and .frame properties to the console, but these do not indicate a jump backwards. This problem happens regardless of whether the video is an internal asset or external local URL, whether the video player outputs to a camera plane or render texture, or the video loops or only plays once.

    Can anyone else confirm this issue?
     
    LostPanda likes this.
  17. simonkendrew

    simonkendrew

    Joined:
    Aug 31, 2017
    Posts:
    17

    EDIT - I've just submitted a bug report to Unity about this - Case 1209623
     
  18. simonkendrew

    simonkendrew

    Joined:
    Aug 31, 2017
    Posts:
    17
    I've tested a Windows Exe for approx 12 hours and there is no increase in memory usage, so that's good news. Just need a fix / response from Unity regarding this new issue of the video skipping backwards when it reaches the end...
     
    LostPanda likes this.
  19. LostPanda

    LostPanda

    Joined:
    Apr 5, 2013
    Posts:
    129
    Thank you for sharing the news.This information is very important to me.As far as I know, unity should be on vacation. Because I submitted a il2cpp error in 2018.4.14f1, and there has been no response.I also observed other people on the forum saying they were on vacation.Can you tell me your gmail address? I have a lot of applications that are based on video, maybe we have a lot of opportunities to communicate. Thanks. For your question, I will take time to test it later. Thanks again.
     
  20. simonkendrew

    simonkendrew

    Joined:
    Aug 31, 2017
    Posts:
    17
    LostPanda likes this.
  21. simonkendrew

    simonkendrew

    Joined:
    Aug 31, 2017
    Posts:
    17
    Can anyone from Unity advise when we might expect a fix on bug 1209623 - 'LAST FRAMES OF VIDEO ARE REPEATED WHEN PLAYED USING VIDEO PLAYER COMPONENT' . Many thanks.
     
  22. simonkendrew

    simonkendrew

    Joined:
    Aug 31, 2017
    Posts:
    17
    I've just tried Unity 2019.3.0f6 which was released yesterday. Bug 1209623 (last frames of video are repeated when played) in the video player is still present, however, the previous bugs 1202525 (memory leak) and 1205811 (audio sync issue on looping video), both appear to be OK.

    Can we get a response from Unity on when bug 1209623 will be resolved, as this makes 2019.3 unusable for me.

    Many thanks.
     
  23. simonkendrew

    simonkendrew

    Joined:
    Aug 31, 2017
    Posts:
    17
    I've just tried the video player component in Unity 2019.3.1f1 and bug 1209623 - 'LAST FRAMES OF VIDEO ARE REPEATED WHEN PLAYED USING VIDEO PLAYER COMPONENT' still exists.

    Can we get a response from Unity on when bug 1209623 will be resolved, as this makes 2019.3 unusable for me.

    Many thanks.
     
unityunity