alswl / excalidraw-collaboration

excalidraw with collaboration feature, self-hosting, and only one-click deploy
MIT License
393 stars 67 forks source link

Images not working when "Export to Link" was used #53

Closed Someone0nEarth closed 8 months ago

Someone0nEarth commented 9 months ago

First things first: Thanks for your work!!

I got the collaboration mode to work, but there are some anomalies when dealing with images:

Images working fine in the collaboration mode:

grafik

Until someone did a save using "Export to Link". When using the link, only a placeholder for the image will be shown:

grafik

When using the room-share link after doing the "Export to Link" the images wont be shown too.

When doing a "Save to disk", the images are referenced in "elements", but the "files" are empty.

Ways to reproduce:

1) Export to Link

  1. Create a new drawing and pasting an image into it.
  2. Do a "Export to Link"
  3. Using the export-link: Now, only the placeholder will be shown

2) Export to Link after starting a Live Collaboration

  1. Create a new drawing and pasting an image into it.
  2. Starting a "Live collaboration": Image will be shown, when using the collaboration-link
  3. Do a "Export to Link"
  4. Using the collaboration-link: Now, only the placeholder will be shown (the same when using the export-link)

3) Export to Link before starting a Live Collaboration

  1. Create a new drawing and pasting an image into it.
  2. Do a "Export to Link"
  3. Using the export-link: Now, only the placeholder will be shown
  4. NOW start a "Live collaboration"
  5. Using the collaboration-link: Now, the image (!) will be shown
  6. Do another "Export to Link"
  7. Using the collaboration-link again: Now, only the placeholder (!) will be shown

Summary

As soon as a "Export to link" was done, images will be shown only as a placeholder. Beside the one special case in 3), when a collaboration session was`t started, it will work until the next "Export to link" for the collaboration mode.

Btw: When restarting all the services, images will still be shown when using the collaboration link (until the drawing was "exported to link"). So there is some kind of working image persistence.

I'm using alswl/excalidraw:v0.17.0-fork-b2, alswl/excalidraw-storage-backend:v2023.11.11 and excalidraw/excalidraw-room:sha-49bf529. But same behavior when using excalidraw/excalidraw-room.

I tried this with redis, postgres and mongodb.

Someone0nEarth commented 9 months ago

Some more additional infos:

Rooms, scenes and files are stored in the mongo:

grafik

And using "rooms" only, files working as aspected, until a scene with this file is created.. than files wont load for rooms and scenes. In the file-exports, the linked "fileId" is correct and still present in the db. Even the file itself is identical, besides "files" is empty:"files": {}`

Someone0nEarth commented 9 months ago

Hello again,

I did a little more digging into it. My knowledge of Javascript frameworks etc are limited... but maybe these are the reasons, why files are not working with "http storage" as soon they are is in scenes:

https://github.com/alswl/excalidraw/blob/1d751e7dc15d1f1b00101e52cf1607bbedccef1c/excalidraw-app/index.tsx#L333

grafik

https://github.com/alswl/excalidraw/blob/1d751e7dc15d1f1b00101e52cf1607bbedccef1c/excalidraw-app/index.tsx#L358

grafik

As I said, my knowledge of JS etc. is limited, so, sadly, I won't be able to proof or fix this in a affordable time.

But maybe, this was helping ...

farapholch commented 9 months ago

@Someone0nEarth I'm unable to even export the link, not sure whats wrong with my config, heres the error message:

image

image

Someone0nEarth commented 9 months ago

@Someone0nEarth I'm unable to even export the link, not sure whats wrong with my config, heres the error message:

Hey @farapholch I would bet, changing the backend GET and POST URL pathes too /api/v2/scenes/ will fix your issues.

farapholch commented 9 months ago

@Someone0nEarth thank you so much! :) Its now working.

woremacx commented 8 months ago

@alswl Thank you for the great changes.

I made some changes that I believe can solve this issue and have submitted a PR. Please check it out.

Init storageBackend before use it by woremacx · Pull Request #30 · alswl/excalidraw

Someone0nEarth commented 8 months ago

@alswl Thank you for the great changes.

I made some changes that I believe can solve this issue and have submitted a PR. Please check it out.

Init storageBackend before use it by woremacx · Pull Request #30 · alswl/excalidraw

Thanks @woremacx !! That fixed it! Now the images are working!!

@alswl Please pull woremacx fix :D

alswl commented 8 months ago

@woremacx Cool, I'w review this changes and release a new version.

alswl commented 8 months ago

Now the new version is released, and the demo site( https://excalidraw-production-4d27.up.railway.app/) is upgraded. You can check out the new image.

Thanks a lot to @Someone0nEarth and @woremacx .

woremacx commented 8 months ago

Thanks @alswl for great hack, and @Someone0nEarth for docker-compose files.