aframevr / aframevr/aframe

option/API to automatically force preload all material uploads to GPU

Open
#3,135 4 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

perf
Dominant language
JavaScript
Stars
17.6k
Forks
4.4k
PR merge metrics
No merged PRs in 30d

Description

Description:

A-Frame/three.js gets serious framedrops whenever we display or load a material for the first time. Even if an entity has a material instantiated, if the entity or its parent is non-visible, the renderer will hang if you flip them to visible. It seems the three.js WebGL renderer does not upload non-visible object's materials.

What we want is a way to preload all the materials up front on scene load so that the user does not experience frame drops during the experience. We can do this by flashing/drawing the materials on initialization, and then removing them. Currently, the base material component reuses all common materials in the material system, we can create a single three.js Object3D, and cycle through all of them to get them all pre-uploaded.

For the API, perhaps we can have a disablePreloadGPU property on the material that can opt-out of this. But what about the case of materials not created from the base material GPU? We could also have a public method, perhaps on the material system, that does this like el.systems.material.forceUpload(threejsmaterial).

Reproduce: https://aframe-360-gallery.glitch.me

Open Firefox Performance Tools, start recording, swap back and forth between images, frame drops when image is first loaded, smooth on second load.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the first-load frame drops at https://aframe-360-gallery.glitch.me using Firefox Performance Tools, then inspect the base material component and material system described in the issue. Done should mean materials can be preloaded before they become visible, avoiding the initial frame drop while supporting an opt-out or public upload path for other materials.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, three.js
Domain
frontend, performance
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.