Bug 460624

Summary: Unable to save image with a small width
Product: [Applications] krita Reporter: Phil <scatcoder>
Component: GeneralAssignee: Lynx3d <lynx.mw+kde>
Status: RESOLVED FIXED    
Severity: major CC: amy, lynx.mw+kde
Priority: NOR    
Version: 5.1.1   
Target Milestone: ---   
Platform: Microsoft Windows   
OS: Microsoft Windows   
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description Phil 2022-10-17 20:33:05 UTC
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. Open Krita.
2. File->New
3. Set width to 32px, height to 8928.
(did not change color - was RGB/Alpha, 8-bit integer/channel, sRgb-elle-V2-srgbtrc.icc(Default))
4. Click Create.
5. File->Save
6. Choose a location and filename, format (any valid one will do, this has nothing to do with permissions or free space).
7. Select kra as type.
8. Click Save.


OBSERVED RESULT
Dialog with error:
"Error occurred while writing to the file."

EXPECTED RESULT
Save file created, no error.

SOFTWARE/OS VERSIONS
Windows: 
macOS: 
Linux/KDE Plasma: 
(available in About System)
KDE Plasma Version: 
KDE Frameworks Version: 
Qt Version: 

ADDITIONAL INFORMATION
The save works if you create a 100px width image.
Clean log file:
Krita

 Version: 5.1.1
 Installation type: installer / portable package
 Hidpi: true

Qt

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

OS Information

  Build ABI: x86_64-little_endian-llp64
  Build CPU: x86_64
  CPU: x86_64
  Kernel Type: winnt
  Kernel Version: 10.0.19044
  Pretty Productname: Windows 10 (10.0)
  Product Type: windows
  Product Version: 10

Locale

  Languages: en_US
  C locale: C
  QLocale current: en
  QLocale system: en
  QTextCodec for locale: UTF-8
  Process ACP: 65001 (UTF-8)
  System locale default ACP: 1252  (ANSI - Latin I)

