Bug 498257 - Krita crashes and file corrupts after closing the application in a span of a few minutes
Summary: Krita crashes and file corrupts after closing the application in a span of a ...
Status: RESOLVED FIXED
Alias: None
Product: krita
Classification: Applications
Component: General (other bugs)
Version First Reported In: 5.2.12
Platform: Android Android 13.x
: NOR major
Target Milestone: ---
Assignee: Krita Bugs
URL:
Keywords: triaged
Depends on:
Blocks:
 
Reported: 2025-01-04 19:00 UTC by baylon09richard
Modified: 2025-12-08 10:36 UTC (History)
2 users (show)

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


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description baylon09richard 2025-01-04 19:00:01 UTC
SUMMARY
Krita crashes and file corrupts after closing the application in a span of a few minutes. I submitted this bug report because the 1 week of progress that I've made disappeared in a few minutes 
and this is my first time submitting bug report and I'm not that smart in this stuff



STEPS TO REPRODUCE
1. Open krita 
2. Open krita file.
3. Draw until has somewhat large file size or lags a tiny bit.
4. Close the krita application.
5. Wait for a few minutes. the longer the more it has possibility of crashing and file corruption (can't open the file again)
6. Open krita again.


OBSERVED RESULT
the good result is that krita only crashed or has a Autosave 
and if I waited a little bit longer the bad result is that the file can't be opened and krita considers it an invalid krita file and file format can't be parsed


EXPECTED RESULT
the file has an Autosave or file gets unusable

Krita

Version: 5.2.8 (git 7c43349)
 Hidpi: true

Qt

  Version (compiled): 5.15.7
  Version (loaded): 5.15.7

OS Information

  Build ABI: arm64-little_endian-lp64
  Build CPU: arm64
  CPU: arm64
  Kernel Type: linux
  Kernel Version: 4.14.180-perf-g98d7380da
  Pretty Productname: Android  (13.0)
  Product Type: android
  Product Version: 13.0
  Product Model: Xiaomi 21051182G

OpenGL Info
 
  Vendor:  "Qualcomm" 
  Renderer:  "Adreno (TM) 640" 
  Driver version:  "OpenGL ES 3.2 V@0502.0 (GIT@83a0eede45, If3f4a1ab82, 1637303585) (Date:11/18/21)" 
  Shading language:  "OpenGL ES GLSL ES 3.20" 
  Requested format:  QSurfaceFormat(version 3.0, 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::NoProfile) 
  Current format:  QSurfaceFormat(version 3.2, 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) 
  GL version: 3.2 
  Supports deprecated functions false 
  Is OpenGL ES: true 
  supportsBufferMapping: true 
  supportsBufferInvalidation: false 
  forceDisableTextureBuffers: false 
  Extensions: 
     GL_EXT_external_buffer 
     GL_EXT_shader_non_constant_global_initializers 
     GL_EXT_disjoint_timer_query 
     GL_EXT_texture_format_sRGB_override 
     GL_OES_sample_shading 
     GL_QCOM_texture_foveated 
     GL_OES_texture_half_float_linear 
     GL_EXT_texture_buffer 
     GL_EXT_EGL_image_storage 
     GL_OES_EGL_image 
     GL_OES_compressed_ETC1_RGB8_texture 
     GL_EXT_multisampled_render_to_texture 
     GL_OES_vertex_half_float 
     GL_EXT_EGL_image_external_wrap_modes 
     GL_OES_standard_derivatives 
     GL_EXT_texture_filter_anisotropic 
     GL_EXT_texture_sRGB_decode 
     GL_ANDROID_extension_pack_es31a 
     GL_OES_texture_half_float 
     GL_EXT_discard_framebuffer 
     GL_EXT_robustness 
     GL_EXT_shader_io_blocks 
     GL_EXT_debug_label 
     GL_KHR_blend_equation_advanced 
     GL_EXT_debug_marker 
     GL_EXT_texture_type_2_10_10_10_REV 
     GL_EXT_texture_format_BGRA8888 
     GL_EXT_clip_control 
     GL_OVR_multiview2 
     GL_EXT_buffer_storage 
     GL_EXT_gpu_shader5 
     GL_OES_EGL_image_external_essl3 
     GL_EXT_YUV_target 
     GL_EXT_EGL_image_array 
     GL_EXT_fragment_invocation_density 
     GL_OES_texture_npot 
     GL_KHR_robust_buffer_access_behavior 
     GL_KHR_texture_compression_astc_hdr 
     GL_NV_shader_noperspective_interpolation 
     GL_OES_EGL_image_external 
     GL_OES_vertex_array_object 
     GL_OES_texture_float_linear 
     GL_QCOM_shader_framebuffer_fetch_noncoherent 
     GL_EXT_sRGB_write_control 
     GL_OES_texture_stencil8 
     GL_OES_texture_storage_multisample_2d_array 
     GL_OES_shader_image_atomic 
     GL_EXT_primitive_bounding_box 
     GL_KHR_debug 
     GL_OES_shader_multisample_interpolation 
     GL_EXT_texture_sRGB_R8 
     GL_OES_packed_depth_stencil 
     GL_QCOM_motion_estimation 
     GL_QCOM_validate_shader_binary 
     GL_OES_sample_variables 
     GL_QCOM_shader_framebuffer_fetch_rate 
     GL_EXT_color_buffer_half_float 
     GL_EXT_multisampled_render_to_texture2 
     GL_OVR_multiview_multisampled_render_to_texture 
     GL_ARM_shader_framebuffer_fetch_depth_stencil 
     GL_EXT_clip_cull_distance 
     GL_OES_element_index_uint 
     GL_EXT_texture_norm16 
     GL_EXT_sRGB 
     GL_OES_get_program_binary 
     GL_EXT_memory_object 
     GL_EXT_texture_border_clamp 
     GL_EXT_texture_cube_map_array 
     GL_EXT_shader_framebuffer_fetch 
     GL_KHR_texture_compression_astc_ldr 
     GL_EXT_geometry_shader 
     GL_QCOM_YUV_texture_gather 
     GL_OES_depth24 
     GL_EXT_tessellation_shader 
     GL_OES_texture_3D 
     GL_OES_depth_texture 
     GL_OES_surfaceless_context 
     GL_EXT_read_format_bgra 
     GL_QCOM_tiled_rendering 
     GL_EXT_memory_object_fd 
     GL_AMD_compressed_ATC_texture 
     GL_OES_EGL_sync 
     GL_QCOM_texture_foveated_subsampled_layout 
     GL_OES_texture_compression_astc 
     GL_EXT_draw_buffers_indexed 
     GL_EXT_blit_framebuffer_params 
     GL_OES_rgb8_rgba8 
     GL_OVR_multiview 
     GL_EXT_protected_textures 
     GL_KHR_blend_equation_advanced_coherent 
     GL_KHR_no_error 
     GL_OES_framebuffer_object 
     GL_QCOM_alpha_test 
     GL_EXT_blend_func_extended 
     GL_EXT_color_buffer_float 
     GL_OES_depth_texture_cube_map 
     GL_OES_texture_float 
     GL_EXT_copy_image 
     GL_OES_texture_view 

QPA OpenGL Detection Info 
  supportsDesktopGL: false 
  supportsOpenGLES: true 
  isQtPreferOpenGLES: true 
  Detected renderers: 
    (Supported) Adreno (TM) 640 (OpenGL ES 3.2 V@0502.0 (GIT@83a0eede45, If3f4a1ab82, 1637303585) (Date:11/18/21))  

useBufferInvalidation (config option): false


Hardware Information

  GPU Acceleration: angle
  Memory: 5501 Mb
  Number of Cores: 8
  Swap Location: /data/data/org.krita/cache
  Built for: arm64+neon
  Base instruction set: arm64+neon
  Supported instruction sets: neon neon64

Current Settings

  Current Swap Location: /data/data/org.krita/cache
  Current Swap Location writable: true
  Undo Enabled: true
  Undo Stack Limit: 200
  Use OpenGL: true
  Use OpenGL Texture Buffer: true
  Disable Vector Optimizations: false
  Disable AVX Optimizations: false
  Canvas State: OPENGL_SUCCESS
  Autosave Interval: 420
  Use Backup Files: true
  Number of Backups Kept: 1
  Backup File Suffix: ~
  Backup Location: Same Folder as the File
  Backup Location writable: false
  Resource Location: /storage/emulated/0/Android/data/org.krita/files
  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: 
		Depth: 32
		Scale: 2.25
		Physical DPI122.535
		Logical DPI72
		Physical Size: 236, 144
		Position: 0, 0
		Resolution in pixels: 1138x695
		Manufacturer: 
		Model: 
		Refresh Rate: 60
		Serial Number: 


---------------------
 30 Dec 2024 14:36:35 +0800. Executing /data/app/~~AKvJ3yh9vaa91W53iB2c8Q==/org.krita-OiJ2OvPSbJVtOwQaQKm-Hw==/lib/arm64/libkrita_arm64-v8a.so

Krita Version: 5.2.8 (git 7c43349), Qt version compiled: 5.15.7, loaded: 5.15.7. Process ID: 23424
-- -- -- -- -- -- -- --
30 Dec 2024 14:36:35 +0800: Style: fusion. Available styles: android, Windows, Fusion
30 Dec 2024 14:36:38 +0800: Database is up to date. Version: 0.0.17, created by Krita 5.2.2, at Wed May 15 20:39:38 2024
30 Dec 2024 14:36:45 +0800: Importing application/x-krita to application/x-krita. Location: content://com.android.externalstorage.documents/document/primary%3ASaves%2Fラナー. Real location: content://com.android.externalstorage.documents/document/primary%3ASaves%2Fラナー. Batchmode: 0
30 Dec 2024 14:36:48 +0800: Loaded image from application/x-krita. Size: 2634 * 1860 pixels, 4.16667 dpi. Color model: 8-bit integer/channel RGB/Alpha (sRGB-elle-V2-srgbtrc.icc). Layers: 41
30 Dec 2024 14:39:26 +0800: Saving Document content://com.android.externalstorage.documents/document/primary%3ASaves%2Fラナー as content://com.android.externalstorage.documents/document/primary%3ASaves%2Fラナー (mime: application/x-krita). 2634 * 1860 pixels, 41 layers.  251 frames, 24 framerate. Export configuration: No configuration
30 Dec 2024 14:39:26 +0800: Create a simple backup for content://com.android.externalstorage.documents/document/primary%3ASaves%2Fラナー in /storage/emulated/0/Android/data/org.krita/files/Documents/krita-backup.
30 Dec 2024 14:39:27 +0800: Converting from application/x-krita to application/x-krita. Location: content://com.android.externalstorage.documents/document/primary%3ASaves%2Fラナー. Real location: content://com.android.externalstorage.documents/document/primary%3ASaves%2Fラナー. Batchmode: 0. Configuration: none
30 Dec 2024 14:39:29 +0800: Completed saving content://com.android.externalstorage.documents/document/primary%3ASaves%2Fラナー (mime: application/x-krita). Result: OK. Warning: . Size: 30018016
30 Dec 2024 14:39:29 +0800: Saving Completed
30 Dec 2024 14:43:44 +0800: Autosaving: /storage/emulated/0/Android/data/org.krita/files/Documents/krita-backup/.ラナー-autosave.kra
30 Dec 2024 14:43:45 +0800: Converting from application/x-krita to application/x-krita. Location: /storage/emulated/0/Android/data/org.krita/files/Documents/krita-backup/.ラナー-autosave.kra. Real location: /storage/emulated/0/Android/data/org.krita/files/Documents/krita-backup/.ラナー-autosave.kra. Batchmode: 0. Configuration: none
30 Dec 2024 14:43:48 +0800: Completed saving /storage/emulated/0/Android/data/org.krita/files/Documents/krita-backup/.ラナー-autosave.kra (mime: application/x-krita). Result: OK. Warning: . Size: 29591497
30 Dec 2024 14:50:48 +0800: Autosaving: /storage/emulated/0/Android/data/org.krita/files/Documents/krita-backup/.ラナー-autosave.kra
30 Dec 2024 14:50:49 +0800: Converting from application/x-krita to application/x-krita. Location: /storage/emulated/0/Android/data/org.krita/files/Documents/krita-backup/.ラナー-autosave.kra. Real location: /storage/emulated/0/Android/data/org.krita/files/Documents/krita-backup/.ラナー-autosave.kra. Batchmode: 0. Configuration: none
30 Dec 2024 14:50:51 +0800: Completed saving /storage/emulated/0/Android/data/org.krita/files/Documents/krita-backup/.ラナー-autosave.kra (mime: application/x-krita). Result: OK. Warning: . Size: 29941666
30 Dec 2024 14:51:48 +0800: Saving Document content://com.android.externalstorage.documents/document/primary%3ASaves%2Fラナー as content://com.android.externalstorage.documents/document/primary%3ASaves%2Fラナー (mime: application/x-krita). 2634 * 1860 pixels, 41 layers.  251 frames, 24 framerate. Export configuration: No configuration
30 Dec 2024 14:51:48 +0800: Create a simple backup for content://com.android.externalstorage.documents/document/primary%3ASaves%2Fラナー in /storage/emulated/0/Android/data/org.krita/files/Documents/krita-backup.
30 Dec 2024 14:51:49 +0800: Converting from application/x-krita to application/x-krita. Location: content://com.android.externalstorage.documents/document/primary%3ASaves%2Fラナー. Real location: content://com.android.externalstorage.documents/document/primary%3ASaves%2Fラナー. Batchmode: 0. Configuration: none
30 Dec 2024 14:51:51 +0800: Completed saving content://com.android.externalstorage.documents/document/primary%3ASaves%2Fラナー (mime: application/x-krita). Result: OK. Warning: . Size: 30550798
30 Dec 2024 14:51:51 +0800: Removing autosave file: /storage/emulated/0/Android/data/org.krita/files/Documents/krita-backup/.ラナー-autosave.kra
30 Dec 2024 14:51:51 +0800: Saving Completed

KRITA DID NOT CLOSE CORRECTLY
================================================================================



















SESSION: 30 Dec 2024 17:04:22 +0800. Executing /data/app/~~AKvJ3yh9vaa91W53iB2c8Q==/org.krita-OiJ2OvPSbJVtOwQaQKm-Hw==/lib/arm64/libkrita_arm64-v8a.so

Krita Version: 5.2.8 (git 7c43349), Qt version compiled: 5.15.7, loaded: 5.15.7. Process ID: 24244
-- -- -- -- -- -- -- --
30 Dec 2024 17:04:22 +0800: Style: fusion. Available styles: android, Windows, Fusion
30 Dec 2024 17:04:27 +0800: Database is up to date. Version: 0.0.17, created by Krita 5.2.2, at Wed May 15 20:39:38 2024
30 Dec 2024 17:04:38 +0800: Importing application/x-krita to application/x-krita. Location: content://com.android.externalstorage.documents/document/primary%3ASaves%2F言葉. Real location: content://com.android.externalstorage.documents/document/primary%3ASaves%2F言葉. Batchmode: 0
30 Dec 2024 17:04:39 +0800: Loaded image from application/x-krita. Size: 1920 * 2750 pixels, 4.16667 dpi. Color model: 8-bit integer/channel RGB/Alpha (sRGB-elle-V2-srgbtrc.icc). Layers: 13

KRITA DID NOT CLOSE CORRECTLY
================================================================================


















SESSION: 31 Dec 2024 20:08:18 +0800. Executing /data/app/~~AKvJ3yh9vaa91W53iB2c8Q==/org.krita-OiJ2OvPSbJVtOwQaQKm-Hw==/lib/arm64/libkrita_arm64-v8a.so

Krita Version: 5.2.8 (git 7c43349), Qt version compiled: 5.15.7, loaded: 5.15.7. Process ID: 6090
-- -- -- -- -- -- -- --
31 Dec 2024 20:08:18 +0800: Style: fusion. Available styles: android, Windows, Fusion
31 Dec 2024 20:08:22 +0800: Database is up to date. Version: 0.0.17, created by Krita 5.2.2, at Wed May 15 20:39:38 2024
31 Dec 2024 20:09:06 +0800: Importing application/x-krita to application/x-krita. Location: content://com.android.externalstorage.documents/document/primary%3ASaves%2Fラナー. Real location: content://com.android.externalstorage.documents/document/primary%3ASaves%2Fラナー. Batchmode: 0
31 Dec 2024 20:09:11 +0800: Loaded image from application/x-krita. Size: 2634 * 1860 pixels, 4.16667 dpi. Color model: 8-bit integer/channel RGB/Alpha (sRGB-elle-V2-srgbtrc.icc). Layers: 41
31 Dec 2024 20:12:20 +0800: Saving Document content://com.android.externalstorage.documents/document/primary%3ASaves%2Fラナー as content://com.android.externalstorage.documents/document/primary%3ASaves%2Fラナー (mime: application/x-krita). 2634 * 1860 pixels, 41 layers.  251 frames, 24 framerate. Export configuration: No configuration
31 Dec 2024 20:12:21 +0800: Create a simple backup for content://com.android.externalstorage.documents/document/primary%3ASaves%2Fラナー in /storage/emulated/0/Android/data/org.krita/files/Documents/krita-backup.
31 Dec 2024 20:12:21 +0800: Converting from application/x-krita to application/x-krita. Location: content://com.android.externalstorage.documents/document/primary%3ASaves%2Fラナー. Real location: content://com.android.externalstorage.documents/document/primary%3ASaves%2Fラナー. Batchmode: 0. Configuration: none
31 Dec 2024 20:12:24 +0800: Completed saving content://com.android.externalstorage.documents/document/primary%3ASaves%2Fラナー (mime: application/x-krita). Result: OK. Warning: . Size: 30878160
31 Dec 2024 20:12:24 +0800: Saving Completed

KRITA DID NOT CLOSE CORRECTLY
================================================================================

















SESSION: 01 Jan 2025 02:41:57 +0800. Executing /data/app/~~AKvJ3yh9vaa91W53iB2c8Q==/org.krita-OiJ2OvPSbJVtOwQaQKm-Hw==/lib/arm64/libkrita_arm64-v8a.so

Krita Version: 5.2.8 (git 7c43349), Qt version compiled: 5.15.7, loaded: 5.15.7. Process ID: 28255
-- -- -- -- -- -- -- --
01 Jan 2025 02:41:57 +0800: Style: fusion. Available styles: android, Windows, Fusion
01 Jan 2025 02:42:00 +0800: Database is up to date. Version: 0.0.17, created by Krita 5.2.2, at Wed May 15 20:39:38 2024
01 Jan 2025 02:42:08 +0800: Importing application/x-krita to application/x-krita. Location: content://com.android.externalstorage.documents/document/primary%3ASaves%2Fラナー. Real location: content://com.android.externalstorage.documents/document/primary%3ASaves%2Fラナー. Batchmode: 0
01 Jan 2025 02:42:12 +0800: Loaded image from application/x-krita. Size: 2634 * 1860 pixels, 4.16667 dpi. Color model: 8-bit integer/channel RGB/Alpha (sRGB-elle-V2-srgbtrc.icc). Layers: 41
01 Jan 2025 02:46:40 +0800: Saving Document content://com.android.externalstorage.documents/document/primary%3ASaves%2Fラナー as content://com.android.externalstorage.documents/document/primary%3ASaves%2Fラナー (mime: application/x-krita). 2634 * 1860 pixels, 41 layers.  251 frames, 24 framerate. Export configuration: No configuration
01 Jan 2025 02:46:40 +0800: Create a simple backup for content://com.android.externalstorage.documents/document/primary%3ASaves%2Fラナー in /storage/emulated/0/Android/data/org.krita/files/Documents/krita-backup.
01 Jan 2025 02:46:41 +0800: Converting from application/x-krita to application/x-krita. Location: content://com.android.externalstorage.documents/document/primary%3ASaves%2Fラナー. Real location: content://com.android.externalstorage.documents/document/primary%3ASaves%2Fラナー. Batchmode: 0. Configuration: none
01 Jan 2025 02:46:44 +0800: Completed saving content://com.android.externalstorage.documents/document/primary%3ASaves%2Fラナー (mime: application/x-krita). Result: OK. Warning: . Size: 30976338
01 Jan 2025 02:46:44 +0800: Saving Completed

KRITA DID NOT CLOSE CORRECTLY
================================================================================
















SESSION: 01 Jan 2025 18:29:37 +0800. Executing /data/app/~~AKvJ3yh9vaa91W53iB2c8Q==/org.krita-OiJ2OvPSbJVtOwQaQKm-Hw==/lib/arm64/libkrita_arm64-v8a.so

Krita Version: 5.2.8 (git 7c43349), Qt version compiled: 5.15.7, loaded: 5.15.7. Process ID: 19072
-- -- -- -- -- -- -- --
01 Jan 2025 18:29:37 +0800: Style: fusion. Available styles: android, Windows, Fusion
01 Jan 2025 18:29:44 +0800: Database is up to date. Version: 0.0.17, created by Krita 5.2.2, at Wed May 15 20:39:38 2024
01 Jan 2025 18:29:54 +0800: Importing application/x-krita to application/x-krita. Location: content://com.android.externalstorage.documents/document/primary%3ASaves%2Fラナー. Real location: content://com.android.externalstorage.documents/document/primary%3ASaves%2Fラナー. Batchmode: 0
01 Jan 2025 18:29:58 +0800: Loaded image from application/x-krita. Size: 2634 * 1860 pixels, 4.16667 dpi. Color model: 8-bit integer/channel RGB/Alpha (sRGB-elle-V2-srgbtrc.icc). Layers: 41
01 Jan 2025 18:31:17 +0800: SAFE ASSERT (krita): "m_d->requestedFrame == frame" in file /builds/graphics/krita/libs/ui/KisAsyncAnimationRendererBase.cpp, line 140
01 Jan 2025 18:36:54 +0800: Autosaving: /storage/emulated/0/Android/data/org.krita/files/Documents/krita-backup/.ラナー-autosave.kra
01 Jan 2025 18:37:04 +0800: Autosaving: /storage/emulated/0/Android/data/org.krita/files/Documents/krita-backup/.ラナー-autosave.kra
01 Jan 2025 18:37:04 +0800: Converting from application/x-krita to application/x-krita. Location: /storage/emulated/0/Android/data/org.krita/files/Documents/krita-backup/.ラナー-autosave.kra. Real location: /storage/emulated/0/Android/data/org.krita/files/Documents/krita-backup/.ラナー-autosave.kra. Batchmode: 0. Configuration: none
01 Jan 2025 18:37:06 +0800: Completed saving /storage/emulated/0/Android/data/org.krita/files/Documents/krita-backup/.ラナー-autosave.kra (mime: application/x-krita). Result: OK. Warning: . Size: 31057591
01 Jan 2025 18:38:57 +0800: SAFE ASSERT (krita): "m_d->requestedFrame == frame" in file /builds/graphics/krita/libs/ui/KisAsyncAnimationRendererBase.cpp, line 140
01 Jan 2025 18:43:46 +0800: Converting from application/x-krita to application/x-krita. Location: /storage/emulated/0/Android/data/org.krita/files/Documents/krita-backup/.ラナー-autosave.kra. Real location: /storage/emulated/0/Android/data/org.krita/files/Documents/krita-backup/.ラナー-autosave.kra. Batchmode: 0
Comment 1 Dmitry Kazakov 2025-01-04 21:48:59 UTC
This crash is one of the two backtraces:

They are the two most frequent crashes on Android for Krita (28% of all the crashes in total).

# Backtrace 1

Exception java.lang.RuntimeException:
  at android.app.ActivityThread.performPauseActivityIfNeeded (ActivityThread.java:5111)
  at android.app.ActivityThread.performPauseActivity (ActivityThread.java:5060)
  at android.app.ActivityThread.handlePauseActivity (ActivityThread.java:5012)
  at android.app.servertransaction.PauseActivityItem.execute (PauseActivityItem.java:47)
  at android.app.servertransaction.ActivityTransactionItem.execute (ActivityTransactionItem.java:45)
  at android.app.servertransaction.TransactionExecutor.executeLifecycleState (TransactionExecutor.java:177)
  at android.app.servertransaction.TransactionExecutor.execute (TransactionExecutor.java:98)
  at android.app.ActivityThread$H.handleMessage (ActivityThread.java:2252)
  at android.os.Handler.dispatchMessage (Handler.java:106)
  at android.os.Looper.loopOnce (Looper.java:201)
  at android.os.Looper.loop (Looper.java:288)
  at android.app.ActivityThread.main (ActivityThread.java:7941)
  at java.lang.reflect.Method.invoke
  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:553)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1003)
