anapnoe / stable-diffusion-webui-ux

Stable Diffusion web UI UX
GNU Affero General Public License v3.0
985 stars 58 forks source link

[Bug]: UI Crashes When Refreshing Lora List #190

Closed Neverdusk closed 11 months ago

Neverdusk commented 11 months ago

Is there an existing issue for this?

What happened?

After updating to the new version (Auto 1.6), I opened the Lora tab on the right. Since no Lora were displayed, I then clicked the refresh icon. This caused the entire page to freeze and eventually show this error: Screenshot 2023-10-31 223505 I've repeated this process four times, and refreshing the Lora tab has consistently caused this crash. Since I have a lot of Loras, it seems like it's struggling to load them all at once, though I never had this issue with the previous version, or any other SD UI.

Refreshing the page caused the UI to restart and then immediately freeze and crash again. So the terminal needed to be closed in order to restart the session.

It's worth mentioning that the embeddings tab also lagged, despite me only having a dozen or so in total. So whatever method is used to load Embeddings / Loras seems to be more demanding and slower than previously. In the old version, I would simply open the Lora tab and every Lora would be listed immediately with its name and thumbnail.

Steps to reproduce the problem

  1. Go to Lora Tab
  2. Press Refresh Icon
  3. UI Crashes

What should have happened?

The Refresh icon should have shown all Lora without issue.

Sysinfo

sysinfo-2023-11-01-02-39.txt

What browsers do you use to access the UI ?

Google Chrome

Console logs

venv "C:\Users\silve\Documents\AI Art\__SDUX\venv\Scripts\Python.exe"
Python 3.10.8 (tags/v3.10.8:aaaf517, Oct 11 2022, 16:50:30) [MSC v.1933 64 bit (AMD64)]
Version: v1.6.0-291-g9d24b2ce
Commit hash: 9d24b2ce2f623f8c46c2f1bf1ff1136ec3eb2487
Launching Web UI with arguments: --api --medvram-sdxl --xformers --no-half-vae --autolaunch --opt-split-attention
Civitai Helper: Get Custom Model Folder
[-] ADetailer initialized. version: 23.11.0, num models: 14
2023-10-31 22:38:36,346 - ControlNet - INFO - ControlNet v1.1.411
ControlNet preprocessor location: C:\Users\silve\Documents\AI Art\__SDUX\extensions\sd-webui-controlnet\annotator\downloads
2023-10-31 22:38:36,501 - ControlNet - INFO - ControlNet v1.1.411
Checkpoint _Stylized\AutoD4Style_1.1.safetensors [50bc589e27] not found; loading fallback __Anime\_Custom\Roxanne01.safetensors [794b07eb91]
Loading weights [794b07eb91] from C:\Users\silve\Documents\AI Art\__SDUX\models\Stable-diffusion\__Anime\_Custom\Roxanne01.safetensors
Running on local URL:  http://127.0.0.1:7860

To create a public link, set `share=True` in `launch()`.
Creating model from config: C:\Users\silve\Documents\AI Art\__SDUX\configs\v1-inference.yaml
Startup time: 19.6s (prepare environment: 3.7s, import torch: 3.5s, import gradio: 1.2s, setup paths: 0.9s, initialize shared: 0.4s, other imports: 0.9s, setup codeformer: 0.1s, list SD models: 0.1s, load scripts: 3.8s, initialize extra networks: 0.1s, create ui: 2.6s, gradio launch: 2.0s, app_started_callback: 0.2s).
Loading VAE weights specified in settings: C:\Users\silve\Documents\AI Art\__SDUX\models\VAE\Blessed2.vae.safetensors
Applying attention optimization: xformers... done.
Model loaded in 17.6s (load weights from disk: 3.8s, create model: 1.1s, apply weights to model: 11.5s, load VAE: 0.5s, load textual inversion embeddings: 0.2s, calculate empty prompt: 0.2s).

Additional information

On an unrelated note, thank you for the new update! I'm looking forward to exploring it in more depth once this is resolved.

anapnoe commented 11 months ago

