chrisgoringe / cg-image-picker

233 stars 16 forks source link

Multiple browser tabs with the Chooser nodes interact with each other #3

Closed EricRollei closed 11 months ago

EricRollei commented 11 months ago

Using Chrome, Windows 11, Comfyui standalone version

I've got several similar workflows open on different tabs and noticed that when one work flow was paused on any tab, hitting 'go' or cancel on a tab on another tab's workflow will cause the one that's paused to 'go'. If you have started a cue of batched images, sometimes it won't run until you switch to another tab and hit cancel on the chooser node even though you weren't using that one. Odd? or is that just a problem with ComfyUI and tabs?

chrisgoringe commented 11 months ago

Thanks for the report - yes, this makes sense. The 'go' button has an effect which is kind of global at the moment, so multiple tabs could get really confusing. I'll need to look at how this could be made to work properly.

EricRollei commented 11 months ago

I'm terrible with too many open tabs, but when I am working on different ideas I like to have several workflows going at the same time. So while one is tied up generating, I can work on editing the graph or prompt on another. So it would be cool for the chooser node to not interact, but I definitely can manage it if that's not easy. I do really enjoy the image chooser - it will be a big time saver - so thank you for that. I will check out your other nodes as well.

chrisgoringe commented 11 months ago

Just be aware that many of my nodes are works in progress!

EricRollei commented 11 months ago

Are you on the ComfyUI matrix message boards? Very good resource, comfyanonymous and a lot of the developers are there every day.

chrisgoringe commented 11 months ago

Yeah, they're great on matrix.

Latest update - I've added an id to the node - randomly changes every time you use it - should link the node specifically to it's button. See if that works.

EricRollei commented 11 months ago

image Okay cool, I'm testing this now. I ran a batch and it stopped as normal at the chooser node with images in the preview box. Then I went to another open tab and tried to choose an image from that other tab, hit the go button, and then cancel. So far so good. Next I went to the chooser node on the correct tab that just ran the batch, and set the value and then clicked "go". What it did was print a value for the id into the chooser value box, but didn't advance the workflow. Pressing Go again only gave me a new id number. Trying to change that to the old number 2, and hit go also didn't work. and I got an error: Traceback (most recent call last): File "A:\Comfy_Aug\ComfyUI\execution.py", line 152, in recursive_execute output_data, output_ui = get_output_data(obj, input_data_all) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "A:\Comfy_Aug\ComfyUI\execution.py", line 82, in get_output_data return_values = map_node_over_list(obj, input_data_all, obj.FUNCTION, allow_interrupt=True) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "A:\Comfy_Aug\ComfyUI\execution.py", line 75, in map_node_over_list results.append(getattr(obj, func)(**slice_dict(input_data_all, i))) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "A:\Comfy_Aug\ComfyUI\custom_nodes\cg-image-picker\image_chooser.py", line 49, in func i = (int(MessageHolder.popMessage(id))-1) % images.shape[0] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ValueError: invalid literal for int() with base 10: ''

image

chrisgoringe commented 11 months ago

OK there are two issues here...

The first is that the choice widget is blank. I think that can happen when the node is updated, and you reload a workflow. So after the next update (see below!), please make sure you delete the Image Chooser nodes and then re-add them.

The second issue is that if you press 'go' or 'cancel' when the node isn't running (outlined in green) bad things happened. I've added a check so the buttons don't do anything if the node isn't active.

Maybe you could update, remove and readd the nodes, and try it?

Also - in image_chooser.py (in custom_nodes/cg-image-picker) there are two lines commented out (lines 24 and 31) with print statements to help debug. If the problem reoccurs, uncomment them!

EricRollei commented 11 months ago

Seems to be working now, thank you. And that was fast.
This is the console output I got when I chose a value and pressed "go" Message added: 5 from id 6139717 Message read : 5 for id 6139717

Oops sorry, the cancel button isn't working.....

EricRollei commented 11 months ago

If you hit cancel, and nothing happens and then choose a value and hit go it completes, but if you hit cancel multiple times you can't even continue if you hit go after that. Instead, you get an new id each time you press go Message added: 1 from id 3867408 Message added: 1 from id 999990 Message added: 1 from id 5360114 Message added: 1 from id 4916546 Message added: 1 from id 9405670 Message added: 1 from id 2618880

could not even cancel from the Manager Queue ... had to close the terminal window and restart comfy

chrisgoringe commented 11 months ago

Can you go into custom_nodes/cg-image-picker/js/iamge_chooser.js and comment out lines 15 and 25 (the second and third time that node.widgets[0].value = Math.floor(Math.random() * 10000000); appears, then restart the server, reload the page, and see what happens?

(comment in javascript is by putting // before the line, just in case you aren't familiar!)

It should stop the random changes of the id which are probably causing these issues. The random changes were only added to deal with the case of someone cloning the node (and therefore getting duplicate ids), but I think I can work around that in a different way.

EricRollei commented 11 months ago

Was able to edit that, and restart. Cancel works now!

Message added: 0 from id 152905 Message read : 0 for id 152905 Processing interrupted Prompt executed in 117.51 seconds

chrisgoringe commented 11 months ago

OK - just committed an update which removes those lines, and fixes clone so it generates a new id. That should be much more robust!

EricRollei commented 11 months ago

Thank you! Your image chooser will save me a ton of time.

And ideas for future... if there is a way to loop through this and make a 2nd or third selection that would be awesome. Next thought... have you seen the Fabric node sets that allow for neg and pos latent 'training'. Your chooser could be very useful in a workflow involving that - since you could choose the best or worst or both to pass down the line to the next iteration...

chrisgoringe commented 11 months ago

On looping through - see this note, and then this request and feel free to add your comments to the request.

Fabric node - no, I haven't seen it. Point me to it?

Closing this issue now, but I think you can still comment (if not you can open a new one with thoughts about Fabric).