I found a behaviour regarding the ServerTickIndex handling which seems like a bug to me in Netcode for Entities which I want to report here. It happens when stepping frame by frame with the Unity Editor in a ServerWorld. This is the setup:
- ServerWorld with no clients connected
- Entered PlayMode in Unity Editor and paused the game, progressing the game only with the Step-Button right besides the Pause-Button
- ClientServerTickRate.MaxSimulationStepBatchSize has to be 2 or greater
- ClientServerTickRate.MaxSimulationStepsPerFrame is 1
- ClientServerTickRate.NetworkTickRate and SimulationTickRate is 60
- ClientServerTickRate.TargetFrameRateMode is Auto
What I experience is that some ServerTickIndices get skipped while some ServerTickIndices gets processed twice. So it look like this:
- Correctly processing ServerTickIndex 749 with a SimulationStepBatchSize of 1
- In the next frame ServerTickIndex 751 is stated with a SimulationStepBatchSize of 2. The PredictionLoop gets executed two times in this frame one-time having ServerTickIndex 751 and one-time with 752. Outside of the PredictionLoop NetworkTime states the 751 and BatchSize of 2 and is executed one time.
- In the next frame ServerTickIndex 752 with SimulationStepBatchSize of 1 is reported. The PredcitonLoop runs one-time with stated ServerTickIndex and also outside of the loop the NetworkTime is supplied and executed one time.
So the stated ServerTickIndices are the following in this small example: 749, 751, 752, 752. While ServerTickIndex 750 is fully missing in the execution, ServerTickIndex 752 is processed two times. This behevior seems fully wrong and leads to issues for ServerTickIndex based logic. In my project some logic may be repreatedly executed, because based on certain ServerTickIndices.
I also attached a few screenshots to show the NetworkTime flow in the debugger. All Systems in the screenshots are part of the SimulationSystemGroup, one inside and one outside of the PredictionLoop. I had to merge some screenshots cause of forum restrictions. 01_02 showing ServerTickIndex 749. In 03, 04 and 05 the situation with the batch of 751 and 752 is shown. And 06_07 shows the double execution of ServerTickIndex 752.
The issue is reproducable with Unity 2022.3.19 and Netcode 1.0.17 as well as Unity 2022.3.26 with Netcode 1.2.0. The bug does NOT occur when progressing the game normally in the Game view without pausing and stepping. It also does NOT occur when MaxSimulationStepBatchSize is 1. But the latter is not an option for me, because I use an increased Time.timeScale for debugging purpose (fast-forwarding the game) and this works best with a higher MaxSimulationStepBatchSize which I configured to 16 in my project.