google / google/model-viewer

How to properly clear or reset <model-viewer> variants to avoid memory issues on mobile?

Open
#5,060 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
8.2k
Forks
947
PR merge metrics
No merged PRs in 30d

Description

Hi team,

I'm experiencing a memory-related issue when working with on mobile devices. After switching between variants (e.g., using the variantName attribute), the memory usage increases significantly. Eventually, it seems like variant data is being cached or retained, causing performance degradation and even crashes on lower-end devices.

This typically happens when:

I load only a single GLB file into instance using the src attribute.

I use KHR_materials_variants.

After switching between variants several times, performance becomes noticeably worse on mobile and website crashes.

Question:
Is there a proper way to:

Clear out or "reset" the variants metadata and internal references when switching models?

Any suggestions or recommended practices for this scenario would be greatly appreciated.

Thanks in advance for your support and awesome work on this project!

Example:

https://onsite-scripter.holostep.io/serve/embedded.html?accountId=45&sceneId=685faac1d90bf1877c600951

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.