TimeSync fails due to Assert
I am missing NetworkTime ever since pulling the latest from the develop branch. I see now that there is a LocalTime and ServerTime property, as well as a NetworkTime and NetworkTick system. Which is the best to use for a simple, synchronized game clock? I feel there should be some more documentation on this and NetworkStart() for people not willing to crawl through commits, such as a BreakingChanges.md file or the like.
I assume I found the best equivalent for a synchronized clock: NetworkManager.ServerTime.Time[AsFloat]
However, I'm now getting KeyNotFoundExceptions from the Ruffies transport. [Edit: see below, this error is much more serious than I initially thought, and not limited to any specific transport.]
FWIW, I switched to Unet transport, and now I'm getting a failure here:
public void HandleTimeSync(ulong clientId, Stream stream)
{
Assert.IsTrue(clientId == NetworkManager.ServerClientId);
using (var reader = PooledNetworkReader.Get(stream))
{
int tick = reader.ReadInt32Packed();
var time = new NetworkTime(NetworkManager.NetworkTickSystem.TickRate, tick);
NetworkManager.NetworkTimeSystem.Sync(time.Time, NetworkManager.NetworkConfig.NetworkTransport.GetCurrentRtt(clientId) / 1000d);
}
}
It is asserting on the client. Even after removing ServerTime references, it's constantly spitting out the assertion. "TimeSync threw an exception" -- is this something that passed QC? Or have I messed up configuration somewhere? This seems entirely unrelated to Unet or transports in general.
Edit: yes, this is definitely a problem. I understand the need to refactor so early on, but this one line (Asset.IsTrue) has completely brickwalled my project. I'm resetting --hard to 9ae52deb53 in order to get my project running again, until I can get support on this TimeSync exception. I appreciate all of your hard work, but I hope to see less of these major refactoring until transports are being actively maintained, enough people are using MLAPI to be well-tested, and documentation is being updated.
The equivalent of NetworkManager.NetworkTime is now NetworkManager.LocalTime.TimeAsFloat.
Thanks for reporting the assert issue. We've already encountered that internally. It looks like it's likely that the UNet transport has a severe issue here which we need to resolve. @NoelStephensUnity already made some discoveries around this and I'll look into it as well today.
Please keep the following in mind when using the develop branch:
- This is not a release branch. Do not expect documentation yet for all features we add to this branch.
- Develop is where we do development. While we try to keep it in a functioning state things like this can slip through. For some reasons our unit tests did not capture this which is concerning so I'll look into that.
Sorry again for the inconveniences you encountered.
I removed the assert from develop so this should no longer happen.
Closing this as the issue has been resolved.