Skip to content

Commit

Permalink
Fix Safari reporting wrong initial track resolution (#898)
Browse files Browse the repository at this point in the history
* Fix Safari reporting wrong initial track resolution

* Create late-starfishes-rush.md

* move into localTrack

* make the fix iOS specific
  • Loading branch information
lukasIO committed Oct 23, 2023
1 parent 3ed61a8 commit 40ccf2a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/late-starfishes-rush.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"livekit-client": patch
---

Fix Safari reporting wrong initial track resolution
6 changes: 6 additions & 0 deletions src/room/track/LocalTrack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

5 comments on commit 40ccf2a

@orangepeelbeef
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are you sure this is only a safari issue? I have noticed this in my console logs for a while and i'm on windows

image

@lukasIO
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@orangepeelbeef that would indicate a different error, are you publishing directly from a device or from a canvas?

@orangepeelbeef
Copy link

@orangepeelbeef orangepeelbeef commented on 40ccf2a Oct 26, 2023 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lukasIO
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that sounds like a likely culprit. Would be great if you could open an issue with some repro steps if you continue to see that error with nvidia broadcast.

@orangepeelbeef
Copy link

@orangepeelbeef orangepeelbeef commented on 40ccf2a Oct 27, 2023 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.