fix: use TIME_FUDGE_FACTOR rather than rounding by decimal digits #881
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
Currently we ran into an issue with
roundSignificantDigit
because it is rounding integer whole numbers when it seems like it was only made to round floats. This can cause us to download multiple duplicate segments on slow connections. Instead I propose that we only round byTIME_FUDGE_FACTOR
here. This will prevent us from having to do any rounding at all.Why the current solution is bad:
Rounding a value of
2.111111
to2.111112
is less than 1 milliseconds a very small change but rounding from2.1
to2.2
is 100ms. Both are possible with the current code.New solution
All numbers are rounded up or down by 33 milliseconds
Possible Solutions:
TIME_FUDGE_FACTOR
for all numbers, but round less for longer floats. Not sure this one really makes sense as longer floats are not necessarily more accurate.