OutOfMemoryException with a video background on autoloop

I’m sometimes getting an OutOfMemoryException on local preview and android device caused by a Video

<Video Layer="Background" File="assets/FONDO.mp4" IsLooping="true" AutoPlay="true" StretchMode="UniformToFill" ContentAlignment="Center" />

comenting out the video allows me to keep working on the project

Hi!

What version are you on? 0.20 which was released yesterday has some fixes for memoryleaks related to Video />.

Are you able to share some more of the code around <Video />? Then it would be easier for me to debug :slight_smile:

Thanks!

Hello!. yes I upgraded to 0.20 yesterday. It’s a small navigation app, no backend services or a lot animations. Added the VideoPage just a few hours ago and the OutOfMemoryException has been happening since yesterday. I don´t think they´re related.

<App>
    <Router ux:Name="router" />
    <DockPanel>
        <Navigator DefaultTemplate="main">
            <MainPage ux:Template="main" router="router" />
            <VideoPage ux:Template="video" router="router" >
                <ActivatingAnimation>
                    <Change logo_nina.Visibility="Hidden" />
                    <Change backButton.Visibility="Hidden" />
                </ActivatingAnimation>
            </VideoPage>
            <GridPage ux:Template="grid" router="router" />
            <ContentPage ux:Template="content" router="router">
                <ActivatingAnimation>
                    <Change logo_nina.Alignment="TopLeft" />
                </ActivatingAnimation>
            </ContentPage>        </Navigator>
    </DockPanel>
    <!-- <Video File="assets/song.mp3" IsLooping="true" AutoPlay="true" /> -->
    <Video Layer="Background" File="assets/FONDO.mp4" IsLooping="true" AutoPlay="true" StretchMode="UniformToFill" ContentAlignment="Center" />
    </App>

System.OutOfMemoryException occured.
   at System.Windows.Media.Renderer.Render(IntPtr pRenderTarget, Channel channel, Visual visual, Int32 width, Int32 height, Double dpiX, Double dpiY, Matrix worldTransform, Rect windowClip)
   at System.Windows.Media.Imaging.BitmapVisualManager.Render(Visual visual, Matrix worldTransform, Rect windowClip)
   at System.Windows.Media.Imaging.BitmapVisualManager.Render(Visual visual)
   at System.Windows.Media.Imaging.RenderTargetBitmap.Render(Visual visual)
   at Fuse.Video.WPF.Video.UpdateTexture(Int32 textureHandle)
   at Fuse.Video.Graphics.CIL.VideoImpl.UpdateTexture(VideoHandle handle, Int32 textureHandle)
   at Fuse.Controls.VideoImpl.CIL.VideoPlayer.Update() in C:\ProgramData\Uno\Packages\Fuse.Controls.Video\0.29.22\CIL\$.uno:line 164
   at Fuse.Controls.VideoImpl.GraphicsVideoService.Fuse.Controls.VideoImpl.IVideoService.Update() in C:\ProgramData\Uno\Packages\Fuse.Controls.Video\0.29.22\$.uno:line 666
   at Fuse.Controls.VideoImpl.VideoVisual.OnUpdate() in C:\ProgramData\Uno\Packages\Fuse.Controls.Video\0.29.22\$.uno:line 1052
   at Fuse.UpdateListener.Invoke() in C:\ProgramData\Uno\Packages\FuseCore\0.29.22\$.uno:line 9084
   at Fuse.UpdateManager.Update(Stage stage) in C:\ProgramData\Uno\Packages\FuseCore\0.29.22\$.uno:line 9361

Thanks for the details. As far as I can tell from my debugging and profiling, Video does not leak memory. The OutOfMemoryException might trigger in Video since it probably allocates a big chunk of memory when it renders. I suspect that the leak is somewhere else and releated to invalidation of the UI. Since Video has to invalidate itself everytime a new video frame is available (typically 24fps), parts of the UI might also redraw. So its not a suprise that it does not happen when removing video since then invalidation might just happen once per reload in preview and not 24 times per second.

Are you able to share your whole app? If you dont want the code to be public in the forum you can upload to this dropbox: https://www.dropbox.com/request/ZgndLtJQm5eGzG9cicGK

Thanks in advance :slight_smile:

I saw now that you have already uploaded your project. Do you get the out of memory exception when just leaving the app running or right after a reload?

And also, how much memory does your computer have?

Mostly right after a reload.

RAM 8.00GB, Intel Core i7-4510U @ 2.00GHz and about 600GB of free disk space.

Thanks for your help and info.

I have confirmed that there is a memoryleak on windows. The leak is in the lib we use for video playback in .Net. I have not been able to reproduce on android.

We have planned a fix for .Net, but its low priority so there is no specific ETAs on that.

I am sorry for any inconvenience this may cause