fix(gsplat): free SOG bundle archive memory after texture upload#8972
Merged
Conversation
The embedded texture assets created by SogBundleParser retain `file.contents`, which are views into the downloaded zip archive ArrayBuffer. Null them once the textures are decoded and uploaded, so the whole archive can be garbage collected. The decoded ImageBitmap kept by each texture (for re-upload on device context loss) is a separate copy and is unaffected. Relates to #8080. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Build size reportThis PR changes the size of the minified bundles.
|
mvaligursky
added a commit
that referenced
this pull request
Jun 26, 2026
The embedded texture assets created by SogBundleParser retain `file.contents`, which are views into the downloaded zip archive ArrayBuffer. Null them once the textures are decoded and uploaded, so the whole archive can be garbage collected. The decoded ImageBitmap kept by each texture (for re-upload on device context loss) is a separate copy and is unaffected. Relates to #8080. Co-authored-by: Martin Valigursky <mvaligursky@snapchat.com> Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
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
SogBundleParserkeeps the downloaded.sogzip archiveArrayBufferalive after parsing: each embedded textureAssetis created withcontents: file.data, and for stored (non-deflate) entriesfile.datais aUint8Arrayview into the archive buffer. As long as those assets retainfile.contents, the whole archive cannot be garbage collected — duplicating the CPU footprint of the splat.This nulls each embedded texture asset's
file.contentsonce the textures have been decoded and uploaded (await Promise.allSettled(promises)), letting the archive buffer be freed.The decoded source kept by each texture (for re-upload on device context loss) is standard engine behaviour for all textures and is intentionally left untouched, so context restore is unaffected.
Fixes #8080.
Testing
Verified on the
shadow-softexample (bicycle.sog, 14.8 MB archive):file.contentsacross the 7 embedded textures.