Fix: Handle edge case where intervalSum is zero during quick recordings - #192
Merged
Conversation
binarykitchen
force-pushed
the
fix/avgfps-undefined-error
branch
from
August 18, 2026 08:17
ca77763 to
31c806a
Compare
- Replace truthy/falsy check with explicit validation in getAvgInterval() - Replace truthy/falsy check with explicit validation in getAvgFps() - Issue: JavaScript treats 0 as falsy, causing avgFps to become undefined - Impact: Prevents 'Average FPS cannot be undefined' error on poster generation - Root cause: Very quick recordings may have intervalSum = 0, triggering falsy check The fix ensures avgFps calculation works correctly for all recording durations, even extremely brief recordings where elapsed time is 0.
binarykitchen
force-pushed
the
fix/avgfps-undefined-error
branch
from
August 18, 2026 08:28
31c806a to
893152d
Compare
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.
Description
This PR fixes an edge case in the avgFps calculation that was causing an error when processing very quick video recordings.
Root Cause
The
getAvgFps()andgetAvgInterval()methods used a falsy check (if (!intervalSum)) to validate the elapsed time. This incorrectly treats0as an invalid value, even though zero milliseconds is a valid elapsed time for extremely brief recordings.JavaScript truthy/falsy issue:
if (!0)evaluates to true (0 is falsy)if (!intervalSum)returns undefined when intervalSum = 0Impact
This caused the following error in the server during poster generation:
Affected recordings: Very quick recordings where the elapsed time rounds to 0ms
Solution
Replaced falsy checks with explicit validation:
undefined,null, or values<= 0Testing
The fix handles all these scenarios:
Files Changed
src/wrappers/visuals/recorder.tsgetAvgInterval()validationgetAvgFps()validation