Bug 499658

Summary: Crash when closing a playing animation while more than 1 document tab is open
Product: [Applications] krita Reporter: cromachina
Component: AnimationAssignee: Emmet O'Neill <emmetoneill.pdx>
Status: RESOLVED FIXED    
Severity: crash CC: emmetoneill.pdx, penguinflyer2222
Priority: NOR    
Version First Reported In: 5.2.9   
Target Milestone: ---   
Platform: NixOS   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:
Attachments: Crash callstack data and test KRA files

Description cromachina 2025-02-07 18:36:52 UTC
Created attachment 178056 [details]
Crash callstack data and test KRA files

SUMMARY
If an animation is playing while two documents are open, and you close the active document, Krita will crash.
Attached are two of the same KRA documents to test with, along with the crash log from drkonqi.

STEPS TO REPRODUCE
1. Open two documents with animations.
2. Play one of the document's animation.
3. Click the close button on the document's tab.

OBSERVED RESULT
Crash.

EXPECTED RESULT
The document closes without issue.

SOFTWARE/OS VERSIONS
Operating System: NixOS 25.05
KDE Plasma Version: 6.2.5
KDE Frameworks Version: 6.10.0
Qt Version: 6.8.1
Kernel Version: 6.12.12 (64-bit)
Graphics Platform: X11
Processors: 24 × AMD Ryzen 9 3900X 12-Core Processor
Memory: 62.7 GiB of RAM
Graphics Processor: AMD Radeon RX 7900 XTX

ADDITIONAL INFORMATION
Crash location:
Thread 1 (Thread 0x7fc00812a8c0 (LWP 59728)):
[KCrash Handler]
#4  0x0000000000000000 in ?? ()
#5  0x00007fc00dd769aa in CanvasPlaybackEnvironment::restore() () from /nix/store/gkhgzaiqg0h8mx3v4yx0mzvplg8bdg1s-krita-unwrapped-5.2.9/lib/libkritaui.so.19
#6  0x00007fc00dd751cd in KisCanvasAnimationState::~KisCanvasAnimationState() () from /nix/store/gkhgzaiqg0h8mx3v4yx0mzvplg8bdg1s-krita-unwrapped-5.2.9/lib/libkritaui.so.19
Comment 1 Emmet O'Neill 2025-03-14 00:35:19 UTC
Git commit 33cb2b2fafed33368669b9b923371fad3f9aa513 by Emmet O'Neill.
Committed on 14/03/2025 at 00:31.
Pushed by emmetoneill into branch 'master'.

Fixed crash on closing secondary animated document during playback.

I think this crash had to do with the lifetime of the
frame cache being longer than that of the canvas animation state.
Manually clearly the canvas animation state fixes it.

M  +6    -0    libs/ui/canvas/kis_canvas2.cpp

https://invent.kde.org/graphics/krita/-/commit/33cb2b2fafed33368669b9b923371fad3f9aa513