Bug 464032 - Tried to save while dragging over the frames to play back certain part of animation.
Summary: Tried to save while dragging over the frames to play back certain part of ani...
Status: RESOLVED FIXED
Alias: None
Product: krita
Classification: Applications
Component: Animation (show other bugs)
Version: 5.1.5
Platform: Microsoft Windows Microsoft Windows
: NOR crash
Target Milestone: ---
Assignee: Dmitry Kazakov
URL:
Keywords:
: 465199 (view as bug list)
Depends on:
Blocks:
 
Reported: 2023-01-09 01:56 UTC by Naps
Modified: 2023-07-14 07:40 UTC (History)
4 users (show)

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


Attachments
Saving while having multiple frames highlighted causes crash sometimes. (282.45 KB, text/plain)
2023-01-09 01:56 UTC, Naps
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Naps 2023-01-09 01:56:51 UTC
Created attachment 155124 [details]
Saving while having multiple frames highlighted causes crash sometimes.

SUMMARY
***
NOTE: If you are reporting a crash, please try to attach a backtrace with debug symbols.
See https://community.kde.org/Guidelines_and_HOWTOs/Debugging/How_to_create_useful_crash_reports
***


STEPS TO REPRODUCE
1. Highlight Frames
2. Save / Or get unlucky with an auto save while playing back frames
3. Crash 
 

OBSERVED RESULT
Krita tried hard to save but failed and crashing.

EXPECTED RESULT
Krita saving and the frames playing back.

SOFTWARE/OS VERSIONS
Windows: 10
KDE Plasma Version: 
KDE Frameworks Version: 
Qt Version: 5.12.12

ADDITIONAL INFORMATION
Had a low resolution video on YouTube playing, Krita was not in full screen and computer was on for a while with out restart or shutdown.
when crash happened entire computer started to lag, Krita also lagged really badly when reopening app on steam.
This has happen other times as well in the past but usually when I already saved. When ever I try to save while highlighting frames and tried to play back when an auto save or manual save occurs. When reopening app in steam it did not provide a recovery to file I was working on.
Comment 1 Naps 2023-01-09 02:09:34 UTC
Forgot to mention when opening Krita on steam it sometimes just doesn't open and just sits there loading until i press stop.
Comment 2 wolthera 2023-01-10 20:40:27 UTC
Ok, there's multiple types of crashes in that log. I think your last comment is caused by this one in the RSS news widget:

> Error occurred on Wednesday, June 30, 2021 at 20:49:05.
> krita.exe caused an Access Violation at location 00007FFD7C61DF87 in module libkritaui.dll Reading from location 0000000000000000.
> AddrPC           Params
> 00007FFD7C61DF87 000000001D6782D0 00007FFD7EEAD0EB 0000000000600000  libkritaui.dll!0x3adf87 MultiFeedRssModel::data+0x37
> 00007FFD7303DFCD 0000000018E49A40 0000000002999990 0000000002AC96C0  Qt5Widgets.dll!0x23dfcd QStyledItemDelegate::initStyleOption+0x4d

However, the most important crash (which shows up twice) is:

> AddrPC           Params
> 00007FFC0EE30AA0 000002D6BD6D0000 000002D600000000 0000000000000020  libkritaui.dll!KisFrameDataSerializer::processFrames<std::__1::minus>+0x140
> 00007FFC0EE318AE 000000ECB9BE72D0 000000ECB9BE7220 000002D6D2E560D0  libkritaui.dll!KisFrameCacheStore::saveFrame+0x57e
> 00007FFC0EE33AC5 000000ECB9BE7180 000002D60000009B 000002D6E18CA820  libkritaui.dll!KisFrameCacheSwapper::saveFrame+0x25
> 00007FFC0EE17EEF 000000ECB9BE72D0 0000000000000000 0000000000000000  libkritaui.dll!KisAnimationFrameCache::Private::addFrame+0x10f
> 00007FFC0EE172EA 000002D6BF12A601 00007FFC0D90800F 000002D6C5A24C90  libkritaui.dll!KisAnimationFrameCache::addConvertedFrameData+0x7a
> 00007FFC0EE1B17B 0000000000000000 000000FA0CCAB001 000002D6E1348A70  libkritaui.dll!KisAsyncAnimationCacheRenderer::slotCompleteRegenerationInternal+0x3b
> 00007FFC0D8FAB04 000000ECB9BEF5C8 000002D6C5A24C90 000002D6BD5CB860  Qt5Core.dll!QObject::event+0x294

