Comfy-Org / ComfyUI_frontend

Official front-end implementation of ComfyUI
https://www.comfy.org/
GNU General Public License v3.0
575 stars 99 forks source link

[Bug]: 'Reroute' nodes shrink after loading .json file #723

Open martin-rizzo opened 2 months ago

martin-rizzo commented 2 months ago

Frontend Version

v1.2.44

Expected Behavior

When saving a workflow to a .json file and reloading it, 'Reroute' nodes should retain their original size, ensuring that the name the user has given to the slot remains visible.

Actual Behavior

After saving the workflow to a .json file and reloading it, the 'Reroute' nodes become smaller. This change not only alters the workflow layout but also results in a size so small that the slot name exceeds the node's boundaries, making it difficult to read.

Steps to Reproduce

  1. Create a new workflow in ComfyUI.
  2. Add a KSampler node, a pair of CLIP Text Encoders, and connect them using the 'Reroute' node.
  3. Modify the Reroute slot name by entering a long piece of text.
  4. Adjust the size of these nodes to ensure they are large enough to display the slot name correctly.
  5. Save the workflow as a .json file.
  6. Reload the workflow from the .json file.
  7. Observe that the size of the 'Reroute' nodes has shrunk, and the slot name is outside the node's boundaries. reroute-bug reroute-bug.json

Debug Logs

otal VRAM 9906 MB, total RAM 31809 MB
pytorch version: 2.4.0+cu124
Set vram state to: NORMAL_VRAM
Device: cuda:0 NVIDIA GeForce RTX 3080 : cudaMallocAsync
Using pytorch cross attention
Downloading frontend(Comfy-Org_ComfyUI_frontend) version(1.2.44) to (/home/aiman/AIMan/Repos/comfyui/web_custom_versions/Comfy-Org_ComfyUI_frontend/1.2.44)
[Prompt Server] web root: /home/aiman/AIMan/Repos/comfyui/web_custom_versions/Comfy-Org_ComfyUI_frontend/1.2.44
Skipping loading of custom nodes
Starting server
To see the GUI go to: http://127.0.0.1:8086

Browser Logs

-

What browsers do you use to access the UI ?

Google Chrome

Other

This issue seems to be related to this previous bug: https://github.com/Comfy-Org/ComfyUI_frontend/issues/676.

webfiltered commented 1 month ago

This also applies to Primitive nodes. It's caused by LiteGraph's default behaviour - shrink nodes to to the "right" size whenever a widget is added (iirc, it just calls computeSize + setSize).

As undo reloads the workflow, this also triggers it. I wrote a quick and ugly workaround, so never bothered fixing it properly:

const addWidget = LGraphNode.prototype.addWidget
LGraphNode.prototype.addWidget = function (type, name, value, callback, options) {
    const size = this.size

    const w = addWidget.apply(this, arguments)

    if (size) {
        size[0] = Math.max(size[0], this.size[0])
        size[1] = Math.max(size[1], this.size[1])
    }
    this.setSize(size)

    return w
}

Not a solution - it introduces its own annoying behaviour.