OpenGL Info
 
  Vendor:  "Google Inc. (Intel)" 
  Renderer:  "ANGLE (Intel, Intel(R) Iris(R) Plus Graphics Direct3D11 vs_5_0 ps_5_0, D3D11-31.0.101.1999)" 
  Version:  "OpenGL ES 3.0.0 (ANGLE 2.1.0 git hash: f2280c0c5f93+krita_qt5.12.12)" 
  Shading language:  "OpenGL ES GLSL ES 3.00 (ANGLE 2.1.0 git hash: f2280c0c5f93+krita_qt5.12.12)" 
  Requested format:  QSurfaceFormat(version 3.0, options QFlags<QSurfaceFormat::FormatOption>(DeprecatedFunctions), depthBufferSize 24, redBufferSize 8, greenBufferSize 8, blueBufferSize 8, alphaBufferSize 8, stencilBufferSize 8, samples -1, swapBehavior QSurfaceFormat::DoubleBuffer, swapInterval 0, colorSpace QSurfaceFormat::DefaultColorSpace, profile  QSurfaceFormat::CompatibilityProfile) 
  Current format:  QSurfaceFormat(version 3.0, options QFlags<QSurfaceFormat::FormatOption>(), depthBufferSize 24, redBufferSize 8, greenBufferSize 8, blueBufferSize 8, alphaBufferSize 8, stencilBufferSize 8, samples 0, swapBehavior QSurfaceFormat::DefaultSwapBehavior, swapInterval 0, colorSpace QSurfaceFormat::DefaultColorSpace, profile  QSurfaceFormat::NoProfile) 
     Version: 3.0
     Supports deprecated functions false 
     is OpenGL ES: true 
  supportsBufferMapping: true 
  supportsBufferInvalidation: false 
  forceDisableTextureBuffers: true 
  Extensions: 
     "GL_EXT_map_buffer_range" 
     "GL_EXT_texture_compression_s3tc_srgb" 
     "GL_EXT_texture_compression_bptc" 
     "GL_ANGLE_multiview_multisample" 
     "GL_OES_depth32" 
     "GL_ANGLE_texture_multisample" 
     "GL_OES_compressed_ETC2_sRGB8_texture" 
     "GL_OES_draw_buffers_indexed" 
     "GL_EXT_robustness" 
     "GL_ANGLE_memory_size" 
     "GL_EXT_texture_norm16" 
     "GL_ANGLE_request_extension" 
     "GL_OES_draw_elements_base_vertex" 
     "GL_OES_element_index_uint" 
     "GL_OES_texture_npot" 
     "GL_CHROMIUM_sync_query" 
     "GL_EXT_blend_minmax" 
     "GL_OES_compressed_EAC_RG11_signed_texture" 
     "GL_CHROMIUM_bind_generates_resource" 
     "GL_EXT_texture_compression_rgtc" 
     "GL_EXT_discard_framebuffer" 
     "GL_OES_EGL_image_external" 
     "GL_ANGLE_framebuffer_blit" 
     "GL_EXT_color_buffer_half_float" 
     "GL_OES_fbo_render_mipmap" 
     "GL_EXT_draw_elements_base_vertex" 
     "GL_EXT_shader_texture_lod" 
     "GL_ANGLE_translated_shader_source" 
     "GL_EXT_blend_func_extended" 
     "GL_CHROMIUM_lose_context" 
     "GL_ANGLE_base_vertex_base_instance" 
     "GL_CHROMIUM_copy_texture" 
     "GL_EXT_multi_draw_indirect" 
     "GL_OES_depth24" 
     "GL_ANGLE_program_cache_control" 
     "GL_EXT_texture_format_BGRA8888" 
     "GL_ANGLE_copy_texture_3d" 
     "GL_EXT_draw_buffers_indexed" 
     "GL_OES_compressed_EAC_RG11_unsigned_texture" 
     "GL_ANGLE_framebuffer_multisample" 
     "GL_ANGLE_texture_compression_dxt5" 
     "GL_EXT_clip_control" 
     "GL_EXT_unpack_subimage" 
     "GL_ANGLE_get_serialized_context_string" 
     "GL_EXT_frag_depth" 
     "GL_EXT_texture_storage" 
     "GL_OES_texture_half_float_linear" 
     "GL_EXT_sRGB" 
     "GL_OES_texture_border_clamp" 
     "GL_WEBGL_video_texture" 
     "GL_OES_get_program_binary" 
     "GL_EXT_debug_label" 
     "GL_ANGLE_texture_compression_dxt3" 
     "GL_EXT_debug_marker" 
     "GL_ANGLE_depth_texture" 
     "GL_NV_fence" 
     "GL_OES_compressed_ETC2_punchthroughA_RGBA8_texture" 
     "GL_EXT_texture_rg" 
     "GL_OES_texture_stencil8" 
     "GL_ANGLE_base_vertex_base_instance_shader_builtin" 
     "GL_ANGLE_multi_draw" 
     "GL_NV_framebuffer_blit" 
     "GL_ANGLE_robust_client_memory" 
     "GL_NV_pack_subimage" 
     "GL_CHROMIUM_bind_uniform_location" 
     "GL_OES_EGL_image_external_essl3" 
     "GL_OES_texture_float_linear" 
     "GL_AMD_performance_monitor" 
     "GL_KHR_debug" 
     "GL_KHR_parallel_shader_compile" 
     "GL_ANGLE_provoking_vertex" 
     "GL_EXT_texture_compression_dxt1" 
     "GL_OES_texture_half_float" 
     "GL_ANGLE_texture_usage" 
     "GL_OES_vertex_array_object" 
     "GL_OVR_multiview" 
     "GL_OES_rgb8_rgba8" 
     "GL_ANGLE_get_tex_level_parameter" 
     "GL_EXT_disjoint_timer_query" 
     "GL_EXT_float_blend" 
     "GL_OES_compressed_EAC_R11_unsigned_texture" 
     "" 
     "GL_EXT_occlusion_query_boolean" 
     "GL_ANGLE_instanced_arrays" 
     "GL_OES_standard_derivatives" 
     "GL_OVR_multiview2" 
     "GL_EXT_color_buffer_float" 
     "GL_EXT_multisampled_render_to_texture" 
     "GL_OES_compressed_ETC2_sRGB8_alpha8_texture" 
     "GL_ANGLE_client_arrays" 
     "GL_NV_EGL_stream_consumer_external" 
     "GL_OES_compressed_ETC2_RGBA8_texture" 
     "GL_OES_compressed_ETC2_punchthroughA_sRGB8_alpha_texture" 
     "GL_OES_compressed_EAC_R11_signed_texture" 
     "GL_ANGLE_lossy_etc_decode" 
     "GL_OES_packed_depth_stencil" 
     "GL_EXT_instanced_arrays" 
     "GL_OES_mapbuffer" 
     "GL_EXT_texture_type_2_10_10_10_REV" 
     "GL_CHROMIUM_copy_compressed_texture" 
     "GL_ANGLE_pack_reverse_row_order" 
     "GL_NV_pixel_buffer_object" 
     "GL_OES_surfaceless_context" 
     "GL_EXT_EGL_image_external_wrap_modes" 
     "GL_OES_compressed_ETC2_RGB8_texture" 
     "GL_OES_texture_float" 
     "GL_EXT_draw_buffers" 
     "GL_OES_EGL_image" 
     "GL_EXT_texture_filter_anisotropic" 
     "GL_EXT_read_format_bgra" 

