y-crdt / ydotnet

.NET bindings for yrs.
MIT License
35 stars 9 forks source link

Use 32-bit number when generating random client IDs #42

Closed SebastianStehle closed 11 months ago

SebastianStehle commented 11 months ago

yjs uses 32 bit client ids. If a client is exceeds the 32 range it cannot be decoded on the client anymore:

There is also an open discussion about that. https://github.com/y-crdt/y-crdt/issues/209

LSViana commented 11 months ago

Hi, @SebastianStehle!

LGTM.

Horusiath commented 11 months ago

@LSViana @SebastianStehle only older versions of Yjs use 31bit client IDs, all never ones use 53bit (numbers are related to safe integer representation of integer in JS).

LSViana commented 11 months ago

Rolling back the PR changes based on the previous commit.

SebastianStehle commented 11 months ago

64 bit is definitely wrong, because it cannot be read in yjs depending on the value. therefore 32bit is safe for backwards compatibility and 53 bit should be preferred to reduce collisions.

LSViana commented 11 months ago

Hi, @SebastianStehle!

If you'd like to provide another PR with the best fix for the future, please feel free to do that. I'm not sure we need to go back to 32-bit integers just for backward compatibility if we can make the code aligned with the latest version of Yjs.