ureishi / QvPen

VRChat World Pen.
64 stars 12 forks source link

VRChat freezing and crashing when too many people join at once #17

Closed iffn closed 1 year ago

iffn commented 1 year ago

There seems to be an issue with QvPen that causes VRChat to freeze and crash within a few seconds of joining the world when too many people enter at once. For example, during the community meetup, 80 people can join a world at once.

I assume this is caused by these lines in the OnPlayerJoined function which calls a network event whenever a person joins the instance. https://github.com/ureishi/QvPen/blob/352081d75d0fb87617b9481cc6741b6062714c55/Assets/QvPen/Runtime/UdonScript/QvPen_LateSync.cs#L26-L27

OnPlayerJoined not only gets called for the people already in the instance when someone joins, but the person joining gets a call for each player already in the instance plus one for themselves.

As far as I understand, when player 70 joins for example, the 68 non owners already in the world will send the event to the owner. Also, the person joining will send 70 events to the owner.

So 80 people joining at once should send Sum(n=2...80)[n-2 + n] = 6320 network events within a few seconds. This will likely break something.

The effect can be seen here: https://www.youtube.com/watch?v=VRqSuXP7fxg&t=4830s

ShingenPizza commented 1 year ago

Just wanted to add that the above calculations are understated. The 6320 events are just the signals to the master to start syncing, which are likely followed by the same number of actual synchronizations. Even more importantly, each of this pair of events happens per pen.

So with a regular set of 15 pens, when 80 people join, thats even 189600 networking events.