ls1intum / Apollon

UML Modeling Editor written in React
https://apollon-library.readthedocs.io
MIT License
61 stars 21 forks source link

remove layouter from patch import process to avoid deadlock on resize #341

Closed loreanvictor closed 5 months ago

loreanvictor commented 5 months ago

Checklist

Motivation and Context

Currently, incoming patches that resize elements with child elements might result in further layout changes (to fix child element layout), which erroneously would cause further patches to be issued by the recipient client, putting collaboration peers in a dead lock (continuously patching each other, not allowing the actual resize to happen).

Description

With this fix, the layouter code is completely removed from the patcher service. Based on prior optimisations, this doesn't seem to break any layouts while importing patches.

Steps for Testing

  1. Run Apollon collaboration (for example, using Apollon_standalone).
  2. Use Apollon.subscribeToAllModelPatches() method for syncing patches.
  3. Open two clients in collaboration mode.
  4. Create elements with child elements (e.g. a Class node).
  5. Resize the parent element.

Without this change, you will get a deadlock. With this change, resizing is smoothly synced between clients.

Caveat

This solution has the downside that importing some patches can actually result in broken diagram layout. Previously, the patcher service would have prevented this. This might specifically happen when two clients are greatly out of sync and for some reason they receive patches from each other.

Test Coverage

Some code was removed, so coverage is unaffected.

Screenshots

Before:

ScreenRecording2024-01-29at08 46 51-ezgif com-video-to-gif-converter

After:

ScreenRecording2024-01-29at08 49 47-ezgif com-video-to-gif-converter