There's also a number of opengl crashes:

> 00007FFAE2E01140 0000019A90DF1BD8 0000000000000000 0000019A97B343F0  Qt5Gui.dll!QOpenGLContext::shareGroup+0x0
> 00007FFAE30CB5D9 0000019A909ED4A8 0000019A83BE77F0 0000019A828709A0  Qt5Gui.dll!QOpenGLMultiGroupSharedResource::value<QOpenGLFunctionsPrivateEx>+0x19
> 00007FFAE30CAD30 00000064A8BBB8F0 00000064A8BBB8F0 00000064A8BBB8F0  Qt5Gui.dll!QOpenGLFunctions::initializeOpenGLFunctions+0x30
> 00007FFAE5A2BA46 00000064A8BB7AD8 00007FFAEB4FCF3A 0000019AA4EE7910  libkritaui.dll!KisTextureTile::update+0x26

I'm going to assign Emmet because I am not familiar enough with the animation code. I'll take a look at the RSS crash...
Comment 3 wolthera 2023-01-10 20:48:53 UTC
Git commit 37502fdca64bab3312d4dadc698cc8f8758b0386 by Wolthera van Hövell.
Committed on 10/01/2023 at 20:48.
Pushed by woltherav into branch 'bug-464032-potential-rss-feed-crash-fix'.

Fix potential crash in RSS Feed reader

M  +34   -33   libs/ui/KisMultiFeedRSSModel.cpp

https://invent.kde.org/graphics/krita/commit/37502fdca64bab3312d4dadc698cc8f8758b0386
Comment 4 Bug Janitor Service 2023-01-10 20:51:53 UTC
A possibly relevant merge request was started @ https://invent.kde.org/graphics/krita/-/merge_requests/1713
Comment 5 Dmitry Kazakov 2023-01-11 08:25:32 UTC
Git commit e71e0f60daf90c5bc98c685ff0e238dd622462a2 by Dmitry Kazakov, on behalf of Wolthera van Hövell.
Committed on 11/01/2023 at 08:25.
Pushed by dkazakov into branch 'master'.

Fix potential crash in RSS Feed reader

M  +34   -33   libs/ui/KisMultiFeedRSSModel.cpp

