Skip to content

Conversation

@fimbox
Copy link
Contributor

@fimbox fimbox commented Oct 1, 2025

Description

When a SOG asset is destroyed, GSplatSogsData.destroy() calls .destroy() directly on the texture resources. This fails to remove the parent Asset from the AssetRegistry cache.

Fixes #
Modify GSplatSogsData.destroy() to call asset.unload() on the texture Asset objects instead of destroying the resources directly.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Fixes a memory leak in SOG asset destruction by ensuring texture assets are properly removed from the AssetRegistry cache when GSplatSogsData is destroyed.

  • Modified GSplatSogsData to accept and store texture asset references during construction
  • Updated the destruction logic to call asset.unload() instead of directly destroying texture resources
  • Updated both SogsParser and SogBundleParser to pass texture assets to GSplatSogsData constructor

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
src/scene/gsplat/gsplat-sogs-data.js Added textureAssets property and constructor, modified _destroyGpuResources to unload assets properly
src/framework/parsers/sogs.js Updated GSplatSogsData instantiation to pass textureAssets parameter
src/framework/parsers/sog-bundle.js Updated GSplatSogsData instantiation to pass texture assets from bundle

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

this.sh_centroids?.destroy();
this.sh_labels?.destroy();

if(this.textureAssets)
Copy link

Copilot AI Oct 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Missing space after 'if' keyword. Should be 'if (this.textureAssets)' to follow JavaScript formatting conventions.

Suggested change
if(this.textureAssets)
if (this.textureAssets)

Copilot uses AI. Check for mistakes.
@slimbuck
Copy link
Member

slimbuck commented Oct 8, 2025

I think we only need orderTexture.destroy() which was already added in #8016?

@slimbuck
Copy link
Member

slimbuck commented Oct 8, 2025

Thanks so much for this PR @fimbox!!

I've implemented the same functionality in a (hopefully) slightly cleaner way in #8037.

It wouldn't have happened without your contribution though - thanks again!

@slimbuck slimbuck closed this Oct 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants