Bug 446472

Summary: Playback stutters when adding additional frames
Product: [Applications] krita Reporter: oliverpete
Component: AnimationAssignee: Krita Bugs <krita-bugs-null>
Status: RESOLVED NOT A BUG    
Severity: normal CC: ghevan
Priority: NOR    
Version: 5.0.0-beta5   
Target Milestone: ---   
Platform: macOS (DMG)   
OS: macOS   
Latest Commit: Version Fixed In:
Sentry Crash Report:
Attachments: The original Krita file and the video showing the issue

Description oliverpete 2021-12-04 13:01:05 UTC
SUMMARY
***
The playback skips random frames, the playback is not smooth. 
***

STEPS TO REPRODUCE
1. create normal frames
2. press play
3. add additional frames in-between the first created frames

OBSERVED RESULT
When playing the animation, it skips frames.

EXPECTED RESULT
It should play without skipping/stutter.


ADDITIONAL INFORMATION
It seems to happen when I create new frames between 2 existent frames (as if the cache didn’t recognise the newly added frame). Even if I 'clear cache', it doesn't solve the playback issue.
This way, I cannot correctly preview my animations. By the way, I have ‘Autokey Blank’ on.

This bug/issue didn't happen on 4.4.7 (the previous version I had installed)

The timeline also stutters a bit, and you can see that it is skipping some frames. 

However, If I render the animation, it renders all the frames.
Comment 1 oliverpete 2021-12-17 09:55:21 UTC
Created attachment 144618 [details]
The original Krita file and the video showing the issue

This zip contains the original Krita file and the video showing the issue.
I've created an animation with numbers, from 1 to 12. The playback is normal, as expected.
Then, I added circles between the frames that have numbers. When I playback, it stutters and skips random frames.
Comment 2 vanyossi 2021-12-17 20:26:34 UTC
Hi! I did some tests on your files and sadly I cannot reproduce it with your files, but I on an extra big canvas... I got the same results on the first playback, on the second playback I could see the animation totally smooth. This only happens on very large canvases and it seems its reaching the limits of the hardware.

I tested some other configurations, with smaller and bigger images and I could not reproduce it, then I went back to my original failing test image and I could not reproduce it either there. From what I gather krita animation playback is CPU intensive the bigger it is and this starts to compete for resource with other programs, make it drop animation frames on some workloads.

For testing I recorded with OBS at 60ish fps - software rendering, and was able to record the issue, however without obs software workload the issue is non-existant. This is on an M1 mac Mini.

Just for the record, could you share the info at "Help ->  Show system information for bug reports"?
Comment 3 vanyossi 2021-12-17 23:48:07 UTC
I'm closing this report, the functionality is working and the code is doing what its supposed to. Of course there is always room for improvement and we would be happy to discuss ways of optimizing the playback rendering, or better yet accept contributions to enhance the animation experience on complex and big files.
Comment 4 oliverpete 2021-12-18 14:37:20 UTC
This problem was non existent with previous versions of Krita. The canvas is 2400x1350 (55,6MiB) so it shouldn't be reaching the limit. I usually check the bottom bar when it warns about reaching the limits and that was not the case...

Might be something related to settings in the Animation Cache? I have On-disk / limit cached frame size: 2500px / Use region of interest: 25% / Enable background cache generation.

Thanks!
Comment 5 oliverpete 2021-12-18 16:15:29 UTC
So, I've changed the swap file size from 4gb to 20gb and I haven't noticed the stutter for now. Is this change relevant?
Comment 6 oliverpete 2021-12-18 16:18:41 UTC
Sorry, still stutters randomly. Sometimes works as expected, others don't...
Comment 7 oliverpete 2021-12-18 16:30:48 UTC
Sorry to bother again, but I am having some extra time to test it and found out something strange:

IF:
1) press play to start the animation
2) I clear the cache (I have assigned a keyboard shortcut)

It plays correctly. IMPORTANT: It only happens if I clear the cache when the animation is playing.

BUT:
When I stop the animation and press play again, a box saying 'Regenerating Cache' appears and the stutter starts again.
Sometimes the regenerating cache box stops at 95% and I have to press ESC to make the box disappear.

So, it has nothing to do with the hardware, because I can play it correctly if following those first steps.
Comment 8 vanyossi 2021-12-19 17:21:40 UTC
I've tested on a couple of animations and it never happens, only on full system workloads (i.e. OBS + extreme size images) which is normal for any program when the system is overloaded. On normal conditions there is no stutter, which means the code is correct and working as expected. Afaik there was no core change on how the animation preview is generated, however canvas openGL rendering changed on the mac, and other krita aspects certainly changed from 4 to 5 which could affect how the rendering behaves in your system. But without information and access to your specific hardware it is impossible to know. You could try testing with "use texture buffer" disabled/enabled on Display preferences.

Also provide your system information: "Help ->  Show system information for bug reports"?

I'll ask around about the cache cleaning, it may be playback starts before regenerating the full cache which may cause a bottleneck if the frame data is huge.
Comment 9 oliverpete 2021-12-20 12:50:07 UTC
Krita
  Version: 5.0.0-beta5

Qt
  Version (compiled): 5.12.12
  Version (loaded): 5.12.12

OS Information
  Build ABI: x86_64-little_endian-lp64
  Build CPU: x86_64
  CPU: x86_64
  Kernel Type: darwin
  Kernel Version: 17.7.0
  Pretty Productname: macOS High Sierra (10.13)
  Product Type: osx
  Product Version: 10.13


OpenGL Info
 
  Vendor:  "ATI Technologies Inc." 
  Renderer:  "AMD Radeon HD 6750M OpenGL Engine" 
  Version:  "4.1 ATI-1.68.25" 
  Shading language:  "4.10" 
  Requested format:  QSurfaceFormat(version 3.2, options QFlags<QSurfaceFormat::FormatOption>(), depthBufferSize 24, redBufferSize 8, greenBufferSize 8, blueBufferSize 8, alphaBufferSize 8, stencilBufferSize 8, samples -1, swapBehavior QSurfaceFormat::DoubleBuffer, swapInterval 0, colorSpace QSurfaceFormat::DefaultColorSpace, profile  QSurfaceFormat::CoreProfile) 
  Current format:  QSurfaceFormat(version 4.1, options QFlags<QSurfaceFormat::FormatOption>(), depthBufferSize 24, redBufferSize 8, greenBufferSize 8, blueBufferSize 8, alphaBufferSize 8, stencilBufferSize 8, samples 0, swapBehavior QSurfaceFormat::DoubleBuffer, swapInterval 0, colorSpace QSurfaceFormat::DefaultColorSpace, profile  QSurfaceFormat::CoreProfile) 
     Version: 4.1
     Supports deprecated functions false 
     is OpenGL ES: false 
  supportsBufferMapping: true 
  supportsBufferInvalidation: false 
  Extensions: 
     "GL_ARB_internalformat_query" 
     "GL_ARB_gpu_shader5" 
     "GL_ARB_ES2_compatibility" 
     "GL_ARB_instanced_arrays" 
     "GL_ARB_vertex_type_2_10_10_10_rev" 
     "GL_ARB_texture_rgb10_a2ui" 
     "GL_ARB_shader_subroutine" 
     "GL_APPLE_flush_render" 
     "GL_EXT_texture_sRGB_decode" 
     "GL_ARB_transform_feedback2" 
     "GL_APPLE_texture_range" 
     "GL_ARB_texture_buffer_object_rgb32" 
     "GL_ARB_texture_query_lod" 
     "GL_NV_texture_barrier" 
     "GL_EXT_texture_mirror_clamp" 
     "GL_ARB_transform_feedback3" 
     "GL_APPLE_container_object_shareable" 
     "GL_ARB_texture_swizzle" 
     "GL_ARB_sampler_objects" 
     "GL_ARB_draw_buffers_blend" 
     "GL_EXT_texture_compression_s3tc" 
     "GL_ATI_texture_mirror_once" 
     "GL_ARB_viewport_array" 
     "GL_APPLE_object_purgeable" 
     "GL_ARB_shader_bit_encoding" 
     "GL_EXT_debug_label" 
     "GL_APPLE_rgb_422" 
     "GL_EXT_texture_filter_anisotropic" 
     "GL_ARB_texture_gather" 
     "GL_APPLE_client_storage" 
     "GL_ARB_occlusion_query2" 
     "GL_ARB_separate_shader_objects" 
     "GL_ARB_tessellation_shader" 
     "GL_ARB_texture_storage" 
     "GL_ARB_sample_shading" 
     "GL_EXT_debug_marker" 
     "GL_APPLE_row_bytes" 
     "GL_ARB_blend_func_extended" 
     "GL_ARB_texture_cube_map_array" 
     "GL_ARB_timer_query" 
     "GL_ARB_draw_indirect" 
     "GL_ARB_shading_language_include" 
     "GL_ARB_explicit_attrib_location" 

QPA OpenGL Detection Info 
  supportsDesktopGL: true 
  supportsOpenGLES: false 
  isQtPreferOpenGLES: true 

Hardware Information
 Memory: 12 Gb
 Cores: 4
 Swap: /private/var/folders/wb/49_9_nv10dsbrk_jtfxks5mm0000gn/T
Comment 10 oliverpete 2021-12-30 23:13:57 UTC
The "texture buffer" disabled solved the issue! Thanks Vanyossi for all your time and patience. It was driving me nuts.
Now it works flawlessly!