Bug 436965 - When crashing Krita during video import, it leaves a ton of video import files behind.
Summary: When crashing Krita during video import, it leaves a ton of video import file...
Status: RESOLVED FIXED
Alias: None
Product: krita
Classification: Applications
Component: Animation (show other bugs)
Version: git master (please specify the git hash!)
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: Krita Bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-05-12 12:41 UTC by wolthera
Modified: 2022-01-11 22:28 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description wolthera 2021-05-12 12:41:25 UTC
SUMMARY
There's a ton of video import temp pngs left behind when Krita crashes or is OOM-Killed during video import.

STEPS TO REPRODUCE
1. Select a large amount of frames from a video file. Too many, infact.
2. Import them all. (or just kill Krita from the terminal while it imports)
3. Watch Krita kill itself.
4. Check the folder of the video file to find a ton of temp files.

I have no idea how we'd really fix this, outside of maybe only extracting a small number of frames at a time and importing those first before heading towards the next set.
Comment 1 Eoin O'Neill 2021-05-13 01:20:01 UTC
The solution here would be to do frame extraction in batches and also restrict the number of frames.

I might also look into ways to see if ffmpeg can be smart about skipping frames that are equivalent to a certain threshold...
Comment 2 Eoin O'Neill 2022-01-06 02:55:44 UTC
Looking into this more, having now optimized the FFMPEG to import less frames (optionally) for longer files on my own branch, another solution is to properly use the temp directories at krita's disposal. 

At least on linux, these temp directories will be cleaned up after system reboot.
Comment 3 Eoin O'Neill 2022-01-07 02:41:41 UTC
Git commit b6b1f2355e0118f23c39a002273f0ad1b1c9edfa by Eoin O'Neill.
Committed on 06/01/2022 at 23:23.
Pushed by eoinoneill into branch 'master'.

Initial proof-of-concept of keyframe detection and duplicate frame removal
during video import process.

Steps remaining...
1) Plug UI in with meaningful value range for users to tweak.
2) Use frame file names to determine position within file, and insert accordingly.
... And more?

This should help people when importing animations that are long and repetitive. They might
not need every single duplicate frame, depending on their user case. Users will be able
to dial in sensitivity to adjust to their liking.

M  +3    -2    libs/ui/animation/KisDlgImportVideoAnimation.cpp
M  +102  -37   libs/ui/animation/VideoImportDialog.ui

https://invent.kde.org/graphics/krita/commit/b6b1f2355e0118f23c39a002273f0ad1b1c9edfa
Comment 4 Eoin O'Neill 2022-01-11 22:28:09 UTC
Git commit 86db9358f2fea2b528346a5f7351dcbe58948316 by Eoin O'Neill.
Committed on 11/01/2022 at 21:55.
Pushed by eoinoneill into branch 'master'.

Use QTemporaryDir class instead of manual temporary directory management.

Should help w/ preventing file leakage. In odd case that it does crash on
import, QTemporaryDir should safely clean up files (and, if not, files should
at least be cleaned on reboot.)

M  +5    -5    libs/ui/KisMainWindow.cpp
M  +5    -15   libs/ui/animation/KisDlgImportVideoAnimation.cpp
M  +1    -4    libs/ui/animation/KisDlgImportVideoAnimation.h

https://invent.kde.org/graphics/krita/commit/86db9358f2fea2b528346a5f7351dcbe58948316