In Krita 5.1.0 we bumped Krita’s targetSdkVersion to Android 12, this has made Krita conformant with Google Play policies but has also allowed google to harden some aspects of the SDK usage.
In our case it has created issues with DocumentSaverService, which we use in Krita to save the document when the app goes in background. But apparently on some devices, the OS doesn’t let the service to start – this results in situations where document saving fails or the app crashes altogether.
I tried reproducing it on some of my devices but I couldn’t on any… Apparently this is only an issue with Samsung devices running Android 12, currently according to Play Store these are the device which have this issue:
Samsung Galaxy Tab S6 Lite
Samsung Galaxy Tab S7 FE
Samsung Galaxy Tab S7 FE 5G
Samsung Galaxy Tab S6 Lite
Samsung Galaxy Tab S7
Samsung Galaxy Tab S7+
Samsung Galaxy Tab S7
Samsung Galaxy Z Fold3 5G
Samsung Galaxy Note20 Ultra 5G
Samsung Galaxy Tab S8
Samsung Galaxy S22 Ultra
Samsung Galaxy S22 Ultra
Samsung Galaxy Tab S7+ 5G
Samsung Galaxy S20 Ultra 5G
Samsung Galaxy Tab S8+
If any of you have any of these device, it would be really helpful if you could help with debugging this issue!
A possible way on how you can reproduce this:
Open Krita, scribble something.
Without saving, press the home button (or swipe to go to home screen).
Wait for 3-4 seconds and reopen Krita, does it open?
If it does open quickly close the Krita using the launcher (home button and swipe the app from recents).
Now reopen Krita, does it show the file you scribbled on in autosaves?
If the file isn’t listed, then the crash does happen on your device – which means we can see what exactly is causing it.
Hi shzam, I have a Samsumg Galaxy Tab S7 FE that is currently on android 12. After updating my Krita to 5.1.0 from the playstore I wasn’t able to reproduce the crash.
I tried about 5 times to reproduce the crash following your steps but I was always able to get Krita to reopen and have the autosave when relaunching. Maybe there is something else that would reproduce the crash?
If this is triggered, does it do irreparable harm to the file? Say I have a project that I’m working on and hit home by accident, or to go to another app to retrieve a file, would my project then be corrupted in some way?
no, most likely it wouldn’t autosave your file and the app will crash.
If you’ve updated the app, and this doesn’t happen it most likely won’t happen on your device. Apparently it crashes every few minutes on some devices and almost never on the others (at least due to this reason)
Ok, I just tried it on my Galaxy tab S7. I upgraded Krita to 5.1.0 from the Playstore, then did the test. Krita handled it just fine. The only thing with the autosave was that it didn’t remember what brush I was using (one of Ramon’s new pencil brushes. - it wasn’t even in the brush history when the autosave was opened.) The brush would keep going to ink-3 Gpen. Otherwise, that’s it.
Another probable factor that may help in reproducing the bug would be Battery Saver, try enabling it and make sure Krita is battery optimized. Also, try it in Samsung Dex mode.
If you can correlate crash trace to the action here’s the crash log for reference:
java.lang.RuntimeException:
at android.app.ActivityThread.performPauseActivityIfNeeded (ActivityThread.java:5557)
at android.app.ActivityThread.performPauseActivity (ActivityThread.java:5508)
at android.app.ActivityThread.handlePauseActivity (ActivityThread.java:5460)
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:176)
at android.app.servertransaction.TransactionExecutor.execute (TransactionExecutor.java:97)
at android.app.ActivityThread$H.handleMessage (ActivityThread.java:2438)
at android.os.Handler.dispatchMessage (Handler.java:106)
at android.os.Looper.loopOnce (Looper.java:226)
at android.os.Looper.loop (Looper.java:313)
at android.app.ActivityThread.main (ActivityThread.java:8663)
at java.lang.reflect.Method.invoke (Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:567)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1135)
Caused by: android.app.ForegroundServiceStartNotAllowedException:
at android.app.ForegroundServiceStartNotAllowedException$1.createFromParcel (ForegroundServiceStartNotAllowedException.java:54)
at android.app.ForegroundServiceStartNotAllowedException$1.createFromParcel (ForegroundServiceStartNotAllowedException.java:50)
at android.os.Parcel.readParcelable (Parcel.java:3345)
at android.os.Parcel.createExceptionOrNull (Parcel.java:2432)
at android.os.Parcel.createException (Parcel.java:2421)
at android.os.Parcel.readException (Parcel.java:2404)
at android.os.Parcel.readException (Parcel.java:2346)
at android.app.IActivityManager$Stub$Proxy.startService (IActivityManager.java:6914)
at android.app.ContextImpl.startServiceCommon (ContextImpl.java:1926)
at android.app.ContextImpl.startForegroundService (ContextImpl.java:1892)
at android.content.ContextWrapper.startForegroundService (ContextWrapper.java:796)
at org.krita.android.MainActivity.onPause (MainActivity.java:77)
at android.app.Activity.performPause (Activity.java:8485)
at android.app.Instrumentation.callActivityOnPause (Instrumentation.java:1530)
at android.app.ActivityThread.performPauseActivityIfNeeded (ActivityThread.java:5547)
at android.app.ActivityThread.performPauseActivity (ActivityThread.java:5508)
at android.app.ActivityThread.handlePauseActivity (ActivityThread.java:5460)
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:176)
at android.app.servertransaction.TransactionExecutor.execute (TransactionExecutor.java:97)
at android.app.ActivityThread$H.handleMessage (ActivityThread.java:2438)
at android.os.Handler.dispatchMessage (Handler.java:106)
at android.os.Looper.loopOnce (Looper.java:226)
at android.os.Looper.loop (Looper.java:313)
at android.app.ActivityThread.main (ActivityThread.java:8663)
at java.lang.reflect.Method.invoke (Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:567)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1135)
Caused by: android.os.RemoteException: Remote stack trace:
at com.android.server.am.ActiveServices.startServiceLocked (ActiveServices.java:771)
at com.android.server.am.ActiveServices.startServiceLocked (ActiveServices.java:679)
at com.android.server.am.ActivityManagerService.startService (ActivityManagerService.java:14071)
at android.app.IActivityManager$Stub.onTransact (IActivityManager.java:2943)
at com.android.server.am.ActivityManagerService.onTransact (ActivityManagerService.java:3034)```
Tried on Tab S7, krita 5.1.0 from official krita site .apk
Testing with Battery Saver on, even put Krita to Deep Sleep App list, cannot crash on my side.
I can’t seem to get it to crash with the steps you provided, with battery saver on or off, or in dex mode either. Reinold’s method did cause a crash for me. I’m using the tab S8+
It crashes – which is a good news! (for now… so we can fix this)
Krita doesn’t save because the stroke is running and it just takes an early exit i.e without saving.
To figure out which one it is, can you please test it a couple more times and give me the time you tested it (in UTC). So I can figure out if there is an entry for the crash on Google Play.
You can also check if the “Saving Document” notification is displaying or not for the latter case (provided it did show when it was able to save the file).
I did this a couple times between 11:07-11:09 PM August 27, 2022 UTC.
I didn’t get a saving notification but I didn’t really get a notification during the other (successful) tests. I think I only saw it 1/5 times so I don’t think it means much that I didn’t see for these failing tests.
I tried a couple times from utc 0:41-45am 8/28. I didn’t get a saving notification except for I think my last test? It’s in the same spot as when the brush is rendering so I might be wrong… It showed an autosave for that test, so maybe the brush I tried wasn’t big enough then…
Sadly, I couldn’t find the corresponding crash in the crash log…
But I did some digging in the Android platform code to get a better idea of what might be going on and I have a hypothesis. The crash may not happen always, the crash occurs when there are fairly decent amount of apps open in the background/recents, plus when the size of the Krita file opened is large. Both factors contribute to high memory pressure on Android – which can trigger android’s OOM service to do some adjustments which can result in Krita not being allowed to start the service.
Testing this hypothesis would be easier on a device with 4GB RAM, just start a few apps heavy in the background and load a heavy image in Krita, edit it and then press the home button. After that, wait about 10 secs and check if Krita is still open or has crashed/OOMed.