Star Citizen: Bugsmashers! - Tick Rate Madness
Transcript — every row opens the video at that moment
- 00:00:16
Hey everyone, welcome to Bug Smashers. I'm your host Mark A Bent. Let's get started. Bug Smashers! Hey everyone, we are here in the PU map. I know you guys like my fun fancy dancy test level, but unfortunately that level won't do for this bug. Um I am here in my Gladius and we have a fun bug where if the server and the client FPS degrade too far from each other as in the server goes too low and the client goes too high because well, we've been doing amazing optimizations for the client. Uh there could be a chance that when you try to take off, you kind of sputter a bit and then you go up. So we're going to try to see if we could replicate that issue by basically telling the server to always run at 5 FPS because I'm well, a
- 00:01:06
monster. So, server's running at 5 FPS. I'm running at about 30. I am now going to try to replicate that bug by turning on my magical flight ready. Shazam. Now I have control of my ship and I'm going to take off. And as you can see, I really can't take off. I am sputtering and snapping every which way. So if we put a breakpoint in the code in this fun little bit, uh I'm going to put it right here. This is basically the IFCS or flight control or basically the ship networking system. Um the server player is basically the server representation as you can see my dedicated server representation of the the ship. I also have a client version of this and this class basically shares
- 00:01:56
information to and from each other. So, the server knows what the client's trying to do and the client's knowing what the server's trying to do. And in this situation, we have the case where the server um is trying to process some of the packets from the client, but it can't because the client has this tick rate of 4,000. And the last received tick rate it got is over 5,000. And so, it never processes the client state. Um this gets a little bit funky because what's happening is when I first get into the ship, the server controls pretty much the whole system. And then when I do flight ready, I have told the server that I am ready to take control of this. So, now I am the local client. I would like to tell
- 00:02:43
the server what I would like to do for the ship. Move to left, move to the right, move all the way up and down. And the client will basically be the authority of the ship, and the server could at times be like, "No, I don't like what you're doing." And snap to this state. And when we do this weird transition period, the server is trying to snap the client. However, during this odd period, because the server is at 5 FPS, it's running updates a little bit slower than the client. So, the client is way up here. The client's uh the server's still catching up. So, when we switch authorities, the server uh the client switch it basically snaps to the server state. And then that gives the client the tick rate of 4,000. However, the server, last time it heard from the client was at
- 00:03:31
5,000. So, it got into this weird situation where when we are exchanging authorities and capturing ticks, uh the server gets borked because we had snapped to the client state. But the last time it heard about the client was when it was in control. So, it gets this weird little uh basically we're screwed. Um the client tick will have to eventually get to 5,000 before I'm able to take off. And this is a huge problem because well, I don't got a minutes to wait all day. And in fact, if you were to just wait inside of the the cockpit for a good 10 minutes and then turn it on, you got to wait about 10 minutes before you could take off. Not fun. So, what we want to do
- 00:04:18
is uh change this bit so that if the server has informed us that we need to snap we're just going to do the snap. Um the server when we do that transition, the server wants to snap the client to the correct state so that they become aligned and their tick rates match. And that didn't happen. So, we're going to change some of the codes to make sure that this does happen. And in this block, this is the server representation, so we need to make sure that um the client is responding to the server snap. So, we're going to say client response to server snap. We're going to ask the server the client what where is it? What tick he expected it to
- 00:05:09
be. Should be actually, let's go into Here we are. Da da da da I'm going to rewind a bit. So, when the server wants to snap the client it basically sets this bool to true indicating that we are waiting for the client to re-process this. And it does this weird trick with this tick rate where it sets the current tick and then negative one when it gets to it's weird, so we're just going to make it always send the force tick rate. That way we could check um so it it did this weird thing where if we set to -1, we don't want it to do a snap, but if we have it not -1, we want it to do a snap. When really
- 00:05:57
instead it should just be the tick rate last time we have done a snap. And if that doesn't match, we just should snap to the state that the server told us to. So we're always just going to send the last time the server did the snap so that the client can know that it needs to do a change. So now that we did this bit, we need to change up um we're going to change up the client bit saying hey let's see. The server is telling us that we need to snap. So let's see. Server said to snap crackle pop. So let's let's do it. And what we got to do So we get the server state and check against do
- 00:06:47
our representation of when the server told us to last snap. Pop pop. So if our last time we heard from the server to snap is different than what the server told us to snap, we're going to snap. Crackle pop. So if our tick rates are different or we're snapping, we're just going to process the snap on the client. So on the server client process it, we are just going to go yep, this is a snap. Is this a snap? Uh yes, this is a snap because our rates are different. So here um since we have processed do do
- 00:07:35
do, we have determined that we're snapping. We also need to realize that we are snapping in this bit. We're going to always update to the latest tick rate that the server told us to snap to. Then we're going to process the snap as if we're going to snap. The snap basically teleports us to where the server has set us. All right. Now let's follow the trail. So, client gets the server snap, snaps. Uh da da da. The Now the server This is the client's response saying I have snapped at this tick. If that matches what the server expected and the server is waiting for a
- 00:08:29
a snap response, we are going to process the client and continue down into here and go, "Yep, we're done." So, server sends out the snap, sends out what tick rate it sent the snap at, the client gets it, goes, "Oh, that's different. Uh this is a response, so I need to snap to the server state." Tells the server that I have snapped. The server gets it and goes, "Yes, you have." And then processes it as it should. So, let's recode this magic and see what happens. So, recode is finished. We are back in our ship. And let's see if we can take off. Success. We can take off. There's a little fun little jitter on the UI, but I'm able to get up and go just as I please. So, look like we fixed it. So, hope you
- 00:09:17
guys enjoyed network shenanigans. As we make the game faster, we're uncovering some fun fun problems. Hope you guys enjoyed. Till next time. So, as you guys saw, we had a fun little bug where the server and client are vastly different FPSs at times, which shouldn't happen, but under certain circumstances it does. And since we vastly improved the client FPS rating when these two get so far out of sync, the tick rates on them goes completely out of sync and one's more ahead of the other, and that caused some fun stuff in the IFCS networking. Now, we fixed that up so that anytime the server needs to snap the client, we just do it and then we're good to go. Hope you guys enjoyed. Till next time. Thanks for watching. For the latest and
- 00:10:14
greatest in Star Citizen and Squadron 42, you can subscribe to our channel or you can check out some of the other shows, and you can also head to our website at www.robertsspaceindustries.com. Thank you very much for watching.
Transcript from YouTube’s automatic captions — punctuation and Star Citizen jargon are approximate. The video itself is hosted by CIG on the official channel.

