VideoTexture module repeated loading of images causes memory leak #43033
Labels
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
7 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#43033
Loading…
Reference in New Issue
No description provided.
Delete Branch "%!s(<nil>)"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
System Information
Mac OS X 10.10.1
MacBook Pro 15in Early 2011 2.2 GHz Core i7 16GB Ram, Intel HD3000 / Radeon 6750M
Blender Version
Broken: 2.27b hash:
9e963ae
2014-10-21 11:38Worked: 2.69.0 r60991 Mac 64bit
Short description of error
Repeatedly loading images from disk using the VideoTexture module will cause the ram usage of Blender to constantly increase while running the scene under the BGE. This leads eventually to the BGE hanging while running requiring a force quit.
Exact steps for others to reproduce the error
Included in the folder is a screen cap showing the memory use while running. I did not observe this in 2.69.0 with over 1,000 repeated loads of images.Monkey_VT_Bug_DelTex.zip
Changed status to: 'Open'
Added subscriber: @jdolan
Added subscriber: @raco
I can confirm the bug.
Nothing seems to help. Tried Texture.close().
Tried also this:
So even just reloading will cause the memory leak.
Still present in 2.74rc and release.
Added subscriber: @JorgeBernalMartinez
Benoit,
As you are touching again VideoTexture module, could you investigate this bug?
Update: While investigating this a bit more it seems that it is the .png images that are causing the problem. Exporting the same images as .jpg allows the textures to be swapped continuously without any issues. (I stopped the loop at 3,500 where as with the original .png files it will crash between 250 and 254.) I will continue to test with other image types that FFMpeg supports.
Edit:
Tested the following formats with these results yesterday -
Image Type, Number of loads, Result, Number of tests
jpeg, 3,500, no crash, 5
jpeg 2k, ~318, crash, 3
png, ~250, crash, 20+
tiff lzw, ~300, crash, 2
tiff, ~258, crash, 2
tga rle, 1,000+, no crash, 2
Added subscriber: @Blendify
I think that #43033 can be merged seems like the same issue
Added subscriber: @you.le
Hi! The commit behind the bug is here: https://developer.blender.org/diffusion/B/change/master/source/gameengine/VideoTexture/VideoFFmpeg.cpp%3Bff08acc556d8e40d501522efcbecac68bb8973c6
I can try to look for a solution but I'm not sure to succeed.
I haven't check it but perhaps:
thread_count = 1 --> stopCache() + m_isThreaded = false;
Hi! I tested your solution but it doesn't work. The problem seems related only to PNG decoding. You can delete this lines:
and if you replace png images with jpg, it will work without problem. The memory leak is due to threading but I had a look at AVCodecContext (m_codecCtx type = AVCodecContext) API and found no simple way to end the threads. I read somewhere that new ffmpeg libraries have a better support of PNG but I think it's complex to update libraries (how many files to modify)? Another (maybe stupid) idea would be to convert png images in another format before decoding (I guess it will take some time). But threading with an external API is too complex to manage in my opinion. So I'll try the idea to convert png before decoding (but I don't know if it's possible and efficient). I'm not experimented so you may have better ideas :) Good day/night! A link I found on the net: https://trac.ffmpeg.org/ticket/4404
Hi! I propose this fix: http://www.pasteall.org/59457/diff
The problem is that the new while loop can turn in an infinite while loop if tha data can't definitely be read. But we can make a counter m_counter = 0; m_counter+=1 (at the end of the while loop), change while ((input->data- [x]==0 && input->data- [x]==0 && input->data- [x]==0 && input->data- [x]==0) || m_counter < 10). And after the while loop, m_counter = 0; (or something like that)
Sorry about my poor english. Good day/night!
http://www.pasteall.org/59472/diff (That's what I thought about...). From what I have read about png decoding with certain ffmpeg versions, to properly decode png you can use the codecContext->thread_count = 1 workaround but in Blender it can cause memory leak, Or you can try to decode png several time until this is finally decoded properly. That's the solution I used. It's not elegant but it seems that works. What do you think about it? I'll ask IRC to have other devs opinion about that.
This issue was referenced by
e443dd4d97
Changed status from 'Open' to: 'Resolved'