casual-simulation / casualos

Casual Open Simulation for the Web
https://ab1.bot
MIT License
47 stars 8 forks source link

Updates that are sent for temporary branches are repeatedly sent #491

Open KallynGowdy opened 1 week ago

KallynGowdy commented 1 week ago

In InstRecordsClient, updates that are added to temporary branches are added to _sentUpdates, but are never actually acknowledged via the handler for repo/updates_received events.

KallynGowdy commented 5 days ago

Ok, so the updates are kept for a valid reason, which is that temporary branches are deleted by the server once all clients disconnect from it. This means that if a client loses connection, then the server may (or may not) delete the updates, while the client keeps them. Upon reconnect, the client needs to re-upload the updates that it has in order to ensure that everything is synced.

This means that we can't simply erase sent updates for the temporary branches, but we could try implementing a smarter version of document syncing. The server could include some state vector information in the initial update after the branch is watched. This would enable the client to build an update that is optimized for updating the server to the latest version that the client has. It would additionally allow the client to skip storing updates and instead rely on the original documents themselves.

kc9zyz commented 5 days ago

Is there a way to specify things that I really don't care about being held onto? The use-case I'm working with now is the communication of the AR user in 3d space over to other listening clients via a frustum. If that data is lost when the client is disconnected, that is totally fine, as it will push new position information on reconnect.

KallynGowdy commented 5 days ago

@kc9zyz You could try using sendRemoteData(). The messaging system behind it is exactly the same as tag updates, you just have complete control over what is being sent and how the result is handled.

In the future I expect temp branches (tempShared and remoteTempShared spaces) to handle this sort of scenario in a better way, but for now sendRemoteData() would be a better option.

kc9zyz commented 5 days ago

@KallynGowdy that is working perfectly for me! Thanks! I am seeing plenty of these messages now when I try and update a mask or a tag on a temp bot - any ideas? It is filling up the console and I'm concerned that it may mean I'm doing something else wrong. [AuxHelper] No partition for event {type: 'update_bot',

KallynGowdy commented 4 days ago

@kc9zyz That can happen if you have a bot that was created in a space that isn't supported. For example, the temp space isn't actually supported by CasualOS. Instead, the tempLocal space is.

kc9zyz commented 4 days ago

🤦 That fixed it. Thanks again for your help! Everything is running much smoother now.