Add opt-in compact storage for Animate timelines - #57
Open
Tutez64 wants to merge 1 commit into
Open
Conversation
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 PR adds an opt-in
swf_compact_animate_timelinesdefine that storesAnimate timeline events in compact numeric buffers instead of eagerly creating
an object graph containing one
AnimateFrame,AnimateFrameObject, andoptional matrix, color-transform, filter, and array objects per serialized
event.
The compact representation:
Vector<Float>;Matrixobjects;The legacy representation remains the default.
This is opt-in because code that accesses
AnimateSpriteSymbol.framesdirectlywill not receive the eagerly expanded legacy metadata.
Motivation
The expanded timeline metadata remains reachable for the lifetime of an
Animate library. Large libraries can therefore retain hundreds of thousands of
small managed objects, increasing both heap usage and the amount of graph
traversal performed by full garbage collections.
Deterministic benchmark
SWFAnimateTimelineMemoryRepro.zip
It parses and retains 400 sprites containing 300 frames and
eight events per frame, for a total of 960,000 timeline events.
Three alternating runs on Linux x86_64 with Haxe 4.3.6 produced:
The retained heap decreased by 57%. The benchmark intentionally amplifies
timeline metadata costs; application results depend on the amount and
complexity of loaded animation data.
Real-world validation
These values should be considered indicative rather than a controlled benchmark:
At a comparable heap census, the compact run contained approximately 4,171
AnimateTimelineDataobjects instead of 40,949AnimateFrameand 63,076AnimateFrameObjectobjects. RetainedMatrixinstances decreased from138,766 to 78,802.
Tests
swf_compact_animate_timelines.color transforms, filters, names, visibility, and frame labels.
Integration notes for pending PRs
This branch is intentionally based directly on
upstream/masterand does not include other pending changes. Depending on merge order, the following adaptations must be preserved when resolving conflicts:__removedChildCleanupDelaytoMath.POSITIVE_INFINITYwhen created.__markTimelineMask. This can be handled in the shared instance-arrangement path.clipDepthin its compatibility check.reset-dependent filter clearing behavior when merging the shared display-object update code.compactTimeline.objects, since the legacyframesarray is intentionally left empty.These integrations are already implemented and tested together on the downstream master branch; they are omitted here only to keep this PR independent and reviewable.
Note: until 159db83 from #55 is merged, the Haxe 3 CI jobs may still fail earlier in AnimateTimeline.hx, independently of this PR.