Skip to content

Consider to disable Three.js Cache #4258

Description

@takahirox

Is your feature request related to a problem? Please describe.

We Hubs (more precisely underlying A-Frame) enables Three.js Cache which saves the file contents downloaded with Three.js loaders in JavaScript level in heap memory.

But I think browser also saves the cache and it should work fine. So JavaScript level cache may be useless.

And JavaScript level cache unnecessarily wastes heap memory. File contents cache can be one of the huge memory consumption in Hubs Client.

I tried to measure the benefit of disabling the Three.js Cache with a very easy way.

  1. On the local Hubs server, I joined a room with "Moz Atrium" scene.
  2. Take heap memory snapshot on Windows10 Chrome
  3. Run THREE.Cache.clear() on the web console (thanks for global THREE)
  4. Take heap memory snapshot again

Result:
Before clearing Three.js Cache: 117.0MB
After clearing Three.js Cache: 75.3MB

I cut off 35% heap memory consumption by just clearing the Cache. The effect would be greater if a lot of medias, objects, and avatars are placed especially in a longer event where people tend to be place (and remove) a lot of objects over time.

Describe the solution you'd like

Disable Three.js Cache. It is disabled by default in Three.js so it can be done by removing THREE.Cache.enabled = true line from A-Frame code.

Describe alternatives you've considered

If we want to enable Three.js Cache for certain reasons, we should remove the file contents which unlikely be used again from Cache by THREE.Cache.remove(url).

Additional context

There may be some codes in A-Frame which expects and relies on that Three.js Cache is enabled. Just in case we should carefully check and review such codes. (But we may not need to be worried about it since we use very little of the built in stuff now.)

I'm thinking of starting to work on this after #4198 is merged.

Metadata

Metadata

Assignees

Labels

enhancementwork that enhances an existing feature

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions