ShiftHackZ / Stable-Diffusion-Android

Stable Diffusion AI client app for Android
https://sdai.moroz.cc
GNU Affero General Public License v3.0
646 stars 63 forks source link

Background Process during image generation #219

Open mtribiere opened 1 month ago

mtribiere commented 1 month ago

Is your feature request related to a problem? Please describe. During generation of an image, switching to another app or locking the phone is not possible.

Describe the solution you'd like The ideal solution in my sense would be to have the process happening in a background process. A permanent notification could indicate the progress of the generation process.

Describe alternatives you've considered Leaving the phone on and focus on the app, but it's necessary a "convenient" solution.

Additional context N/A

PurpleCodingWizard commented 1 month ago

Yeah, I too experience this issue. The app gets killed unless I keep it in foeground with my display turned on.

ShiftHackZ commented 1 month ago

Thanks for reporting this important issue.

I think implementing generation as a background process using Work Manager API that is recommended by Google for background work should resolve this.

Could you please also provide some additional information related to your user experience:

mtribiere commented 1 month ago

I use the local generation provider, so it runs pretty slowly. I would say it takes 4~5 minutes per images for me

dragos240 commented 1 month ago

My phone (Asus Zenfone 10) seems to kill the app even if I run it in the foreground. I'm not sure how to disable this behavior. I have battery restrictions disabled for this app, but I'm not sure anything else I can do to prevent my phone from killing the process. I think it must have to do with the OS thinking it's using too much resources and killing it. Not sure what to do to resolve this. If anyone has any tips, I would greatly appreciate them.

ShiftHackZ commented 1 month ago

My phone (Asus Zenfone 10) seems to kill the app even if I run it in the foreground. I'm not sure how to disable this behavior. I have battery restrictions disabled for this app, but I'm not sure anything else I can do to prevent my phone from killing the process. I think it must have to do with the OS thinking it's using too much resources and killing it. Not sure what to do to resolve this. If anyone has any tips, I would greatly appreciate them.

Please try to disable battery optimizations for the app specifically (see the screenshot). Maybe it's worth checking if your manufacturer (Asus) added some additional battery optimization settings in their Android ROM, if you have any additional settings, try also disable them.

image

If it does not help, wait for the next 0.6.3 release, it will include Background generation feature in app settings that is based on Android Work Manager API, maybe this implementation will work better on your device.

PurpleCodingWizard commented 1 month ago

Sorry for late reply. I just saw your comment in the spam while looking for important communication in all folders.

I think implementing generation as a background process using Work Manager API that is recommended by Google for background work should resolve this.

Great, hopefully android doesn't kill SDAI Foss now.

Could you please also provide some additional information related to your user experience:

* What generation provider(s) do you use ?

I use the local version.

* How much time does the generation process take (with the workaround you've considered) ?

Depends on the image size and steps(20) but 7-10mins on average if I go 384x384 and higher. I usually keep the app in a floating window until SDAI gets started on the processing steps after which its usually safe (but not guranteed) to be switched to background in addition to locking the app to further reduce the possibility of being killed.

dragos240 commented 1 month ago

My phone (Asus Zenfone 10) seems to kill the app even if I run it in the foreground. I'm not sure how to disable this behavior. I have battery restrictions disabled for this app, but I'm not sure anything else I can do to prevent my phone from killing the process. I think it must have to do with the OS thinking it's using too much resources and killing it. Not sure what to do to resolve this. If anyone has any tips, I would greatly appreciate them.

Please try to disable battery optimizations for the app specifically (see the screenshot). Maybe it's worth checking if your manufacturer (Asus) added some additional battery optimization settings in their Android ROM, if you have any additional settings, try also disable them.

image

If it does not help, wait for the next 0.6.3 release, it will include Background generation feature in app settings that is based on Android Work Manager API, maybe this implementation will work better on your device.

I have tried everything that I was able to find on my phone and the app's setting. Everything is set to unrestricted, but my phone still kills the app. So I will wait to see if the next release fixes things

KintCark commented 1 month ago

U don't have enough ram the app used to do the same to me on 512x512 u can download swap file no root app from Google Play store it will help with ram issues. I just factory reset my phone and it frees up the most ram, after u factory reset it don't install to many apps the more apps you have the more ram is used.

PurpleCodingWizard commented 1 month ago

U don't have enough ram the app used to do the same to me on 512x512 u can download swap file no root app from Google Play store it will help with ram issues.

You cannot create a swap file without root on android. That app is a literal scam. All it does is create a blank file in its data folder hogging storage which does nothing.