QPA OpenGL Detection Info 
  supportsDesktopGL: true 
  supportsAngleD3D11: true 
  isQtPreferAngle: true 

useBufferInvalidation (config option): false


Hardware Information

  GPU Acceleration: auto
  Memory: 16125 Mb
  Number of Cores: 8
  Swap Location: C:/Users/PhilC/AppData/Local/Temp
  Built for: sse2
  Base instruction set: sse2
  Supported instruction sets: avx512bw avx512dq avx512cd avx512f fma3+avx2 avx2 fma3+avx avx fma4 fma3+sse4.2 sse4.2 sse4.1 ssse3 sse3 sse2 

Current Settings

  Current Swap Location: C:/Users/PhilC/AppData/Local/Temp
  Current Swap Location writable: true
  Undo Enabled: true
  Undo Stack Limit: 30
  Use OpenGL: true
  Use OpenGL Texture Buffer: true
  Disable Vector Optimizations: false
  Disable AVX Optimizations: false
  Canvas State: OPENGL_SUCCESS
  Autosave Interval: 0
  Use Backup Files: true
  Number of Backups Kept: 1
  Backup File Suffix: ~
  Backup Location: Same Folder as the File
  Backup Location writable: false
  Use Win8 Pointer Input: false
  Use RightMiddleTabletButton Workaround: false
  Levels of Detail Enabled: false
  Use Zip64: false


Display Information
Number of screens: 1
	Screen: 0
		Name: \\.\DISPLAY1
		Depth: 32
		Scale: 1
		Physical DPI131.45
		Logical DPI96
		Physical Size: 309, 174
		Position: 0, 0
		Resolution in pixels: 1600x900
		Manufacturer: 
		Model: 
		Refresh Rate: 60


---------------------
================================================================================
SESSION: 17 Oct 2022 16:13:59 -0400. Executing C:\Program Files\Krita (x64)\bin\krita.exe

