Repository: stable-diffusion-webui
Issue: [Bug]: Textual inversion training slowed down / stalls when browser WebUI  is displayed on screen
Labels: bug-report

### Is there an existing issue for this?

- [X] I have searched the existing issues and checked the recent builds/commits

### What happened?


I don't have a a log to provide but it is systematic, at least on my setup : 
When I launch a Textual inversion training, each step is slowed down or, in slow learning "Embedding learning rates", is  completely stalled when the browser displaying stable diffusion is displayed on screen. 
The simple fact of reducing it to task bar , "solve" the issue.

My Setup : 
RTX 3080
I7 10th gen
SSD hard drives
Windows 11
SD launched via visual studio code on a powershell terminal
several monitors of various size (seems to have no impact, even if I unplug 2 of them, the issue is still there)
TI launched on sd1.5 pruned emaonly
Automatic1111 v1.3.0
commit hash : 20ae71faa8ef035c31aa3a410b707d792c8203a3 and below (not tested the most recent one yet)
Browser tested : Firefox (latest) 

### Steps to reproduce the problem

1. Go to train /Train  
2. Define low Embedding Learning rate for more pronounced behaviour (inferior to 0.0005)
3. Define the other parameters
4. Give a fat dataset in parameter  for more pronounced behaviour (superior to 50 pics, various size, not 512x512 only)
5. Launch a training, keep the browser displayed on screen, with the terminal and notice that the steps are really slowed (best scenario but it is more than noticeable), or even stalled 


### What should have happened?

On terminal, you should see on normal behaviour, the steps going further at a reasonable pace. not stalling or slowed


### Commit where the problem happens

20ae71faa8ef035c31aa3a410b707d792c8203a3 and below

### What Python version are you running on ?

Python 3.10.x

### What platforms do you use to access the UI ?

Windows

### What device are you running WebUI on?

Nvidia GPUs (RTX 20 above)

### What browsers do you use to access the UI ?

Mozilla Firefox

### Command Line Arguments

```Shell
--xformers
```


### List of extensions

a1111-sd-webui-lycoris
clip-interrogator
embedding-inspector
openpose-editor
sd_civitai_extension
sd-dynamic-prompts
sd-webui-controlnet
stable-diffusion-webui-tokenizer
put extensions here.txt # ;)

### Console logs

```Shell
None => everything is normal on console except it is stalled, doesn't answer to keystroke either. (enter for instance. Ctrl +C after .... seeeeeeeeeeeeeeeveral attempts)
```


### Additional information

**Workaround :** 
Reduce the browser to taskbar and notice the steps are getting back on track.


The first I noticed it was on a fat pic dataset, and a slow embedding learning rate. I launch a training on the afternoon and it started to slow down , and down. but it was still moving . It ran all afternoon without issue, all evening. around 12 AM I checked some stuff on my PC (which was slow, but hey => training I thought),  I checked the epoch and steps and went to bed. It stayed stalled for a complete night: more than 6 hours on the same step without errors on the terminals, it just hanged

The screen was displaying A1111 under firefox, the task manager on performance pannel, and the terminal under VSCode.
I reduced firefox to fetch the file explorer that was below => the steps did get back on track right away.





**Also to interrupt a training, knowing this:** 
1. raise the browser
2.  click a long time/press on interrupt, pay attention to see the color change of the button (it acknowledged the action)
3. reduce your browser
4. wait you see on terminal ""Applying optimization: xformers"
Training has been interrupted correctly



My guess is that gradio calls a refresh to often, preventing the training process to go forward.