krita-ai-diffusion icon indicating copy to clipboard operation
krita-ai-diffusion copied to clipboard

The first generated image gets lost

Open fukc-gihtub opened this issue 2 months ago • 3 comments

With a custom ComfyUI server, the first image generated after the server starts often ~~(always?)~~ gets lost. In the server console I can see it gets successfully generated (100%, Prompt executed in ...), but it never appears in Krita. The generation then continues and the remaining images/batches do appear in Krita.

fukc-gihtub avatar Oct 20 '25 06:10 fukc-gihtub

I think this is it. The plugin sometimes receives a ClientEvent.disconnected event for some reason. The server meanwhile continues to run the job and shows 100% done.

ClientMessage(event=<ClientEvent.connected: 4>, job_id='', progress=0, images=None, result=None, error=None)
ClientMessage(event=<ClientEvent.progress: 0>, job_id='4739b4a0-e4ab-4e07-b248-f9ed45d593e0', progress=0.11764705882352942, images=None, result=None, error=None)


(skipped)


ClientMessage(event=<ClientEvent.progress: 0>, job_id='4739b4a0-e4ab-4e07-b248-f9ed45d593e0', progress=0.5811764705882354, images=None, result=None, error=None)
**ClientMessage(event=<ClientEvent.disconnected: 5>, job_id='', progress=0, images=None, result=None, error=None)**
ClientMessage(event=<ClientEvent.connected: 4>, job_id='', progress=0, images=None, result=None, error=None)
ClientMessage(event=<ClientEvent.connected: 4>, job_id='', progress=0, images=None, result=None, error=None)
ClientMessage(event=<ClientEvent.connected: 4>, job_id='', progress=0, images=None, result=None, error=None)


the next job starts here:


ClientMessage(event=<ClientEvent.progress: 0>, job_id='90548eb9-4957-49fd-9d12-f21bb074ef49', progress=0.11764705882352942, images=None, result=None, error=None)
ClientMessage(event=<ClientEvent.progress: 0>, job_id='90548eb9-4957-49fd-9d12-f21bb074ef49', progress=0.12941176470588237, images=None, result=None, error=None)

In the server console (5 images done but only 4 show up in Krita):

loaded completely 13524.688992370606 11350.067443847656 True
100%|███████████████████████████████████████████████████████████████████████████████████████████████| 20/20 [00:40<00:00,  2.01s/it]
Requested to load AutoencodingEngine
loaded completely 181.96966552734375 159.87335777282715 True
Prompt executed in 74.72 seconds
loaded completely 13552.690642227173 11350.067443847656 True
100%|███████████████████████████████████████████████████████████████████████████████████████████████| 20/20 [00:39<00:00,  1.97s/it]
Prompt executed in 41.27 seconds
loaded completely 13552.690642227173 11350.067443847656 True
100%|███████████████████████████████████████████████████████████████████████████████████████████████| 20/20 [00:39<00:00,  1.97s/it]
Prompt executed in 41.11 seconds
loaded completely 13543.315642227173 11350.067443847656 True
100%|███████████████████████████████████████████████████████████████████████████████████████████████| 20/20 [00:39<00:00,  1.96s/it]
Prompt executed in 40.85 seconds
loaded completely 13543.315642227173 11350.067443847656 True
100%|███████████████████████████████████████████████████████████████████████████████████████████████| 20/20 [00:39<00:00,  1.96s/it]
Prompt executed in 40.92 seconds

fukc-gihtub avatar Oct 21 '25 06:10 fukc-gihtub

ClientEvent.disconnected only happens when the web-socket connection is interrupted, ie. an actual disconnect. It establishes a new connection afterwards, that can lead to images being dropped.

Not really sure what would cause it though, I have not heard of this happening to anyone else.

Acly avatar Oct 21 '25 08:10 Acly

Thanks. I'll try to use tcpdump and see what happens to the connection.

fukc-gihtub avatar Oct 21 '25 10:10 fukc-gihtub