ArnoldSmith86 / virtualtabletop

a virtual surface in the browser on which you can play board, dice and card games
https://virtualtabletop.io
GNU General Public License v3.0
173 stars 31 forks source link

fixed crash and missing cards when one client deletes a pile while another adds a card #2363

Open ArnoldSmith86 opened 1 week ago

ArnoldSmith86 commented 1 week ago

Fixes #2360. Fixes #27. I will build a room to test this. Should not be too hard.

Edit: I can still trigger the problem in the pr-test room. Edit 2: Still broken after second commit.


PR-SERVER-BOT: You can play around with it here: https://test.virtualtabletop.io/PR-2363/pr-test (or any other room on that server)

bjalder26 commented 1 week ago

This seems hard to trigger, is the code too involved to plug into jsfiddle with some fake variables and try a bunch of deltas in receiveDelta()?

ArnoldSmith86 commented 1 week ago

Using my phone and my laptop, I can trigger this pretty easily.. I'm pretty sure I'll get this to work soon.

96LawDawg commented 1 week ago

I could also trigger it.

ArnoldSmith86 commented 6 days ago

I think the detection is working as intended but it also crashes if the conflicting deltas are the other way around. Gotta add another test for that.

ArnoldSmith86 commented 5 days ago

Huh. The conflict detection seems to work now but the client still has to handle the broken delta. It goes like this:

  1. Client A sends delta 1 that sets any parent to widgetA.
  2. The server receives delta 1, accepts it and broadcasts it.
  3. Client B didn't receive delta 1 yet and sends delta 2 that removes widgetA.
  4. Client B receives delta 1 and crashes because it can't set parent to widgetA anymore because it deleted it. :boom:
  5. The server receives delta 2, notices a conflict and sends the game state to client B. But client B already crashed.