Skip to content

Commit de39881

Browse files
Merge pull request #1859 from GetStream/chore/and-1607-ring-poll-start-after-9s
Start ring state polling after 9s instead of 15s
2 parents 2cee1c8 + 0a40ba6 commit de39881

2 files changed

Lines changed: 25 additions & 23 deletions

File tree

‎stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/ringing/RingStatePollingConfig.kt‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,10 @@ package io.getstream.video.android.core.ringing
2323
* must be usable, and a non-positive one is rejected rather than quietly disabling the fallback.
2424
*
2525
* @param startAfterMs how long a ring must go without a participant's ring status changing before
26-
* polling begins. Kept well above the coordinator's websocket ping interval so a merely slow
27-
* answer does not poll.
26+
* polling begins. This is the trade the whole fallback turns on: a shorter quiet period recovers a
27+
* dropped outcome sooner, and also makes rings whose callee is merely slow to answer pay for a read
28+
* they did not need. The default is tuned for the first, because a caller stuck on a ringing screen
29+
* is a visible failure and an extra read is not.
2830
* @param intervalMs the gap between reads once polling has begun. Measured from the end of one
2931
* read to the start of the next, so a slow read widens the gap rather than being absorbed by it.
3032
*/
@@ -40,7 +42,7 @@ public data class RingStatePollingConfig(
4042
}
4143

4244
public companion object {
43-
public const val DEFAULT_START_AFTER_MS: Long = 15_000
45+
public const val DEFAULT_START_AFTER_MS: Long = 9_000
4446
public const val DEFAULT_INTERVAL_MS: Long = 5_000
4547

4648
/**

‎stream-video-android-core/src/test/kotlin/io/getstream/video/android/core/ringing/RingStatePollerTest.kt‎

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ class RingStatePollerTest {
6767
})
6868

6969
poller.start({ sessionId }, { ringTimeout })
70-
advanceTimeBy(14_999)
70+
advanceTimeBy(8_999)
7171

7272
assertThat(reads).isEqualTo(0)
7373
poller.stop()
@@ -82,7 +82,7 @@ class RingStatePollerTest {
8282
})
8383

8484
poller.start({ sessionId }, { ringTimeout })
85-
advanceTimeBy(15_001)
85+
advanceTimeBy(9_001)
8686
assertThat(reads).isEqualTo(1)
8787

8888
advanceTimeBy(5_000)
@@ -100,15 +100,15 @@ class RingStatePollerTest {
100100
})
101101

102102
poller.start({ sessionId }, { ringTimeout })
103-
advanceTimeBy(10_000)
103+
advanceTimeBy(5_000)
104104

105105
// A rejection from one callee does not settle a group ring, so the poller stays armed —
106106
// but the socket just proved it is alive, so the wait starts over.
107107
poller.onRingParticipantStatusUpdate()
108-
advanceTimeBy(10_000)
108+
advanceTimeBy(5_000)
109109
assertThat(reads).isEqualTo(0)
110110

111-
advanceTimeBy(5_001)
111+
advanceTimeBy(4_001)
112112
assertThat(reads).isEqualTo(1)
113113

114114
poller.stop()
@@ -125,9 +125,9 @@ class RingStatePollerTest {
125125
poller.start({ sessionId }, { ringTimeout })
126126
advanceTimeBy(60_000)
127127

128-
// 15s quiet period, then reads at 20/25/30s — the read that would land past the
128+
// 9s quiet period, then reads at 9/14/19/24/29s — the read that would land past the
129129
// deadline is not issued.
130-
assertThat(reads).isEqualTo(3)
130+
assertThat(reads).isEqualTo(5)
131131
poller.stop()
132132
}
133133

@@ -144,7 +144,7 @@ class RingStatePollerTest {
144144
poller.start({ sessionId }, { ringTimeout })
145145
advanceTimeBy(25_001)
146146

147-
assertThat(reads).isEqualTo(3)
147+
assertThat(reads).isEqualTo(4)
148148
poller.stop()
149149
}
150150

@@ -157,7 +157,7 @@ class RingStatePollerTest {
157157
})
158158

159159
poller.start({ sessionId }, { ringTimeout })
160-
advanceTimeBy(15_001)
160+
advanceTimeBy(9_001)
161161
assertThat(reads).isEqualTo(1)
162162

163163
poller.stop()
@@ -207,8 +207,8 @@ class RingStatePollerTest {
207207
poller.start({ sessionId }, { 600_000L })
208208
advanceTimeBy(600_000)
209209

210-
// 60s ceiling: quiet period to 15s, then reads at 20..55s.
211-
assertThat(reads).isEqualTo(9)
210+
// 60s ceiling: quiet period to 9s, then reads at 9..59s.
211+
assertThat(reads).isEqualTo(11)
212212
poller.stop()
213213
}
214214

@@ -228,8 +228,8 @@ class RingStatePollerTest {
228228
poller.start({ sessionId }, { ringTimeout })
229229
advanceTimeBy(600_000)
230230

231-
// 30s window: quiet period to 15s, then reads at 15, 20 and 25s, and no further.
232-
assertThat(reads).isEqualTo(3)
231+
// 30s window: quiet period to 9s, then reads at 9, 14, 19, 24 and 29s, and no further.
232+
assertThat(reads).isEqualTo(5)
233233
poller.stop()
234234
}
235235

@@ -256,7 +256,7 @@ class RingStatePollerTest {
256256
advanceTimeBy(600_000)
257257

258258
// The reads of one loop over a 30s window, not two loops interleaved.
259-
assertThat(reads).isEqualTo(3)
259+
assertThat(reads).isEqualTo(5)
260260
poller.stop()
261261
}
262262

@@ -272,7 +272,7 @@ class RingStatePollerTest {
272272
poller.start({ sessionId }, { 0L })
273273
advanceTimeBy(600_000)
274274

275-
assertThat(reads).isEqualTo(3)
275+
assertThat(reads).isEqualTo(5)
276276
poller.stop()
277277
}
278278

@@ -287,8 +287,8 @@ class RingStatePollerTest {
287287
poller.start({ sessionId }, { null })
288288
advanceTimeBy(600_000)
289289

290-
// 30s default, not the 60s ceiling: quiet period to 15s, then reads at 15, 20 and 25s.
291-
assertThat(reads).isEqualTo(3)
290+
// 30s default, not the 60s ceiling: quiet period to 9s, then reads at 9 through 29s.
291+
assertThat(reads).isEqualTo(5)
292292
poller.stop()
293293
}
294294

@@ -325,8 +325,8 @@ class RingStatePollerTest {
325325
},
326326
)
327327

328-
// A longer window than the default: this exercises three polls, which does not fit in one
329-
// 30s ring.
328+
// A longer window than the default, so the reads this walks through are not also being
329+
// bounded by the ring deadline.
330330
poller.start({ current }, { 60_000L })
331331
advanceTimeBy(20_001)
332332
assertThat(seen).isEmpty()
@@ -350,7 +350,7 @@ class RingStatePollerTest {
350350
poller.start({ sessionId }, { ringTimeout })
351351
advanceTimeBy(20_001)
352352

353-
assertThat(seen).hasSize(2)
353+
assertThat(seen).hasSize(3)
354354
assertThat(seen.first().sessionId).isEqualTo(sessionId)
355355
poller.stop()
356356
}

0 commit comments

Comments
 (0)