https://invent.kde.org/graphics/krita/commit/e71e0f60daf90c5bc98c685ff0e238dd622462a2
Comment 6 Naps 2023-01-23 17:55:52 UTC
(In reply to wolthera from comment #2)
> Ok, there's multiple types of crashes in that log. I think your last comment
> is caused by this one in the RSS news widget:
> 
> > Error occurred on Wednesday, June 30, 2021 at 20:49:05.
> > krita.exe caused an Access Violation at location 00007FFD7C61DF87 in module libkritaui.dll Reading from location 0000000000000000.
> > AddrPC           Params
> > 00007FFD7C61DF87 000000001D6782D0 00007FFD7EEAD0EB 0000000000600000  libkritaui.dll!0x3adf87 MultiFeedRssModel::data+0x37
> > 00007FFD7303DFCD 0000000018E49A40 0000000002999990 0000000002AC96C0  Qt5Widgets.dll!0x23dfcd QStyledItemDelegate::initStyleOption+0x4d
> 
> However, the most important crash (which shows up twice) is:
> 
> > AddrPC           Params
> > 00007FFC0EE30AA0 000002D6BD6D0000 000002D600000000 0000000000000020  libkritaui.dll!KisFrameDataSerializer::processFrames<std::__1::minus>+0x140
> > 00007FFC0EE318AE 000000ECB9BE72D0 000000ECB9BE7220 000002D6D2E560D0  libkritaui.dll!KisFrameCacheStore::saveFrame+0x57e
> > 00007FFC0EE33AC5 000000ECB9BE7180 000002D60000009B 000002D6E18CA820  libkritaui.dll!KisFrameCacheSwapper::saveFrame+0x25
> > 00007FFC0EE17EEF 000000ECB9BE72D0 0000000000000000 0000000000000000  libkritaui.dll!KisAnimationFrameCache::Private::addFrame+0x10f
> > 00007FFC0EE172EA 000002D6BF12A601 00007FFC0D90800F 000002D6C5A24C90  libkritaui.dll!KisAnimationFrameCache::addConvertedFrameData+0x7a
> > 00007FFC0EE1B17B 0000000000000000 000000FA0CCAB001 000002D6E1348A70  libkritaui.dll!KisAsyncAnimationCacheRenderer::slotCompleteRegenerationInternal+0x3b
> > 00007FFC0D8FAB04 000000ECB9BEF5C8 000002D6C5A24C90 000002D6BD5CB860  Qt5Core.dll!QObject::event+0x294
> 
> There's also a number of opengl crashes:
> 
> > 00007FFAE2E01140 0000019A90DF1BD8 0000000000000000 0000019A97B343F0  Qt5Gui.dll!QOpenGLContext::shareGroup+0x0
> > 00007FFAE30CB5D9 0000019A909ED4A8 0000019A83BE77F0 0000019A828709A0  Qt5Gui.dll!QOpenGLMultiGroupSharedResource::value<QOpenGLFunctionsPrivateEx>+0x19
> > 00007FFAE30CAD30 00000064A8BBB8F0 00000064A8BBB8F0 00000064A8BBB8F0  Qt5Gui.dll!QOpenGLFunctions::initializeOpenGLFunctions+0x30
> > 00007FFAE5A2BA46 00000064A8BB7AD8 00007FFAEB4FCF3A 0000019AA4EE7910  libkritaui.dll!KisTextureTile::update+0x26
> 
> I'm going to assign Emmet because I am not familiar enough with the
> animation code. I'll take a look at the RSS crash...
Comment 7 Naps 2023-01-23 17:58:26 UTC
Thank you for looking into this, I'm new so how do I look up the solution To the RSS widget for potential fixing of crashing when booting up Krita?
Comment 8 Naps 2023-01-23 18:05:02 UTC
(In reply to Naps from comment #7)
> Thank you for looking into this, I'm new so how do I look up the solution To
> the RSS widget for potential fixing of crashing when booting up Krita.
Comment 9 Halla Rempt 2023-03-06 11:38:51 UTC
Ah, you will have to use the krita next nightly build (https://binary-factory.kde.org/job/Krita_Nightly_Windows_Build/) because that has the fix in it -- though it's not complete since your log shows several different crashes, and the one in the animation part still needs to be fixed by Emmet.
Comment 10 Dmitry Kazakov 2023-07-06 10:47:07 UTC
According to the disassembly, it seems like the crash happens in KisFrameDataSerializer::processData, around line 923. Either src or dst pointer is null.
Comment 11 Dmitry Kazakov 2023-07-07 09:48:00 UTC
Just an additional info: it seems like `m_d->lastSavedFullFrame` gets a null pointer internally somehow in KisFrameCacheStore
Comment 12 Dmitry Kazakov 2023-07-07 10:40:57 UTC
It looks like the fix for bug 436283 actually covers cause of this bug.
Comment 13 Dmitry Kazakov 2023-07-07 15:15:15 UTC
Okay, I found the reason of this bug: it is a duplicate of bug 436283. The solution of bug 436283 just hidden the real cause of the crash making it hard to track down.

The problem happens when `KisAnimationCachePopulator` and `KisAsyncAnimationCacheRenderDialog` start regeneration of the cache in parallel. It may happen under some weird circumstances, when the user presses the "Play" button while the populator is being generating frames.

The solution should be twofold:

1) `KisAsyncAnimationRendererBase::notifyFrameCompleted` should properly release resources on stumbling on the assert (which will avoid double-use of the same `m_d->requestInfo`).

2) Frame and cache regeneration should somehow be handled in universal way to avoid double start of the regeneration process.
Comment 14 Dmitry Kazakov 2023-07-07 15:29:23 UTC
Git commit ec5c5c58527cf8b283f70dff155d8e7d4a1a66be by Dmitry Kazakov.
Committed on 07/07/2023 at 15:20.
Pushed by dkazakov into branch 'master'.

Add an assert for early catching of concurrent animation generation issue

M  +2    -0    libs/ui/KisFrameCacheStore.cpp

https://invent.kde.org/graphics/krita/-/commit/ec5c5c58527cf8b283f70dff155d8e7d4a1a66be
Comment 15 Dmitry Kazakov 2023-07-11 12:56:10 UTC
Git commit 6500d2e7bef52ef1e05a1186b9a32274a5396f13 by Dmitry Kazakov.
Committed on 11/07/2023 at 12:54.
Pushed by dkazakov into branch 'master'.

Fix asserts in KisAsyncAnimationRendererBase to clean resources

The patch also implements `kismpl::finally` wrapper that behaves
like java's 'finally' block, but in C++ way.

M  +22   -0    libs/global/KisMpl.h
M  +20   -6    libs/ui/KisAsyncAnimationRendererBase.cpp

https://invent.kde.org/graphics/krita/-/commit/6500d2e7bef52ef1e05a1186b9a32274a5396f13
Comment 16 Dmitry Kazakov 2023-07-11 12:56:18 UTC
Git commit f54e8cf230c9b3d8a1ef433f1a283579f316a593 by Dmitry Kazakov.
Committed on 11/07/2023 at 12:54.
Pushed by dkazakov into branch 'master'.

Fix crashes when trying to play animation

The sequence of event was really complicated. It turned out that under some
rare circumstances background cache populator and the interactive
cache generation could start the generation process concurrently. It
caused the following:

1) KisAsyncAnimationRendererBase::notifyFrameCompleted() caught an
   "unexpected frame" assert:

   KIS_SAFE_ASSERT_RECOVER_RETURN(m_d->requestedFrame == frame);

2) Triggering this assert skipped the clearFrameRegenerationState() call

3) Skipping the clearFrameRegenerationState() call, caused the
   texturing info objects to be used twice. But, the textures
   caching uses a (home-grown) move-semantics, so, on the second call,
   the textures contained no actual data.

4) Null pointers in the data caused the crashes in the end.

5) Incorrect fix for bug 436283 (which was actually the same bug)
   actually hid the bug and moved the crash down the execution path,
   making it harder to track down.

The patch also implements a simple wrapper class KisAdaptedLock, which
allows converting any lockable object with non-standard interface
into std::unique_lock().

A  +92   -0    libs/global/KisAdaptedLock.h     [License: GPL(v2.0+)]
M  +3    -14   libs/global/KisCursorOverrideLock.h
M  +2    -0    libs/image/CMakeLists.txt
A  +24   -0    libs/image/KisBlockBackgroundFrameGenerationLock.cpp     [License: GPL(v2.0+)]
A  +37   -0    libs/image/KisBlockBackgroundFrameGenerationLock.h     [License: GPL(v2.0+)]
A  +30   -0    libs/image/KisLockFrameGenerationLock.cpp     [License: GPL(v2.0+)]
A  +35   -0    libs/image/KisLockFrameGenerationLock.h     [License: GPL(v2.0+)]
M  +37   -2    libs/image/kis_image_animation_interface.cpp
M  +65   -1    libs/image/kis_image_animation_interface.h
M  +5    -1    libs/image/kis_regenerate_frame_stroke_strategy.cpp
M  +5    -2    libs/image/kis_regenerate_frame_stroke_strategy.h
M  +4    -4    libs/ui/KisAsyncAnimationRendererBase.cpp
M  +3    -2    libs/ui/KisAsyncAnimationRendererBase.h
M  +1    -1    libs/ui/KisDocument.cpp
M  +17   -1    libs/ui/dialogs/KisAsyncAnimationRenderDialogBase.cpp
M  +43   -17   libs/ui/kis_animation_cache_populator.cpp
M  +2    -2    libs/ui/kis_async_action_feedback.cpp
M  +42   -1    libs/ui/kis_async_action_feedback.h
M  +10   -2    plugins/dockers/storyboarddocker/KisStoryboardThumbnailRenderScheduler.cpp

https://invent.kde.org/graphics/krita/-/commit/f54e8cf230c9b3d8a1ef433f1a283579f316a593
Comment 17 Dmitry Kazakov 2023-07-14 07:40:40 UTC
*** Bug 465199 has been marked as a duplicate of this bug. ***