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:
i7-6700K, GTX 970M (6 GB video RAM, GeForce driver 441.41), 32 GB RAM, Windows 10 Pro 1909 Build 18363.418
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.
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.
@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
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?
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?
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?
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?
@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 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.
@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.
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…
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.