Frame rate detection on MotionMark occasionally sees older devices as… #51
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.
Frame rate detection on MotionMark occasionally sees older devices as 90 fps instead of 60
#50
To get the target frame rate we sample 300 rAFs and we get the average of their frame rates. We calculate the average incrementally using some sort of exponential decay. The average starts very small but keeps increasing until it reaches the actual target frame rate and it is supposed to stay unchanged much. Then we compare the final average rate with predefined frame rates and get the closest one.
The purpose of this incremental calculation was to show the target frame rate being calculated in the detectionProgressElement in the developer page.
In addition to having the incremental average very small for more than 100 frames, the bigger problem is this incremental average calculation gives more weight to the last frame. And if it is considerably large for any reason, the final average will be wildly inaccurate.
The fix is to simplify the calculations:
For count == 0: The firstTimeStamp will be recorded and and we won't update the detectionProgressElement.
For count > 0: averageFrameLength = (timestamp - firstTimeStamp) / count; averageFrameRate = 1000 / averageFrameLength;