hediet / vscode-drawio

This unofficial extension integrates Draw.io (also known as diagrams.net) into VS Code.
https://marketplace.visualstudio.com/items?itemName=hediet.vscode-drawio
GNU General Public License v3.0
9.02k stars 406 forks source link

Synchronization Loss #380

Open jeeftor opened 1 year ago

jeeftor commented 1 year ago

Hello, I'm wondering if/why how to debug my vscode sessions loosing sync:

I noticed this message:

vscode <- drawio: { error: "unknownMessage", data: "{"action":"updateLiveshareViewState","selected"+... }

in the log - and I've got to a situation where my two views have become unsynced...

image

Any idea how to debug this better?

Thanks

Is there a way to run the extension in debug mode with a debug console or something and step through? Obviously there is code for this updateLieveshareViewState - but I'm not sure what's going on.

image

jeeftor commented 1 year ago

So it looks like client sends out the following info:

image

But when I look at the log on my server it really seems like other data is coming across... (unless its being truncated somehow)

I'm going to assume if this gets fixed the cursor will start working again too...

jeeftor commented 1 year ago

So @hediet - if I check out your source what do I run to "debug" this plugin?

image
jeeftor commented 1 year ago

I'm pulling down an empty insider vscode + insider plugin to verify the issues still exist...

jeeftor commented 1 year ago

Trying this out with the insider build:

I've got insiders with Live Share + Insider plugin and I've got a web view opened with just insider plugin:

I can't duplicate the sync loss - however - I am able to duplicate the error message:

image

vscode -> drawio: { action: "updateLiveshareViewState", selectedCells: [ ], cursors: [ ], selectedRectangles: [ ] } vscode <- drawio: { error: "unknownMessage", data: "{"action":"updateLiveshareViewState","selected"+... }

(Here is how I ran)

image
jeeftor commented 1 year ago

So I've played around with the debugging a little but I'm running into a local storage issue:

When I run image

I seem to run into a local storage config issues

        const localStorage = untracked(() => config.localStorage);

image

Is there something I'm doing wrong here - or do I need to pass in some config options?

Thanks

jeeftor commented 1 year ago

Oh the other thing is when trying to develop the plugin it just hangs at the

image

loading screen - so I wasn't sure if the storage was an issue here.

jeeftor commented 1 year ago

Unless its tied to this error:

023-03-27 14:05:01.579 [warning] hediet.vscode-drawio created a webview without a content security policy: https://aka.ms/vscode-webview-missing-csp
2023-03-27 14:06:07.441 [info] ExtensionService#_doActivateExtension vscode.simple-browser, startup: false, activationEvent: 'onOpenExternalUri:https'
hediet commented 1 year ago

Thanks for investigating!

This is for sure a liveshare problem, as this extension does not synchronize the state on its own.

You can verify this to be a liveshare issue by reopening the diagram with the text editor and see that the text does not agree.

I also run into this even without draw.io.

jeeftor commented 1 year ago

I definitely went down the rabbit hole yesterday of jumping through the javascript (TS) land of doom...

When you are developing any chance you can post your debugging flow?

it seems like running (dev) kinda worked but I couldn't really get the plugin to synchronize correctly due to running into local storage issues... I'd be happy to help out with debugging/patching...

hediet commented 1 year ago

I'll see what I can do! There is nothing this extension can do though to improve synchronization... It all goes through the VS Code text model and then the liveshare extension ensures that all text models of the same uri on different machines eventually converge.

jeeftor commented 1 year ago

I wonder if they made any API changes whatsoever.

In any case -> When testing the cursor tracking I did notice differences between Web -> Electron vs Electron -> Electron...

Not sure why but I think possibly maybe they've embedded a node-js inside the native app?