[Android] Memory is not released on CloseMedia
Unity version
6000.2.11f1
Unity editor platform
Windows
AVPro Video edition
Ultra
AVPro Video version
3.3.3
Device hardware
Meta Quest 3
Which Android OS version are you using?
14
Unity Graphics API
Vulkan
Video API
media3/ExoPlayer
Texture format
BGRA
Audio output
System Direct
Any other Media Player component configuration required to reproduce the issue.
No response
Which output component(s) are you using?
Apply to Mesh
Any other component configuration required to reproduce the issue.
No response
The issue
When we open the media file, the Quest allocates a certain amount of memory (I'm assuming this is managed by the ExoPlayer/Media player, as it is marked as "Untracked" in Unity's memory profiler). The expectation is that when we close the media, this memory will be released. However, this is not the case, and the memory footprint will keep increasing until the app crashes, which can happen quickly when dealing with 8k videos. The memory does get released when the player component is destroyed. This is reproducible with ExoPlayer and MediaPlayer both, whether the video is rendered in unity or not. It doesn't happen when using the XR Composition Layer output mode. I have also tested this on OpenGLES, and there the problem exists, but is not that severe – while the memory doesn't get released on close, it also doesn't increase with each file load.
Memory profiler overview
Untracked memory details
This might be related to part 3 of this issue.
Media information
No response
Logcat output
Hello, I'm taking the opportunity to share what we’ve discovered regarding this issue. We’ve noticed that in some cases, the CloseMedia() method does not release the memory that was previously allocated by OpenMedia(). However, after further testing, we found that calling the Play() method at least once before calling CloseMedia() reliably frees the allocated memory.
To sum it up:
OpenMedia() + CloseMedia() → memory is not freed
OpenMedia() + Play() (at least once) + CloseMedia() → memory is freed
Hope this helps you track down the issue.
Cheers.
A fix for this issue will make it into the next release, version 3.3.4.
AVPro Video version 3.3.4 has been released. Please let us know if it has not fixed this issue.
With 3.3.4 everything seems to work correctly on Vulkan. On OpenGLES though, the memory isn't released even if the player is destroyed now.
I've unable to reproduce this with OpenGLES and I am seeing a pretty consistent value for untracked memory in Unity's profiler. Can you provide more details about how you have the media player configured?
It doesn't grow, yes, but it also doesn't get released when I close the media. I've sent you the project.
Thanks for sending the project. I've reproduced it and will get a fix in for the next release.