refactor: move per-frame stats collection from AppBase to ApplicationStats#8643
Merged
willeastcott merged 1 commit intoApr 23, 2026
Merged
Conversation
…Stats Relocates the two private `_fillFrameStatsBasic` and `_fillFrameStats` methods (~100 lines) from `AppBase` onto `ApplicationStats` as `updateBasic()` and `updateDetailed()`. `AppBase.tick` now calls `this.stats.updateBasic(...)` / `this.stats.updateDetailed(...)` and passes the renderer and graphics device as explicit dependencies. Pure internal refactor - no public API changes, no behaviour changes. The stats object shape (`app.stats.frame.*`, `app.stats.drawCalls.*`, etc.) is unchanged, so external consumers such as `mini-stats` continue to work as-is. Made-with: Cursor
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors per-frame stats collection by moving the basic and profiler-only detailed update logic out of AppBase and into ApplicationStats, aligning the update logic with the counters it populates and reducing responsibilities in app-base.js.
Changes:
- Added
ApplicationStats.updateBasic()andApplicationStats.updateDetailed()(both@ignore) to encapsulate per-frame stats population and counter resets. - Updated
AppBase.tickto call the new stats update methods and passrenderer/graphicsDeviceas explicit dependencies. - Moved primitive-constants imports (
PRIMITIVE_TRIANGLES/TRIFAN/TRISTRIP) fromapp-base.jstostats.js.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/framework/stats.js | Adds per-frame stats update methods and relocates the detailed primitive/counter logic into ApplicationStats. |
| src/framework/app-base.js | Replaces internal private stats methods with calls into ApplicationStats, removing duplicated logic and imports. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Relocates the two private per-frame stats collection methods from
AppBaseontoApplicationStats, where the counters they populate already live. This is the first of several small, targeted refactors to break upapp-base.js(currently ~2k lines, mixing ~10 distinct responsibilities)._fillFrameStatsBasicand_fillFrameStats(~100 lines) out ofsrc/framework/app-base.jsand intosrc/framework/stats.jsasApplicationStats.updateBasic()andApplicationStats.updateDetailed().AppBase.ticknow callsthis.stats.updateBasic(currentTime, dt, ms, this.renderer, this.graphicsDevice)andthis.stats.updateDetailed(this.renderer, this.graphicsDevice), passing the renderer and graphics device as explicit dependencies rather than the callees reaching back throughthis.PRIMITIVE_TRIANGLES/PRIMITIVE_TRIFAN/PRIMITIVE_TRISTRIPimports move tostats.jsalong with the detailed update body.Public API
No changes. The stats object shape (
app.stats.frame.*,app.stats.drawCalls.*,app.stats.particles.*,app.stats.misc.*) is identical. External consumers such asmini-statscontinue to work without modification. Both new methods are marked@ignore, matching the visibility of the originals.File size impact
src/framework/app-base.js: 2086 -> 1986 lines (-100)src/framework/stats.js: 133 -> 244 lines (+111)Test plan
npm run lint- clean (0 errors, 1 unrelated pre-existing warning inutils/rollup-build-target.mjs)npm run build:types- types regenerate without errorsnpm run test:types- passesnpm test- 1652 passing, 0 failing (2 pre-existing pending)mini-statsexample in a local build to confirm frame stats still populate correctly