pencil2d / pencil

Pencil2D is an easy, intuitive tool to make 2D hand-drawn animations. Pencil2D is open source and cross-platform.
http://pencil2d.org
GNU General Public License v2.0
1.45k stars 271 forks source link

[BUG] Cross-platform Memory Leak Crash-Wipe Issue #520

Open Jose-Moreno opened 8 years ago

Jose-Moreno commented 8 years ago

--Issue Overview--

This is perhaps the most complex bug to date in Pencil2D, there are several case-scenarios that need to be addressed, but I believe they all relate to the same memory management problem within Pencil2D.

CASE A: Pencil2D Save & Silent File Wipe:

In this case, several reports indicate that people have been saving their files "normally" in different OS, however when they reopen the files everything inside the file has been erased without a clear error warning.

Reference Forum Threads:

CASE B: Pencil2D Crash & File Wipe / Corruption

In this case Pencil distinctively crashes once and completely corrupts the PCL file, as well as the .data folder and every other file inside of it.

Reference Forum Threads:

CASE C: Pencil2D Crash, Working File, Crashes when Opened.

In this case, Pencil2D crashes (most likely due to the memory leak) and when people try to open the file the file jsut won't open and Pencil crashes again. However the file is still potentially working, a.k.a not corrupted. It seems there is a distinct relationship of this branch of the problem appearing due to the new PCLX filetype and how it handles the information contained within, but it has also happened with PCL files.

--System Information-- Pencil2D Nightly Build 1st JULY 2016 (I can reproduce CASE C with this version) Windows 7 64bits SP1 ATI Radeon HD 6770 1GB AMD Phenom II X4 965 BE 3.4 GHZ 4 GB RAM

chchwy commented 8 years ago

OK, thank you @Jose-Moreno for so many clues. I'll try to fix the case C first, and keep track on other 2 cases.

Jose-Moreno commented 8 years ago

@chchwy I forgot that Case B had a password. The password is "pencil" without quotes.

Last week someone reported they had another crash and it soft-wiped their pencil file only. This happened when coloring. I've read accounts on tumblr that describe a similar occurence when they tried to color. Everytime it happens when they have a lot of frames. I think we have to review how Pencil2D manages the memory allocation of images, because I've made tests on my own and everytime I create a bunch of new empty frames the memory footprint left by the software becomes huge. Considering that it is also reading and writing data constantly there must be a way to optimize and thus eliminate these much hated crashes.

I'm trying to advertise for coders without much luck and I'm really busy due to my job so I can't be helping as much as I want. Hope things are well, talk to you soon!

edwrodrig commented 7 years ago

I'm really interested in solving this issues to use be able to use this software at work.

For CASE A.I think that some complex error or memory exhaustation is causing error at loading file. When an error at loading happends then call this function.

Object* FileManager::cleanUpWithErrorCode( Status error ) { mError = error; removePFFTmpDirectory( mstrLastTempFolder ); return nullptr; }

and could cause deletion of project files.

chchwy commented 7 years ago

Case C fixed. 20891445508a9e238f67fd3491ec8a409684f9fa

Jose-Moreno commented 6 years ago

[2018 Review] For the past 2 years thanks to chchwy's work these cases have become less and less.

Case B seems to remain elusive but lately the only thing that happens is that the XML file disappears, so at least the whole project does not corrupt and makes it possible to extract the files, however a secondary coordinate file (an autosaved backup text file or similar) would be great.

For CASE A, I think that it might still have to do with the new save bug, it's just that perhaps before the thing crashed silently and corrupted the files, whereas today the manager is crashing first so even though people can't save, the project as a whole is not getting damaged (theya r eonly losing their session work).

Once we fix those I'll close this as I think lately there's not been a single report where the projects have been wiped clean like before.