Reduce Animate shape command memory usage - #55
Open
Tutez64 wants to merge 2 commits into
Open
Conversation
Contributor
Author
|
The new Animate shape test caused AnimateTimeline to be compiled on Haxe 3.4.7, exposing a pre-existing parser incompatibility in a combined conditional expression. The condition has been split into nested directives in both the Animate and SWFLite timeline implementations. |
This was referenced Jul 26, 2026
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.
Summary
This changes how Animate shape commands are stored at runtime:
allocating one
AnimateShapeCommandenum object per drawing command;Graphicswhen a shape is firstinstantiated;
commandspath for manually constructedAnimateShapeSymbolinstances;representation.
Motivation
Animate exports already represent shape commands as flat JSON command streams.
AnimateLibrarycurrently expands every stream while loading into enum objects,matrices and nested arrays, even for shapes that are never instantiated.
Large Animate libraries can therefore retain hundreds of thousands of managed
objects. Besides the additional memory usage, these objects increase the live
graph that hxcpp must traverse during garbage collection, resulting in longer
GC stalls as more assets are loaded.
The new representation keeps the command stream compact and delays graphics
creation until the shape is actually used.
Benchmark
SWFAnimateShapeCommandMemoryRepro.zip
It parses and retains 1,000 unrendered shapes containing
1,050 commands each.
Results on Linux x86_64 with Haxe 4.3.6 and
HXCPP_GC_BIG_BLOCKS:masterReal-world validation
AnimateShapeCommandinstancesThese values should be considered indicative rather than a controlled benchmark.
However, the complete removal of roughly 759,000 surviving command objects,
together with consistently shorter marking and GC pauses, confirms that the
improvement also applies under a real game workload.
The patched run completed normally with no visible shape rendering regression.
Related change
This PR has a small textual overlap with #54, which adds
lineGradientStylesupport. The changes are functionally independent, but bothmodify
AnimateLibrary.hxandAnimateShapeSymbol.hx.Once either PR is merged, I can rebase the other one. The combined resolution
handles
LINE_GRADIENT_STYLEthrough the same compact gradient command path andcalls
Graphics.lineGradientStylewhile rendering. This combined version hasalready been tested downstream.