fps-counter affect FPS
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 35/100
- Issue type
- Bug
- Clarity
- Needs clarification
- Activity status
- Stale
- Tech stack
- javascript
- Domain
- performance
Research direction
Start at the fps-counter component and inspect how it uses the stats component, setTimeout, and DOM text each tick. Compare its behavior with the alternative implementation in the issue; done should address the reported per-tick DOM access, parsing, formatting, and allocation concerns while preserving FPS display.
Written by the indexing model from the issue text.
Description
Hi there.
Thanks for all your wonderful work contributing to A-Frame!
I'm a little concerned about the fps-counter component. Such a component needs to be very sensitive to FPS, both measuring and impacting, and I'm not sure the component is 'careful' enough with regard to DOM access and garbage collection.
Specifically:
- it creates a new anonymous function (to pass to setTimeout) every tick
- it accesses the DOM (.innerHTML) every tick
- it parses floats from text every tick
- it formats floats (.toFixed) every tick
- it requires the stats component (and keeps parsing its DOM)
I'm not good enough at A-Frame to know if this is a big deal, but it seemed to be a problem for me. I ended up writing my own version of fps-counter:
AFRAME.registerComponent( 'fps-counter', {
init() {
this.el.setAttribute( 'text', { align: 'center', side: 'double', color: 'white' } );
this.ticksSinceLastInterval = 0;
setInterval( () => {
this.ticksToDisplay = this.ticksSinceLastInterval.toString();
this.ticksSinceLastInterval = 0;
}, 1000 );
},
tick() {
this.ticksSinceLastInterval++;
if ( this.ticksToDisplay !== undefined ) {
this.el.setAttribute( 'text', 'value', this.ticksToDisplay );
this.ticksToDisplay = undefined;
}
}
} );
- Dominant language
- JavaScript
- Stars
- 1.4k
- Forks
- 425
- PR merge metrics
- No merged PRs in 30d
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from supermedium/superframe
-
Difficulty 1/5 Under an hour Newbie friendliness 72/100
supermedium/superframe#241 ·
-
text-geometry update Open
Difficulty 3/5 1-2 days Newbie friendliness 58/100
supermedium/superframe#352 · 3 comments ·
-
Difficulty 3/5 1-2 days Newbie friendliness 35/100
supermedium/superframe#349 · 1 comment ·
-
Difficulty 3/5 1-2 days Newbie friendliness 35/100
supermedium/superframe#348 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 45/100
supermedium/superframe#347 ·
All issues in supermedium/superframe
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
HarperFast/skills#96 ·
-
[Block] Latest Posts [Type] Bug
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Automattic/studio#4908 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
sugarlabs/musicblocks#8847 ·