Caused by android.app.BackgroundServiceStartNotAllowedException:
  at android.app.ContextImpl.startServiceCommon (ContextImpl.java:1862)
  at android.app.ContextImpl.startService (ContextImpl.java:1818)
  at android.content.ContextWrapper.startService (ContextWrapper.java:776)
  at org.krita.android.MainActivity.startForegroundServiceS (MainActivity.java:128)
  at org.krita.android.MainActivity.startServiceGeneric (MainActivity.java:111)
  at org.krita.android.MainActivity.onPause (MainActivity.java:102)
  at android.app.Activity.performPause (Activity.java:8244)
  at android.app.Instrumentation.callActivityOnPause (Instrumentation.java:1530)
  at android.app.ActivityThread.performPauseActivityIfNeeded (ActivityThread.java:5099)

# Backtrace 2

Exception java.lang.UnsatisfiedLinkError: No implementation found for void org.krita.android.JNIWrappers.saveState() (tried Java_org_krita_android_JNIWrappers_saveState and Java_org_krita_android_JNIWrappers_saveState__) - is the library loaded, e.g. System.loadLibrary?
  at org.krita.android.JNIWrappers.saveState (JNIWrappers.java)
  at org.krita.android.DocumentSaverService$1.run (DocumentSaverService.java:120)
  at java.lang.Thread.run (Thread.java:1012)
