[Engineering] fix: profiler result page never clamped below 1 - #3405
Merged
Merged
Conversation
On the first frames after profiling is enabled there are no results yet, so numberOfPages is 0 - and CurrentResultPage, clamped with Math.Min against it, dropped to 0 and stayed there. The profiler then showed page 0 of N over an empty list once results arrived. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> (cherry picked from commit dd27c24)
3 tasks
Ethereal77
reviewed
Sep 8, 2026
| var elementsPerPage = (int)Math.Floor(availableDisplayHeight / TextRowHeight); | ||
| numberOfPages = (uint)Math.Ceiling(profilingResults.Count / (float)elementsPerPage); | ||
| CurrentResultPage = Math.Min(CurrentResultPage, numberOfPages); | ||
| CurrentResultPage = Math.Max(1, Math.Min(CurrentResultPage, numberOfPages)); |
Contributor
There was a problem hiding this comment.
Better to use this.
Or, even better this, which is the Microsoft's recommended way now.
int.Clamp(value, 1, numberOfPages)
Contributor
Author
There was a problem hiding this comment.
Done: uint.Clamp(CurrentResultPage, 1, Math.Max(1, numberOfPages)). The upper bound is kept at 1 or more because numberOfPages is 0 until the first results arrive, and Clamp throws when max < min.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
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.
PR Details
Split out of #3388 as requested in review.
GameProfilingSystemclampsCurrentResultPageagainst the page count. On the first frames after profiling is enabled there are no results yet, so the page count is 0 and the page is clamped to 0, where it stays: once results arrive the profiler shows "PAGE 0 OF N" over an empty list. The clamp now never goes below page 1.Verified with the in-game profiler (F2 / P in the VoxelGI demo): the first page shows its results right after enabling.
Related Issue
None filed; small enough to be its own fix.
Types of changes
Checklist