overte-org / overte

Overte open source virtual worlds platform.
https://overte.org/
Other
138 stars 50 forks source link

Support entity properties > 1 MTU #830

Open HifiExperiments opened 7 months ago

HifiExperiments commented 7 months ago

I am not familiar with this part of the code at all. This is a highly experimental and possibly dangerous change. But...it seems to work (in my basic tests)!

There are two parts to this change:

Client -> Server Communication (EntityEditLarge)

Clients communicate edits via EntityEditPacketSender::queueEditEntityMessage, which calls EntityItemProperties::encodeEntityEditPacket. This gets called multiple times, packing all the changed properties into multiple individual packets. If the first property in a new packet doesn't fit (reported via firstDidntFitProperty), we know it's too big, and we instead search for a large enough buffer and send an EntityEditLarge packet list.

Server -> Client Communication (EntityDataLarge)

The server is a little more complicated. It is constantly trying to send multiple entities to multiple clients as things change. OctreeSendThread::traverseTreeAndSendContents builds up _packetData in EntityTreeSendThread::traverseTreeAndBuildNextPacketPayload and sends it as EntityData packets. Now, if the first property we encounter doesn't fit (_numEntities == 0 && firstDidntFitProperty was set), we again search for a large enough buffer and send a EntityData packet list...a little circuitiously through handlePacketListSend.

Notes:

ksuprynowicz commented 7 months ago

I just tested the PR, and when starting game in tutorial world it segfaults in libraries/entities/src/EntityItem.cpp line 391. Here's the backtrace and local variables: image

ksuprynowicz commented 7 months ago

It's possible that this affects serverless worlds only

ksuprynowicz commented 7 months ago

The crash seems to happen every time for me when launching interface in Tutorial.

gydence commented 7 months ago

thank you, I’ll take a look! looks like it’s specific to when you have an avatar entity attached

HifiExperiments commented 7 months ago

@ksuprynowicz should be fixed!

ksuprynowicz commented 7 months ago

The crash is fixed now :) It seems that there's another problem though. I started a server and client on this version, and large part of the entities on that copy of Overte Hub were missing. I will do more teating tomorrow.

HifiExperiments commented 7 months ago

@ksuprynowicz interesting - are there even any entities in the domain that hit the packet limit? if there are none I'm surprised, as the code should operate as before.

if there are any, I did encounter a similar issue at one point during testing, but I thought I had fixed it. it related to the sequence number and the changes in OctreeSendThread.cpp. when we send a large packet, we rewrite the sequence number of the normal size packet that we have at the time to bump it. but now that we're sending a mix of normal packets and packet lists, I don't totally understand if the sequence numbers are able to handle it.

ksuprynowicz commented 6 months ago

Here's a screenshot of the same place in master branch and in PR 830: Master branch: overte-snap-by--on-2024-03-10_17-41-31

PR 830: overte-snap-by--on-2024-03-10_18-52-59