InvokeAI/frontend
psychedelicious eb17dfdeaa Patches redux-persist and redux-deep-persist with debounced persists
Our app changes redux state very, very often. As our undo/redo history grows, the calls to persist state start to take in the 100ms range, due to a the deep cloning of the history. This causes very noticeable performance lag.

The deep cloning is required because we need to blacklist certain items in redux from being persisted (e.g. the app's connection status).

Debouncing the whole process of persistence is a simple and effective solution. Unfortunately, `redux-persist` dropped `debounce` between v4 and v5, replacing it with `throttle`. `throttle`, instead of delaying the expensive action until a period of X ms of inactivity, simply ensures the action is executed at least every X ms. Of course, this does not fix our performance issue. 

The patch is very simple. It adds a `debounce` argument - a number of milliseconds - and debounces `redux-persist`'s `update()` method (provided by `createPersistoid`) by that many ms.

Before this, I also tried writing a custom storage adapter for `redux-persist` to debounce the calls to `localStorage.setItem()`. While this worked and was far less invasive, it doesn't actually address the issue. It turns out `setItem()` is a very fast part of the process.

We use `redux-deep-persist` to simplify the `redux-persist` configuration, which can get complicated when you need to blacklist or whitelist deeply nested state. There is also a patch here for that library because it uses the same types as `redux-persist`.

Unfortunately, the last release of `redux-persist` used a package `flat-stream` which was malicious and has been removed from npm. The latest commits to `redux-persist` (about 1 year ago) do not build; we cannot use the master branch. And between the last release and last commit, the changes have all been breaking.

Patching this last release (about 3 years old at this point) directly is far simpler than attempting to fix the upstream library's master branch or figuring out an alternative to the malicious and now non-existent dependency.
2022-11-27 03:35:49 +13:00
..
dist Fixes inpainting + code cleanup 2022-11-27 03:35:49 +13:00
patches Patches redux-persist and redux-deep-persist with debounced persists 2022-11-27 03:35:49 +13:00
src Fixes (?) spacebar issues 2022-11-27 03:35:49 +13:00
.eslintrc.cjs React web UI with flask-socketio API (#429) 2022-09-16 13:18:15 -04:00
.gitignore Fix WebUI Not Working 2022-10-07 08:09:55 +13:00
eslintconfig.json Rebases against development 2022-11-27 03:35:49 +13:00
favicon.ico Add New WebUI and Desktop Mode 2022-10-03 23:28:53 -04:00
index.d.ts React web UI with flask-socketio API (#429) 2022-09-16 13:18:15 -04:00
index.html Add New WebUI and Desktop Mode 2022-10-03 23:28:53 -04:00
package.json Pins react-hotkeys-hook to v4.0.2 2022-11-27 03:35:49 +13:00
README.md Rebases against development 2022-11-27 03:35:49 +13:00
tsconfig.json Rebases against development 2022-11-27 03:35:49 +13:00
tsconfig.node.json Rebases against development 2022-11-27 03:35:49 +13:00
vite.config.ts Rebases against development 2022-11-27 03:35:49 +13:00
yarn.lock Pins react-hotkeys-hook to v4.0.2 2022-11-27 03:35:49 +13:00

Stable Diffusion Web UI

Run

Evironment

Install node (includes npm) and optionally yarn.

From frontend/ run npm install / yarn install to install the frontend packages.

Dev

  1. From frontend/, run npm dev / yarn dev to start the dev server.
  2. Run python scripts/dream.py --web.
  3. Navigate to the dev server address e.g. http://localhost:5173/.

To build for dev: npm build-dev / yarn build-dev

To build for production: npm build / yarn build

TODO

  • Search repo for "TODO"