mlc-ai / web-stable-diffusion

Bringing stable diffusion models to web browsers. Everything runs inside the browser with no server support.
https://mlc.ai/web-stable-diffusion
Apache License 2.0
3.51k stars 220 forks source link

Image Save/Copy Issue - Grabs Previous Image Instead of Current One #18

Open rkuemon opened 1 year ago

rkuemon commented 1 year ago

When trying to copy or save an image on the demo webpage, it always takes the previous image instead of the currently displayed one. Additionally, if you attempt to copy or save the first generated image, it results in a transparent 512x512 image instead.

Steps to reproduce:

  1. Generate an image.
  2. Attempt to copy or save the first generated image.
  3. Generate another image.
  4. Attempt to copy or save the second image.

Expected results:

Actual results:

Environment:

Please investigate this issue, as it prevents users from properly saving or copying the most recent image.

DustinBrett commented 1 year ago

This is indeed an odd issue. The same thing happens if you try and get the image programmatically from the canvas. I am wondering if it's a WebGPU issue or if the code as is needs some kind of finalization step.

DustinBrett commented 1 year ago

Interestingly, after moving to using a Web Worker with an OffscreenCanvas this issue went away.

tom-leamon commented 1 year ago

I am experiencing this issue as well. Thank you @DustinBrett for the suggestion, modifying the code to use an offscreen canvas worked.