Comment 2 dra.w.p.il.e+bugskde 2025-09-21 10:51:47 UTC
The errors Dmitry mentioned are fixed, but you can still pretty easily corrupt a file with the following steps to reproduce:

1. Save a file that takes a while to save.
2. Go into the application overview and swipe Krita out of the way so that it terminates.
3. Try to reopen the file, see that it won't work.

Of course #2 is likely to happen in practice in the form of Android deciding that it would really like to reclaim memory while Krita is saving and the out-of-memory killer kills it dead.

I assume the reason this happens is because Krita writes directly to the output file, given that Android has no support for QSaveFile, so it just truncates the file first and starts writing it in-place. That means there's an immensely long span of time where the OS getting impatient will guarantee total data loss, both of the old file and any changes made meanwhile.

That could be solved by writing the file to the internal application data first and then once that has succeeded copy it over the original file. This isn't perfect, because Android can't do an atomic move of a file like a real operating system could, but just shoveling data over is so fast that it's pretty unlikely for the application to be terminated in that exact moment.

Alternatively, Krita could first back up the old file to the internal application data and then start saving, then detect whether that got interrupted on the next startup and offer to recover the file. This would never leave you in the situation where neither the old nor the new data are persisted anywhere, but downside is that it's a whole lot more work to implement, to the point where it's questionable whether it makes sense to bother with it at all over implementing the save to sandbox instead, cf. https://invent.kde.org/graphics/krita/-/issues/20

