From 40ccf2aff79553485e6a808b2a3fa49f18d8c3ee Mon Sep 17 00:00:00 2001 From: lukasIO Date: Mon, 23 Oct 2023 19:37:09 +0200 Subject: [PATCH] Fix Safari reporting wrong initial track resolution (#898) * Fix Safari reporting wrong initial track resolution * Create late-starfishes-rush.md * move into localTrack * make the fix iOS specific --- .changeset/late-starfishes-rush.md | 5 +++++ src/room/track/LocalTrack.ts | 6 ++++++ 2 files changed, 11 insertions(+) create mode 100644 .changeset/late-starfishes-rush.md diff --git a/.changeset/late-starfishes-rush.md b/.changeset/late-starfishes-rush.md new file mode 100644 index 0000000000..9c4822fdf2 --- /dev/null +++ b/.changeset/late-starfishes-rush.md @@ -0,0 +1,5 @@ +--- +"livekit-client": patch +--- + +Fix Safari reporting wrong initial track resolution diff --git a/src/room/track/LocalTrack.ts b/src/room/track/LocalTrack.ts index c1b0d5585a..fbc09bc447 100644 --- a/src/room/track/LocalTrack.ts +++ b/src/room/track/LocalTrack.ts @@ -163,6 +163,12 @@ export default abstract class LocalTrack extends Track { throw new Error('cannot get dimensions for audio tracks'); } + if (getBrowser()?.os === 'iOS') { + // browsers report wrong initial resolution on iOS. + // when slightly delaying the call to .getSettings(), the correct resolution is being reported + await sleep(10); + } + const started = Date.now(); while (Date.now() - started < timeout) { const dims = this.dimensions;