can you remove some Loras from your directory and test the acceptable amount of processing them? it is not that loading causing the issue as all images are lazy loaded it is probably that the engine straggles to remove all the event listeners from each card in order to optimize against them also printing all this in the console may slow things down a bit I plan to add this option soon to disable the logs

also when you have an issue it is a good start to disable all extensions to discard any conflict with other extensions

Neverdusk commented 11 months ago

I disabled all extensions manually, leaving in the built-in extensions (since setting Disable All disables this UI). Now the UI just freezes on startup automatically. I think it's refreshing the actual checkpoint model list on startup, which freezes the UI similarly to the Lora list. Got the same out of memory error, even when closing the terminal and tab and restarting it entirely.

I had to remove all of my models from the models/Stable-Diffusion folder in order to re-open the UI. I put four models in and clicked refresh, but only four black bars popped up. I think these are the four models, but I haven't assigned thumbnails images to them, so they only appeared as thin bars. Screenshot 2023-11-01 014139 As a separate note, it is a bit difficult to select models without images, if this is how they appear. In the image above, there are actually six models. The top four don't have assigned images, so they're only displayed as those four thin bars at the top.

Back to testing, I'm slowly adding more models and refreshing as I do. 12 is fine. 16 is fine. 27 is fine. At 36, added all of them back, and it's fine. However, I restarted the UI and it froze again, from loading all of them at once on startup.

So now I'm testing by restarting the UI entirely instead of just refreshing between adding more models back to the folder. Starts up at 16 fine and refreshes fine. Starts up at 27 fine but freezes when refreshing - not crashing but taking several seconds until the UI reacts again. At 36 it starts up fine (I guess the startup glitch is gone?) and also refreshes without crashing or freezing. I'm not sure if things are cached or not, but this is pretty inconsistent.

Note that all of this was done with non-built-in extensions all disabled. And this was with models / safetensor checkpoints as opposed to Loras, since I discovered they had the issue as well.

Actually, I clicked the Lora tab and found all of them shown as well, without me even pressing refresh. Same with embeddings. I'm not really sure what happened or if the source of the actual issue was resolved, but it seems that everything figured itself out between all of the freezing and crashing.

Edit 1: I restarted the UI again, and now nothing is already shown. Refreshed the models list and they appeared after a stutter. But refreshing the lora list froze for several seconds - but they appeared afterwards without crashing.

Edit 2: Restarting the UI has a random chance of showing no models, showing all models after freezing, or showing all models and freezing before crashing. It's basically a roulette, and I can't nail down what's causing it because it happens even without changing anything. When no models are shown, refreshing the model and Lora list freeze but don't crash.

Edit 3: Having any non-built-in extensions installed, regardless of what they are, seems to just increase the chance of freezing or crashing. I removed all but Dynamic Prompts, ControlNet, and MultiDiffusion, and it crashed on reloading Lora. Then I removed only those three extensions, and refreshing Loras still crashed. Removing all extensions makes the chance of crashing random again.

anapnoe commented 11 months ago

can you test with the latest commit? there is a new option in settings Anapnoe UI-UX > disable console log

Neverdusk commented 11 months ago

Sure thing:

Updated to the latest commit. The UI froze on startup and ran out of memory again, so I removed all of my extensions to startup normally.

Enable console log was already checked, so I unchecked it and refreshed the Lora list, but nothing happened. Same with the checkpoints and embeddings. They won't show up at all, though each tab's file structure shows the correct folders. This happened whether the console log was enabled or disabled.

Went into settings again and clicked Reload UI (with console log disabled). Everything loaded very quickly. All models and loras appeared on startup.

Shut down the UI entirely and reopened it. Same result - everything appeared immediately. Even the UI started up faster.

Replaced all extensions. Then shut down and reopened the UI. It started up fairly quickly, and all models, embeddings, loras showed up on startup.

While the results were inconsistent in the previous commit I tried, it looks like disabling the console log fixes things. At least from this one quick session of tests I've done. Hopefully it'll last.

On a slightly unrelated note, checkpoints, embeddings, and loras still show up as black lines with no text, if they have no preview thumbnail assigned (when three are listed in a row). I can create an additional Issue for this if necessary. Screenshot 2023-11-01 160109

anapnoe commented 11 months ago

fixed check last commit