-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Disable AudioBasedLatency on non-Android-Chrome platforms (#1009)
- Loading branch information
1 parent
416b178
commit d33f3db
Showing
2 changed files
with
28 additions
and
7 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,22 @@ | ||
export default function getAudioContextBaseLatency(): number | undefined { | ||
if (!window.AudioContext) { | ||
return undefined | ||
import { isAndroid, isWebKit } from '../utils/browser' | ||
|
||
export const enum SpecialFingerprint { | ||
/** The browser doesn't support AudioContext or baseLatency */ | ||
NotSupported = -1, | ||
/** Entropy source is disabled because of console warnings */ | ||
Disabled = -2, | ||
} | ||
|
||
export default function getAudioContextBaseLatency(): number { | ||
// The signal emits warning in Chrome and Firefox, therefore it is enabled on Safari where it doesn't produce warning | ||
// and on Android where it's less visible | ||
const isAllowedPlatform = isAndroid() || isWebKit() | ||
if (!isAllowedPlatform) { | ||
return SpecialFingerprint.Disabled | ||
} | ||
|
||
return new AudioContext().baseLatency | ||
if (!window.AudioContext) { | ||
return SpecialFingerprint.NotSupported | ||
} | ||
return new AudioContext().baseLatency ?? SpecialFingerprint.NotSupported | ||
} |