Skip to content

Commit

Permalink
Remove debug info (#1181)
Browse files Browse the repository at this point in the history
* Remove `DebugInfo` class

* Spotless and ApiDump
  • Loading branch information
aleksandar-apostolov authored Sep 19, 2024
1 parent 7080ea2 commit 18c5057
Show file tree
Hide file tree
Showing 6 changed files with 4 additions and 254 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -295,8 +295,6 @@ class AndroidDeviceTest : IntegrationTestBase(connectCoordinatorWS = false) {

delay(1000)

clientImpl.debugInfo.log()

// leave and cleanup the joining call
call.leave()
call.cleanup()
Expand Down Expand Up @@ -471,7 +469,6 @@ class AndroidDeviceTest : IntegrationTestBase(connectCoordinatorWS = false) {

// log debug info
logger.d { networkOut.toString() }
clientImpl.debugInfo.log()

// leave and clean up a call
call.leave()
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -380,14 +380,12 @@ public class Call(
}

// step 1. call the join endpoint to get a list of SFUs
val timer = clientImpl.debugInfo.trackTime("call.join")

val locationResult = clientImpl.getCachedLocation()
if (locationResult !is Success) {
return locationResult as Failure
}
location = locationResult.value
timer.split("location found")

val options = createOptions
?: if (create) {
Expand All @@ -403,7 +401,6 @@ public class Call(
val sfuToken = result.value.credentials.token
val sfuUrl = clientImpl.testSfuAddress ?: result.value.credentials.server.url
val iceServers = result.value.credentials.iceServers.map { it.toIceServer() }
timer.split("join request completed")

session = if (testInstanceProvider.rtcSessionCreator != null) {
testInstanceProvider.rtcSessionCreator!!.invoke()
Expand All @@ -425,21 +422,18 @@ public class Call(
session?.let {
state._connection.value = RealtimeConnection.Joined(it)
}
timer.split("rtc session init")

try {
session?.connect()
} catch (e: Exception) {
return Failure(Error.GenericError(e.message ?: "RtcSession error occurred."))
} finally {
timer.split("rtc connect completed")
}

scope.launch {
// wait for the first stream to be added
session?.let { rtcSession ->
val mainRtcSession = rtcSession.lastVideoStreamAdded.filter { it != null }.first()
timer.finish("stream added, rtc completed, ready to display video $mainRtcSession")
logger.d { "stream added, rtc completed, ready to display video $mainRtcSession" }
}
}

Expand All @@ -458,8 +452,6 @@ public class Call(
}
}

timer.finish()

return Success(value = session!!)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ import io.getstream.video.android.core.socket.ErrorResponse
import io.getstream.video.android.core.socket.PersistentSocket
import io.getstream.video.android.core.socket.SocketState
import io.getstream.video.android.core.sounds.Sounds
import io.getstream.video.android.core.utils.DebugInfo
import io.getstream.video.android.core.utils.LatencyResult
import io.getstream.video.android.core.utils.getLatencyMeasurementsOKHttp
import io.getstream.video.android.core.utils.safeCall
Expand Down Expand Up @@ -175,8 +174,6 @@ internal class StreamVideoImpl internal constructor(
CoroutineScope(_scope.coroutineContext + SupervisorJob() + coroutineExceptionHandler)

/** if true we fail fast on errors instead of logging them */
var developmentMode = true
val debugInfo = DebugInfo(this)

/** session id is generated client side */
public val sessionId = UUID.randomUUID().toString()
Expand All @@ -201,7 +198,6 @@ internal class StreamVideoImpl internal constructor(
override fun cleanup() {
// remove all cached calls
calls.clear()
debugInfo.stop()
// stop all running coroutines
scope.cancel()
// stop the socket
Expand Down Expand Up @@ -411,8 +407,6 @@ internal class StreamVideoImpl internal constructor(
}
}
}

debugInfo.start()
}

var location: String? = null
Expand Down Expand Up @@ -456,10 +450,10 @@ internal class StreamVideoImpl internal constructor(
// wait for the guest user setup if we're using guest users
guestUserJob?.await()
try {
val timer = debugInfo.trackTime("coordinator connect")
val startTime = System.currentTimeMillis()
socketImpl.connect()
timer.finish()
Success(timer.duration)
val duration = System.currentTimeMillis() - startTime
Success(duration)
} catch (e: ErrorResponse) {
if (e.code == VideoErrorCode.TOKEN_EXPIRED.code) {
refreshToken(e)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -380,9 +380,6 @@ public class RtcSession internal constructor(
errorJob = coroutineScope.launch {
sfuConnectionModule.sfuSocket.errors.collect {
logger.e(it) { "permanent failure on socket connection" }
if (clientImpl.developmentMode) {
throw it
}
}
}
}
Expand Down Expand Up @@ -422,10 +419,7 @@ public class RtcSession internal constructor(
}

suspend fun connect() {
val timer = clientImpl.debugInfo.trackTime("sfu ws")
sfuConnectionModule.sfuSocket.connect()
timer.finish()

// ensure that the join event has been handled before starting RTC
try {
withTimeout(2000L) {
Expand Down Expand Up @@ -605,7 +599,6 @@ public class RtcSession internal constructor(

private suspend fun connectRtc() {
val settings = call.state.settings.value
val timer = clientImpl.debugInfo.trackTime("connectRtc")

// turn of the speaker if needed
if (settings?.audio?.speakerDefaultOn == false) {
Expand All @@ -620,14 +613,12 @@ public class RtcSession internal constructor(

if (canPublish) {
publisher = createPublisher()
timer.split("createPublisher")
} else {
// enable the publisher if you receive the send audio or send video capability
coroutineScope.launch {
call.state.ownCapabilities.collect {
if (it.any { it == OwnCapability.SendAudio || it == OwnCapability.SendVideo }) {
publisher = createPublisher()
timer.split("createPublisher")
}
}
}
Expand All @@ -653,7 +644,6 @@ public class RtcSession internal constructor(
// step 2 ensure all tracks are setup correctly
// start capturing the video

timer.split("media enabled")
// step 4 add the audio track to the publisher
setLocalTrack(
TrackType.TRACK_TYPE_AUDIO,
Expand Down Expand Up @@ -687,7 +677,6 @@ public class RtcSession internal constructor(
}

// step 6 - onNegotiationNeeded will trigger and complete the setup using SetPublisherRequest
timer.finish()
listenToMediaChanges()

// subscribe to the tracks of other participants
Expand Down Expand Up @@ -1735,7 +1724,6 @@ public class RtcSession internal constructor(
failedToSwitch: () -> Unit,
) {
logger.i { "[switchSfu] from ${this.sfuUrl} to $sfuUrl" }
val timer = clientImpl.debugInfo.trackTime("call.switchSfu")

// Prepare SDP
val getSdp = suspend {
Expand Down Expand Up @@ -1767,7 +1755,6 @@ public class RtcSession internal constructor(
when (it) {
is SocketState.Connected -> {
logger.d { "[switchSfu] Migration SFU socket state changed to Connected" }
timer.split("SFU socket connected")

// Disconnect the old SFU and stop listening to SFU stateflows
eventJob?.cancel()
Expand Down Expand Up @@ -1807,15 +1794,13 @@ public class RtcSession internal constructor(
subscriber?.state?.collect {
if (it == PeerConnectionState.CONNECTED) {
logger.d { "[switchSfu] Migration subscriber state changed to Connected" }
timer.split("Subscriber connected")
tempSubscriber?.let { tempSubscriberValue ->
tempSubscriberValue.connection.close()
tempSubscriber = null
}

onMigrationCompleted.invoke()

timer.finish()
cancel()
} else if (it == PeerConnectionState.CLOSED ||
it == PeerConnectionState.DISCONNECTED ||
Expand Down
Loading

0 comments on commit 18c5057

Please sign in to comment.