Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Caching brush settings in mask editor #2271

Merged
merged 16 commits into from
Jan 17, 2025
Merged

Conversation

benceruleanlu
Copy link
Contributor

@benceruleanlu benceruleanlu commented Jan 17, 2025

For #2190 and comfyanonymous/ComfyUI#6458

I think the mask editor needs a lot of refactoring, fixes, and features. I couldn't even navigate the file without resorting to ctrl + f and vscode's minimap.

I tested my changes and they work on my machine, but it might break on desktop? Not too sure how localStorage.setItem works with Electron.

┆Issue is synchronized with this Notion page by Unito

@benceruleanlu
Copy link
Contributor Author

Also, getting this error on every pre-commit run, even trivial changes. I've just been --no-verify ing past it since it threw the same error even on style changes.

✖ vue-tsc --noEmit:
src/views/InstallView.vue(143,24): error TS2339: Property 'trackEvent' does not exist on type '{ readonly getDetectedGpu: () => Promise<GpuType>; readonly setWindowStyle: (style: "custom" | "default") => Promise<void>; readonly getWindowStyle: () => Promise<"custom" | "default">; }'.
src/views/InstallView.vue(182,24): error TS2339: Property 'trackEvent' does not exist on type '{ readonly getDetectedGpu: () => Promise<GpuType>; readonly setWindowStyle: (style: "custom" | "default") => Promise<void>; readonly getWindowStyle: () => Promise<"custom" | "default">; }'.
husky - pre-commit script failed (code 1)

@benceruleanlu benceruleanlu marked this pull request as ready for review January 17, 2025 01:50
@benceruleanlu benceruleanlu requested review from trsommer and a team as code owners January 17, 2025 01:50
Copy link
Collaborator

@christian-byrne christian-byrne left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested and works for me.

@christian-byrne
Copy link
Collaborator

There's also this:

export function getStorageValue(id: string) {
const clientId = api.clientId ?? api.initialClientId
return (
(clientId && sessionStorage.getItem(`${id}:${clientId}`)) ??
localStorage.getItem(id)
)
}
export function setStorageValue(id: string, value: string) {

@webfiltered
Copy link
Contributor

Also, getting this error on every pre-commit run

Does running npm i fix it?

@benceruleanlu
Copy link
Contributor Author

Also, getting this error on every pre-commit run

Does running npm i fix it?

Running npm install does indeed fix it. Very funny!

@benceruleanlu
Copy link
Contributor Author

There's also this:

export function getStorageValue(id: string) {
const clientId = api.clientId ?? api.initialClientId
return (
(clientId && sessionStorage.getItem(`${id}:${clientId}`)) ??
localStorage.getItem(id)
)
}
export function setStorageValue(id: string, value: string) {

ahhh thanks for letting me know, I didn't see this.

let me try and implement this.

Copy link
Member

@huchenlei huchenlei left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alternatively you can also do hidden setting for restoring these states, e.g.

// Hidden setting used by the queue for how to fit images
{
id: 'Comfy.Queue.ImageFit',
name: 'Queue image fit',
type: 'hidden',
defaultValue: 'cover'
},

But that would require you debounce the setter calls, as each adjustment triggers a request to update it in the backend server.

@@ -2545,23 +2584,27 @@ class BrushTool {

private setBrushSize(size: number) {
this.brushSettings.size = size
saveBrushToCache('maskeditor_brush_settings', this.brushSettings)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we would want to debounce these cache calls? You can use https://lodash.com/docs/#debounce

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's a good point. i didn't think of that.

Copy link
Member

@huchenlei huchenlei left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The current state lgtm. You can open a new PR if session/local storage does become an issue later.

@huchenlei huchenlei merged commit cb9d2c6 into Comfy-Org:main Jan 17, 2025
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants