Fix delayed heartbeat and host stats sending every frame#70
Closed
andy013 wants to merge 4 commits intoFacepunch:masterfrom
Closed
Fix delayed heartbeat and host stats sending every frame#70andy013 wants to merge 4 commits intoFacepunch:masterfrom
andy013 wants to merge 4 commits intoFacepunch:masterfrom
Conversation
Contributor
|
This PR has been merged upstream. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix delayed heartbeat and host stats sending every frame
This PR finishes up #709
Changes
Notes
Currently the heartbeat is sent after the frame has rendered but it uses the
Time.Nowvalue from the previous frame. This means if the frame takes a long time to render the heartbeat will be incorrect and cause unnecessary timing fluctuations on the client.I tested this and this is what happens to
Time.Nowon the client after a 2 second delay on the server:With this fix the time keeps on running like it should and the client doesn't run any extra fixed updates when the server has a large frametime spike.
I also moved
SendHostStats()toNetworking.PreFrameTick()because it usesTime.Nowfrom the previous frame too. There is no good reason to delay sending it until after the current frame has rendered. It doesn't matter much for host stats but this is more correct.Comments
I feel like
Networking.PostFrameTick()could be removed entirely. It now only has a call toSendTableUpdates()which is currently being called 3 times per frame in these places:Networking.PreFrameTick()GameInstanceDll.FinishLoadingAssemblies()Networking.PostFrameTick()I did a quick test and I only ever saw
PreFrameTick()actually sending any changes. I haven't tested it extensively though and I don't feel confident enough to removePostFrameTick()without breaking anything. I don't think it's a big deal to call it too many times but it just clutters up the code if it's not needed.