Bug 473484

Summary: Krita 5.2.0-beta 2 closes when trying to open animation file.
Product: [Applications] krita Reporter: electricdragon160
Component: AnimationAssignee: Emmet O'Neill <emmetoneill.pdx>
Status: RESOLVED FIXED    
Severity: crash CC: anistagea_dean, dimula73, emmetoneill.pdx
Priority: NOR Keywords: regression, release_blocker
Version First Reported In: 5.2.0-beta2   
Target Milestone: ---   
Platform: Microsoft Windows   
OS: Microsoft Windows   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:
Attachments: Bug report:

Description electricdragon160 2023-08-17 17:26:59 UTC
Created attachment 161030 [details]
Bug report:

SUMMARY
***
Upon opening an animation file, Krita attempts to load it for a couple seconds, before closing. No crash report was created, however I attached a bug report. I tried this multiple times with different files with no change. This issue came up upon testing version 5.2.0-beta 2. 
***


STEPS TO REPRODUCE
1. Open Krita and select an existing animation document, either from the recent files tab or file explorer. 


OBSERVED RESULT
Krita attempts to load the file and closes soon after. 

EXPECTED RESULT
The animation file is opened normally. 

SOFTWARE/OS VERSIONS
Windows: 11 Home, version 22H2
Comment 1 Emmet O'Neill 2023-08-18 21:27:43 UTC
Hi there, thanks for the bug report!

I haven't been able to reproduce this on my end, checking both Linux and Windows versions.
But from these lines in you attachment, it seems like we're failing an assertion somehow, which is causing a crash:

```
17 Aug 2023 12:10:13 -0400: SAFE ASSERT (krita): "animState" in file C:/Packaging/workspace/Krita_Release_Windows64_Build/krita/libs/ui/KisPlaybackEngine.cpp, line 306
17 Aug 2023 12:10:13 -0400: ASSERT (krita): "animationState" in file C:/Packaging/workspace/Krita_Release_Windows64_Build/krita/libs/ui/KisPlaybackEngineMLT.cpp, line 412
```

I'll double check that we aren't making any bad assumptions there and hopefully that'll fix the problem that you're running into before the end of the beta.

(Setting this to "assigned" as I plan on looking into it more next week.)
Comment 2 Dmitry Kazakov 2023-08-22 13:07:14 UTC
Hi, electricdragon160!

Could you please share the animation file that you use to reproduce this crash? I cannot reproduce the issue with the test file I have. If your file should be kept private, you can send it to my email directly dimula73 at gmail dot com
Comment 3 Dmitry Kazakov 2023-08-22 13:13:18 UTC
Hi, electricdragon160!

Please discard my previous comment, I have managed to reproduce the issue.

The issue happens when opening an animation file with audio. Krita tries to upgrade an animation engine from normal to MLT one, but it happens before the canvas got properly initialized, hence, the assert.

As a temporary workaround:
1) Open Krita
2) Create an empty document
3) Add any audio to this document
4) Close the document

From now on, Krita will be able to open any document with attached audio.
Comment 4 electricdragon160 2023-08-23 00:12:40 UTC
Hello Dmitry Kazakov,

The workaround provided worked! I can now open any animation file. Thank you so much for looking into it!(In reply to Dmitry Kazakov from comment #3)
> Hi, electricdragon160!
> 
> Please discard my previous comment, I have managed to reproduce the issue.
> 
> The issue happens when opening an animation file with audio. Krita tries to
> upgrade an animation engine from normal to MLT one, but it happens before
> the canvas got properly initialized, hence, the assert.
> 
> As a temporary workaround:
> 1) Open Krita
> 2) Create an empty document
> 3) Add any audio to this document
> 4) Close the document
> 
> From now on, Krita will be able to open any document with attached audio.

Hello Dmitry Kazakov,

The workaround provided worked! I can now open any animation file. Thank you so much for looking into it!
Comment 5 Emmet O'Neill 2023-08-23 01:29:31 UTC
Ok, I believe this has been fixed in master by deferring the loading of audio files until after the canvas has finished construction. 

commit: a8fcd53a094ddc3b2d841e0d779c05bb533dbfe9

Thanks again for the bug report, electricdragon. :)
If you'd like to try the fixed version, you can try out tomorrow's "Krita Next" nightly build.
Comment 6 Dmitry Kazakov 2023-08-23 07:28:26 UTC
The fix is pushed into both

master:
https://invent.kde.org/graphics/krita/-/commit/a8fcd53a094ddc3b2d841e0d779c05bb533dbfe9

and krita/5.2:
https://invent.kde.org/graphics/krita/-/commit/2c3c49c0c211b472673a58d7eb3ea980c514e7dc

I have triggered the stable nightly builds, so the package should be available here in about an hour:
https://binary-factory.kde.org/job/Krita_Stable_Windows_Build/1953/
Comment 7 Dmitry Kazakov 2023-08-28 08:13:34 UTC
*** Bug 473767 has been marked as a duplicate of this bug. ***