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

[Android] Memory is not released on CloseMedia

Open rhduwe opened this issue 1 month ago • 7 comments

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 Image
Untracked memory details Image

This might be related to part 3 of this issue.

Media information

No response

Logcat output


rhduwe avatar Nov 18 '25 07:11 rhduwe

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.

BaptisteDev09 avatar Nov 20 '25 15:11 BaptisteDev09

A fix for this issue will make it into the next release, version 3.3.4.

MorrisRH avatar Nov 25 '25 17:11 MorrisRH

AVPro Video version 3.3.4 has been released. Please let us know if it has not fixed this issue.

Chris-RH avatar Dec 02 '25 14:12 Chris-RH

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.

rhduwe avatar Dec 02 '25 21:12 rhduwe

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?

MorrisRH avatar Dec 05 '25 17:12 MorrisRH

It doesn't grow, yes, but it also doesn't get released when I close the media. I've sent you the project.

rhduwe avatar Dec 06 '25 16:12 rhduwe

Thanks for sending the project. I've reproduced it and will get a fix in for the next release.

MorrisRH avatar Dec 09 '25 09:12 MorrisRH