In both cases, you'd still lose your current changes of course, since Krita is terminated before it can save that, but it would at least retain the old state.
Comment 3 baylon09richard 2025-11-10 14:44:48 UTC
(In reply to dra.w.p.il.e+bugskde from comment #2)
> The errors Dmitry mentioned are fixed, but you can still pretty easily
> corrupt a file with the following steps to reproduce:
> 
> 1. Save a file that takes a while to save.
> 2. Go into the application overview and swipe Krita out of the way so that
> it terminates.
> 3. Try to reopen the file, see that it won't work.
> 
> Of course #2 is likely to happen in practice in the form of Android deciding
> that it would really like to reclaim memory while Krita is saving and the
> out-of-memory killer kills it dead.
> 
> I assume the reason this happens is because Krita writes directly to the
> output file, given that Android has no support for QSaveFile, so it just
> truncates the file first and starts writing it in-place. That means there's
> an immensely long span of time where the OS getting impatient will guarantee
> total data loss, both of the old file and any changes made meanwhile.
> 
> That could be solved by writing the file to the internal application data
> first and then once that has succeeded copy it over the original file. This
> isn't perfect, because Android can't do an atomic move of a file like a real
> operating system could, but just shoveling data over is so fast that it's
> pretty unlikely for the application to be terminated in that exact moment.
> 
> Alternatively, Krita could first back up the old file to the internal
> application data and then start saving, then detect whether that got
> interrupted on the next startup and offer to recover the file. This would
> never leave you in the situation where neither the old nor the new data are
> persisted anywhere, but downside is that it's a whole lot more work to
> implement, to the point where it's questionable whether it makes sense to
> bother with it at all over implementing the save to sandbox instead, cf.
> https://invent.kde.org/graphics/krita/-/issues/20
> 
> In both cases, you'd still lose your current changes of course, since Krita
> is terminated before it can save that, but it would at least retain the old
> state.

Thank you!(In reply to dra.w.p.il.e+bugskde from comment #2)
> The errors Dmitry mentioned are fixed, but you can still pretty easily
> corrupt a file with the following steps to reproduce:
> 
> 1. Save a file that takes a while to save.
> 2. Go into the application overview and swipe Krita out of the way so that
> it terminates.
> 3. Try to reopen the file, see that it won't work.
> 
> Of course #2 is likely to happen in practice in the form of Android deciding
> that it would really like to reclaim memory while Krita is saving and the
> out-of-memory killer kills it dead.
> 
> I assume the reason this happens is because Krita writes directly to the
> output file, given that Android has no support for QSaveFile, so it just
> truncates the file first and starts writing it in-place. That means there's
> an immensely long span of time where the OS getting impatient will guarantee
> total data loss, both of the old file and any changes made meanwhile.
> 
> That could be solved by writing the file to the internal application data
> first and then once that has succeeded copy it over the original file. This
> isn't perfect, because Android can't do an atomic move of a file like a real
> operating system could, but just shoveling data over is so fast that it's
> pretty unlikely for the application to be terminated in that exact moment.
> 
> Alternatively, Krita could first back up the old file to the internal
> application data and then start saving, then detect whether that got
> interrupted on the next startup and offer to recover the file. This would
> never leave you in the situation where neither the old nor the new data are
> persisted anywhere, but downside is that it's a whole lot more work to
> implement, to the point where it's questionable whether it makes sense to
> bother with it at all over implementing the save to sandbox instead, cf.
> https://invent.kde.org/graphics/krita/-/issues/20
> 
> In both cases, you'd still lose your current changes of course, since Krita
> is terminated before it can save that, but it would at least retain the old
> state.

Thank you!
Comment 4 baylon09richard 2025-11-10 14:47:58 UTC
I think I made the comment a little long sorry
Comment 5 Bug Janitor Service 2025-12-05 15:31:47 UTC
A possibly relevant merge request was started @ https://invent.kde.org/graphics/krita/-/merge_requests/2556
Comment 6 Dmitry Kazakov 2025-12-08 10:36:35 UTC
Git commit 02e9966601ca99f07b9db31cf3edabdd8d40ee70 by Dmitry Kazakov, on behalf of Carsten Hartenfels.
Committed on 08/12/2025 at 10:36.
Pushed by dkazakov into branch 'master'.

[android] Write to temporary file when saving

Instead of using QSaveFile, because that doesn't work on Android due to
sandboxing. Nor does the usual method of QFile::copy work on Android, we
have to do that manually by opening the target file and shoveling bytes.

M  +90   -12   libs/ui/KisImportExportManager.cpp

https://invent.kde.org/graphics/krita/-/commit/02e9966601ca99f07b9db31cf3edabdd8d40ee70
Comment 7 Dmitry Kazakov 2025-12-08 10:36:59 UTC
Git commit 49af64b324526aa94b1a9d4b604dac9f79671b41 by Dmitry Kazakov.
Committed on 08/12/2025 at 10:36.
Pushed by dkazakov into branch 'krita/5.2'.

[android] Write to temporary file when saving

Instead of using QSaveFile, because that doesn't work on Android due to
sandboxing. Nor does the usual method of QFile::copy work on Android, we
have to do that manually by opening the target file and shoveling bytes.


(cherry picked from commit 02e9966601ca99f07b9db31cf3edabdd8d40ee70)

Co-authored-by: Carsten Hartenfels <carsten.hartenfels@pm.me>

M  +90   -12   libs/ui/KisImportExportManager.cpp

https://invent.kde.org/graphics/krita/-/commit/49af64b324526aa94b1a9d4b604dac9f79671b41