-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix animation timing issues. Reduce heap allocations when loading GFX #306
Merged
Conversation
This file contains 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
- Main character moving/attacking more slowly than vanilla client - Other characters moving more slowly than vanilla client, causing weird walk glitches when their walk ended - Main character timestamps not having high enough resolution - Main character timestamps not being sent at consistent enough intervals
…s that need to be collected by GC
…number of garbage collection events.
…ting textures instead of parsing through SixLabors.ImageSharp Reduces number of transient heap-allocated objects that need to be garbage collected. Reduces data copies and external dependencies.
…the pixel below the mouse cursor.
…s from consuming too much memory.
…on timing issues and makes behavior more consistent with vanilla client
Bug was introduced in commit 2ceeff5
Use single Delay method in TrainerBot Use 10ms target update time in EndlessGame
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.
This change includes timing updates as well as performance updates to reduce the number of garbage collections happening in the background.
Timing Updates
Completely reworked my timing system to be tick-based like the vanilla client.
Timestamp measurements:
Approach:
System.Diagnostics.Stopwatch
and use monogame's frame updateGameTime
for all animation timingUpdate()
call, increment a globalTick
Tick
value when an animation startsTick
difference when updating animation framesTick
since they're updated every 10msThe end result is that there's a single place where animation timings are tracked. The behavior is now significantly more consistent and closer to vanilla.
Fixes #299
Memory usage updates
Updated PELoaderLib to use
Span<T>
andMemory<T>
to load data, and removedImageSharp
as a dependency in the texture loading pipeline. This reduces the number of intermediate heap allocations and data copies when converting a texture from a PE resource to aTexture2D
. This relies on some unsafe code and pointer arithmetic for high performance and reduced memory footprintAdditionally, found a couple memory hotspots where lots of allocations were happening:
Draw
call inStatusBarLabel
GetData
in eachUpdate
callStatusBarLabel
texture is now just loaded once, and NPCs now use an LRU caching mechanism to store the pixel data of the underlying textures. This has an increased memory footprint, but reduces the number ofGetData
calls needed, which reduces the number of heap allocations and eventual garbage collections.This partially addresses #230 but more work still needs to be done