LogikSim / LogikSimPython

Python prototype of a digital logic simulator
http://www.logiksim.org/
GNU General Public License v3.0
2 stars 1 forks source link

Meta data change loop #45

Closed christianbrugger closed 9 years ago

christianbrugger commented 9 years ago

Currently when notifying the backend on a metadata update through Interface.update_element causes the backend to report back the metadata update via InsertableItem.update. This loop causes serious issues.

@hacst: I propose that the backend only reports on metadata changes induced from the backend, e.g. on item creation, when additional fields are set or when logic states change, but not on updates from the specific frontend / GUI.

One issue with the current approach is, that it is not clear anymore to the InsertableItemwhether to apply a change or not, when multiple updates have been scheduled. Imagine the following situation. An element is moved quickly with the mouse from x=0 to 1 and finally 2. The element issues two updates to the backend: {'x': 1} and a few ms later {'x': 2}. Then after a while the backend reports an updated position via InsertableItem.update({'x': 1}). The item being at position x=2 has now to assume that it has to move to position x=1, causing an unnecessary state change. This is more serious for large moves and makes the GUI seem to misbehave (stuttering). That is why the backend should never report back on incoming updates.

hacst commented 9 years ago

That's why state changes should only be reported to the backend after they are completed and items should not directly apply them while they are being modified in the value in question. If the metadata that changes isn't repropagated you have no way to make sure that the UI stays in sync with the backend. Especially if you ever want to have multiple frontends to one backend.

The ideal state is to optimistically apply changes directly to the frontend element as the user performs them (during interaction the user is in control) but to always become eventually consistent with the authoritative state in the backend.

christianbrugger commented 9 years ago

I resolved this issue by not sending all state changes to the backend. But rather introduce some sync points in the GUI where all changes are collected and send in a batch to the backend. Such sync points are currently performed when changing modes (e.g. going from selection to edge triggering).