Krita Version: 5.1.1, Qt version compiled: 5.12.12, loaded: 5.12.12. Process ID: 19060
-- -- -- -- -- -- -- --
17 Oct 2022 16:13:59 -0400: Style: fusion. Available styles: windowsvista, Windows, Fusion
17 Oct 2022 16:14:01 -0400: Database is up to date. Version: 0.0.17, created by Krita 5.1.1, at Mon Oct 17 15:09:47 2022
17 Oct 2022 16:14:01 -0400: Could not load resource patterns/krita_FFoxtU.pat
17 Oct 2022 16:14:01 -0400: Could not load resource patterns/krita_XZInbp.pat
17 Oct 2022 16:14:01 -0400: Could not load resource patterns/krita_nkOhfR.pat
17 Oct 2022 16:14:01 -0400: Non-store package - creating updater
17 Oct 2022 16:14:24 -0400: Created image "Unnamed", 100 * 8928 pixels, 600 dpi. Color model: 8-bit integer/channel RGB/Alpha (sRGB-elle-V2-srgbtrc.icc). Layers: 1
17 Oct 2022 16:15:14 -0400: Saving Document  as C:/test/test.kra (mime: application/x-krita). 100 * 8928 pixels, 2 layers.  101 frames, 24 framerate. Export configuration: No configuration
17 Oct 2022 16:15:14 -0400: Converting from application/x-krita to application/x-krita. Location: C:/test/test.kra. Real location: C:/test/test.kra. Batchmode: 0. Configuration: none
17 Oct 2022 16:15:15 -0400: Completed saving C:/test/test.kra (mime: application/x-krita). Result: OK. Warning: . Size: 50115
17 Oct 2022 16:15:15 -0400: Saving Completed
17 Oct 2022 16:15:39 -0400: Saving Document C:/test/test.kra as C:/test/test.kra (mime: application/x-krita). 100 * 8928 pixels, 2 layers.  101 frames, 24 framerate. Export configuration: No configuration
17 Oct 2022 16:15:39 -0400: Create a simple backup for C:/test/test.kra in the same location as the file.
17 Oct 2022 16:15:39 -0400: Converting from application/x-krita to application/x-krita. Location: C:/test/test.kra. Real location: C:/test/test.kra. Batchmode: 0. Configuration: none
17 Oct 2022 16:15:39 -0400: Completed saving C:/test/test.kra (mime: application/x-krita). Result: OK. Warning: . Size: 2460660
17 Oct 2022 16:15:39 -0400: Saving Completed
17 Oct 2022 16:15:46 -0400: Saving Document C:/test/test.kra as C:/test/test2.kra (mime: application/x-krita). 100 * 8928 pixels, 2 layers.  101 frames, 24 framerate. Export configuration: No configuration
17 Oct 2022 16:15:46 -0400: Converting from application/x-krita to application/x-krita. Location: C:/test/test2.kra. Real location: C:/test/test2.kra. Batchmode: 0. Configuration: none
17 Oct 2022 16:15:46 -0400: Completed saving C:/test/test2.kra (mime: application/x-krita). Result: OK. Warning: . Size: 2460660
17 Oct 2022 16:15:46 -0400: Saving Completed
17 Oct 2022 16:16:22 -0400: Saving Document C:/test/test2.kra as C:/test/test2.kra (mime: application/x-krita). 32 * 8928 pixels, 2 layers.  101 frames, 24 framerate. Export configuration: No configuration
17 Oct 2022 16:16:23 -0400: Create a simple backup for C:/test/test2.kra in the same location as the file.
17 Oct 2022 16:16:23 -0400: Converting from application/x-krita to application/x-krita. Location: C:/test/test2.kra. Real location: C:/test/test2.kra. Batchmode: 0. Configuration: none
17 Oct 2022 16:16:23 -0400: Completed saving C:/test/test2.kra (mime: application/x-krita). Result: Error occurred while writing to the file.. Warning: . Size: 2460660

---------------------
Comment 1 Lynx3d 2022-10-17 21:33:39 UTC
That's an interesting one, the extreme aspect ratio makes the thumbnail generation fail...
Shouldn't be too hard to fix.
Comment 2 Lynx3d 2022-10-17 22:31:13 UTC
Git commit 392fd207cd897ce51f1fb76e080e79c7e35f962d by Mathias Wein.
Committed on 17/10/2022 at 22:18.
Pushed by mwein into branch 'master'.

Fix saving files with extreme aspect ratio

Saving failed because thumbnail generation didn't take into account
that scaling a QSize with KeepAspectRatio may round one dimension down
to zero.
This caused even the recovery path to generate an invalid thumbnail
image and saving aborted.

M  +2    -2    libs/ui/KisDocument.cpp
M  +3    -2    plugins/impex/libkra/kra_converter.cpp

https://invent.kde.org/graphics/krita/commit/392fd207cd897ce51f1fb76e080e79c7e35f962d
Comment 3 Lynx3d 2022-10-17 22:31:21 UTC
Git commit 67aad01fcd67f409b97adc4f1138de794ed3b676 by Mathias Wein.
Committed on 17/10/2022 at 22:21.
Pushed by mwein into branch 'krita/5.1'.

Fix saving files with extreme aspect ratio

Saving failed because thumbnail generation didn't take into account
that scaling a QSize with KeepAspectRatio may round one dimension down
to zero.
This caused even the recovery path to generate an invalid thumbnail
image and saving aborted.
(cherry picked from commit 392fd207cd897ce51f1fb76e080e79c7e35f962d)

M  +2    -2    libs/ui/KisDocument.cpp
M  +3    -2    plugins/impex/libkra/kra_converter.cpp

https://invent.kde.org/graphics/krita/commit/67aad01fcd67f409b97adc4f1138de794ed3b676
Comment 4 Phil 2022-10-17 23:41:35 UTC
yay!

I was helping my daughter fiddle with some textures for bloxd.io. Definitely an odd scenario.

Thanks!