Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ package io.getstream.video.android.core

import android.app.Notification
import android.os.Bundle
import android.util.Log
import androidx.compose.runtime.Stable
import androidx.core.app.NotificationManagerCompat
import io.getstream.android.video.generated.models.BlockedUserEvent
Expand Down Expand Up @@ -724,6 +723,7 @@ public class CallState(
internal var jetpackTelecomRepository: JetpackTelecomRepository? = null

internal var incomingNotificationData = IncomingNotificationData(emptyMap())
private val ringingLogger by taggedLogger("RingingState")

fun handleEvent(event: VideoEvent) {
logger.d { "[handleEvent] ${event::class.java.name.split(".").last()}" }
Expand Down Expand Up @@ -834,10 +834,11 @@ public class CallState(
}

is CallEndedEvent -> {
call.state.cancelTimeout()
cancelTimeout()
updateFromResponse(event.call)
_endedAt.value = OffsetDateTime.now(Clock.systemUTC())
_endedByUser.value = event.user?.toUser()
updateRingingState()
call.leave("CallEndedEvent")
}

Expand Down Expand Up @@ -1256,8 +1257,9 @@ public class CallState(
val userIsParticipant =
_session.value?.participants?.find { it.user.id == client.userId } != null
val outgoingMembersCount = _members.value.filter { it.value.user.id != client.userId }.size
val isCallEnded: Boolean = _endedAt.value != null
Copy link
Contributor

@aleksandar-apostolov aleksandar-apostolov Feb 23, 2026

Choose a reason for hiding this comment

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

taggedLogger is a delegate — creating it inside updateRingingState() means a new instance allocates on every call. This method runs frequently (every state change, every event). Should be class-level: private val ringingLogger by taggedLogger("RingingState")

Same issue flagged on #1617

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Correct


Log.d("RingingState", "Current: ${_ringingState.value}, call_id: ${call.cid}")
ringingLogger.d { "Current: ${_ringingState.value}, call_id: ${call.cid}" }

val ringingStateLogs = arrayListOf(
("acceptedByMe: $isAcceptedByMe"),
Expand All @@ -1266,17 +1268,18 @@ public class CallState(
("hasActiveCall: $hasActiveCall"),
("hasRingingCall: $hasRingingCall"),
("userIsParticipant: $userIsParticipant"),
("isCallEnded: $isCallEnded"),
).joinToString("") { it + "\n" }

Log.d(
"RingingState",
"call_id: ${call.cid}, Flags: $ringingStateLogs",
)
ringingLogger.d { "call_id: ${call.cid}, Flags: $ringingStateLogs" }

// no members - call is empty, we can join
val state: RingingState = if (hasActiveCall && !ringingStateUpdatesStopped) {
cancelTimeout()
RingingState.Active
} else if (hasRingingCall && isCallEnded) {
cancelTimeout()
RingingState.RejectedByAll
} else if (isRejectedByMe) {
call.leave("updateRingingState-rejected-self")
cancelTimeout()
Expand All @@ -1303,7 +1306,7 @@ public class CallState(
}
} else if (hasRingingCall && createdBy?.id == client.userId) {
// The call is created by us
logger.d { "acceptedBy: $acceptedBy, userIsParticipant: $userIsParticipant" }
ringingLogger.d { "acceptedBy: $acceptedBy, userIsParticipant: $userIsParticipant" }
if (acceptedBy.isEmpty()) {
// no one accepted the call
RingingState.Outgoing(acceptedByCallee = false)
Expand All @@ -1325,7 +1328,7 @@ public class CallState(
}

if (_ringingState.value != state) {
logger.d { "Updating ringing state ${_ringingState.value} -> $state" }
ringingLogger.d { "Updating ringing state ${_ringingState.value} -> $state" }

// handle the auto-cancel for outgoing ringing calls
if (state is RingingState.Outgoing && !state.acceptedByCallee) {
Expand All @@ -1338,7 +1341,7 @@ public class CallState(

// stop the call ringing timer if it's running
}
Log.d("RingingState", "Update: $state")
ringingLogger.d { "Update: $state" }

_ringingState.value = state
}
Expand Down
Loading