Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Server not sending all parents before children in initial scene sync #775

Open
jonnenauha opened this issue Sep 8, 2014 · 1 comment
Open
Labels

Comments

@jonnenauha
Copy link
Member

While I was implementing the drag and drop Entity parenting in scene struct windows, I noticed this bug. Making a mental note here to fix it later. Also asking for input from @cadaver as you know the sync manager code best and authored Entity parenting.

How to reproduce

  1. Login to a server with a client.
  2. Create two Entities.
  3. Parent the smaller id Entity to the bigger entity Id. (eg. Entity Teleport not working in OpenSim #1 to Entity Debian sid segmentation fault #2).
  4. Logout and login back.
  5. You should see a warning on the console (client side) Failed to find parent Entity #2 for Entity

I looked at the code of the SyncManager server state processing. It looks like the initial scene sync is done in the order of creation (essentially ascending by id). This is not good enough anymore as we have parenting. The result on the client is that scene struct and actually even the code Entity::Parent() will lie to the user. The parents creation is not monitored if it fails to be found during creation. I think this is good because we dont want the mess/complexity of EC_Placeable::parentRef monitoring.

Proposed solution

It's quite simple really if I'm not missing something. Don't send the new Entity messages while processing the state (looping dirty new ents). Instead make a list and insert each item to the correct place as per parenting hierarchy. It might be even faster to create two lists, one for root Entities and after those Entities that have children. Then a secondary list that has any parented Entities.

After all new ents have been processed, loop the list (or the two lists) and send them to the client in the correct order.

@cadaver I see that the initial sync is the only place where problems might occur would you agree? Do you see any problems coming from changing the order of initial sync entities?

Edit: If you save the scene after pareting to txml/tbin Restart the server with that scene description, it will get fixed. Thanks to the proper hierarchy in the scene descs now, the parent will always get created before the children. Hence getting a smaller id and getting added to the client states prior to the children. I think this is even the case (order of the client sync state) even if new ids are not generated for the scene as the CreateEntity is emitted first for the parent, but I didnt check.

@jonnenauha jonnenauha added the Bug label Sep 8, 2014
@jonnenauha
Copy link
Member Author

From the IRC discussions it seems the best approach would be to take a copy of the client sync states dirty entity queue, sort it so that parents are before children and then run the same loop that currently sends the messages with that sorted list.

jonnenauha added a commit to Adminotech/tundra that referenced this issue Sep 9, 2014
…ke sure that parents are sent before children. This is crucial in keeping Entity parenting working during runtime when smaller id Entities are parented to bigger ids. Changed SceneSyncState to be a associative QHash that maps entities to EntitySyncState*, this makes for fast lookups when parents are needed inside the processing. Added EntitySyncState::weak to the Entity, we can get rid of scene queries being done all the time (I did not fully utilize this yet, should be added to be used in more of the SyncManager functions). Fixes realXtend#775.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant