Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handling many participant joins #170

Merged
merged 5 commits into from
Oct 4, 2023
Merged

Handling many participant joins #170

merged 5 commits into from
Oct 4, 2023

Conversation

martinmitrevski
Copy link
Collaborator

🔗 Issue Links

Provide all JIRA tickets and/or GitHub issues related to this PR, if applicable.

🎯 Goal

Describe why we are making this change.

📝 Summary

Provide bullet points with the most important changes in the codebase.

🛠 Implementation

Provide a detailed description of the implementation and explain your decisions if you find them relevant.

🎨 Showcase

Add relevant screenshots and/or videos/gifs to easily see what this PR changes, if applicable.

Before After
img img

🧪 Manual Testing Notes

Explain how this change can be tested manually, if applicable.

☑️ Contributor Checklist

  • I have signed the Stream CLA (required)
  • This change follows zero ⚠️ policy (required)
  • This change should receive manual QA
  • Changelog is updated with client-facing changes
  • New code is covered by unit tests
  • Comparison screenshots added for visual changes
  • Affected documentation updated (Docusaurus, tutorial, CMS)

🎁 Meme

Provide a funny gif or image that relates to your work on this pull request. (Optional)

@martinmitrevski martinmitrevski requested a review from a team as a code owner September 29, 2023 13:25
@github-actions
Copy link

1 Warning
⚠️ Please be sure to complete the Contributor Checklist in the Pull Request description

Generated by 🚫 Danger

if count < 16 {
return 0
} else if count < 50 {
return 250_000_000
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: WDYT about making those configurable via a config? Or at least move them as constants somewhere more prominent as here they feel like magic numbers

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

we shouldn't have them configurable, this is an internal thing. Moving them to constants makes sense, will do that.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

@@ -105,6 +105,8 @@ public class VideoRenderer: RTCMTLVideoView {
self.track?.trackId
}

private var viewSize: CGSize?
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
private var viewSize: CGSize?
private var trackSize: CGSize = .zero
private lazy var scale: CGFloat = UIScreen.main.scale

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It's actually the view size, not the track size, so the naming is correct. Good point about the scale, will move it here.
Btw, should be optional, because we have a default track size - we should change it only when we know the view size.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

Comment on lines 125 to 133
public override func layoutSubviews() {
super.layoutSubviews()
let scale = UIScreen.main.scale
self.viewSize = CGSize(
width: self.bounds.size.width * scale,
height: self.bounds.size.height * scale
)
}

Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
public override func layoutSubviews() {
super.layoutSubviews()
let scale = UIScreen.main.scale
self.viewSize = CGSize(
width: self.bounds.size.width * scale,
height: self.bounds.size.height * scale
)
}
public override func layoutSubviews() {
super.layoutSubviews()
trackSize = CGSize(
width: self.bounds.size.width * scale,
height: self.bounds.size.height * scale
)
}

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

Comment on lines +188 to +189
if let viewSize, prev != viewSize {
onTrackSizeUpdate(viewSize, participant)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
if let viewSize, prev != viewSize {
onTrackSizeUpdate(viewSize, participant)
if let trackSize, prev != viewSize {
onTrackSizeUpdate(trackSize, participant)

@@ -171,15 +182,11 @@ extension VideoRenderer {
if let track = participant.track {
log.debug("adding track to a view \(self)")
self.add(track: track)
DispatchQueue.main.asyncAfter(deadline: .now() + 0.01) {
DispatchQueue.global(qos: .userInteractive).asyncAfter(deadline: .now() + 0.01) { [weak self] in
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why not update async without a delay?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I can't remember now, but there were issues when it was done straight away. Should've put a comment back then. 😞

@@ -586,6 +586,10 @@ open class CallViewModel: ObservableObject {
}
}
} else if let participantEvent = callEventsHandler.checkForParticipantEvents(from: event) {
guard participants.count < 25 else {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Are we completely skipping them? Would that have any unwanted effects on UI? (e.g. participants list count not updating)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

For now yes, because it is actually not usable nor correct. We need to re-think this (sth like "User and 10 more joined"), but not for the scope of this PR.

@sonarqubecloud
Copy link

sonarqubecloud bot commented Oct 4, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 2 Code Smells

73.7% 73.7% Coverage
0.0% 0.0% Duplication

@martinmitrevski martinmitrevski merged commit 8f2ffb6 into main Oct 4, 2023
11 of 13 checks passed
@martinmitrevski martinmitrevski deleted the benchmarking branch October 4, 2023 14:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants