Bug 1446346 Do not clamp or jitter the AudioContext's CurrentTime if its interval is larger than our precision. r=jib

MozReview-Commit-ID: Bc1cto3pBKL

--HG--
extra : rebase_source : ace58df9f1669beacc176ab968f45a09ca44be2e
This commit is contained in:
Tom Ritter 2018-04-17 15:35:51 -05:00
Родитель 7d52995eaf
Коммит 3705fef918
4 изменённых файлов: 24 добавлений и 7 удалений

Просмотреть файл

@ -175,6 +175,16 @@ https://trac.torproject.org/projects/tor/ticket/1517
// and check if it is rounded
for (let timeStampCode of timeStampCodesDOM) {
let timeStamp = eval(timeStampCode);
// Audio Contexts increment in intervals of (minimum) 5.4ms, so we don't
// clamp/jitter if the timer precision is les than that.
// (Technically on MBPs they increment in intervals of 2.6 but this is
// non-standard and will eventually be changed. We don't cover this situation
// because we don't really support arbitrary Timer Precision, especially in
// the 2.6 - 5.4ms interval.)
if (timeStampCode.includes("audioContext") && expectedPrecision < 5.4)
continue;
ok(isRounded(timeStamp, expectedPrecision),
"pref: " + prefname + " - '" +
"'" + timeStampCode +

Просмотреть файл

@ -668,17 +668,22 @@ AudioContext::CurrentTime()
{
MediaStream* stream = Destination()->Stream();
if (!mIsStarted &&
stream->StreamTimeToSeconds(stream->GetCurrentTime()) == 0) {
return 0;
double rawTime = stream->StreamTimeToSeconds(stream->GetCurrentTime());
// CurrentTime increments in intervals of 128/sampleRate. If the Timer
// Precision Reduction is smaller than this interval, the jittered time
// can always be reversed to the raw step of the interval. In that case
// we can simply return the un-reduced time; and avoid breaking tests.
// We have to convert each variable into a common magnitude, we choose ms.
if ((128/mSampleRate) * 1000.0 > nsRFPService::TimerResolution() / 1000.0) {
return rawTime;
}
// The value of a MediaStream's CurrentTime will always advance forward; it will never
// reset (even if one rewinds a video.) Therefore we can use a single Random Seed
// initialized at the same time as the object.
return nsRFPService::ReduceTimePrecisionAsSecs(
stream->StreamTimeToSeconds(stream->GetCurrentTime()),
GetRandomTimelineSeed());
rawTime, GetRandomTimelineSeed());
}
void AudioContext::DisconnectFromOwner()

Просмотреть файл

@ -107,8 +107,9 @@ nsRFPService::GetOrCreate()
return sRFPService;
}
inline double
TimerResolution()
/* static */
double
nsRFPService::TimerResolution()
{
if(nsRFPService::IsResistFingerprintingEnabled()) {
return max(100000.0, (double)sResolutionUSec);

Просмотреть файл

@ -162,6 +162,7 @@ public:
static nsRFPService* GetOrCreate();
static bool IsResistFingerprintingEnabled();
static bool IsTimerPrecisionReductionEnabled(TimerPrecisionType aType);
static double TimerResolution();
enum TimeScale {
Seconds = 1,