From 485bec5d5dbf9bffaedc4fb69df24c36dab4d63e Mon Sep 17 00:00:00 2001 From: Evgeny Date: Wed, 30 Sep 2026 09:18:26 +0100 Subject: [PATCH] android, desktop: reduce logging (#7618) Co-authored-by: Evgeny @ SimpleX Chat <259188159+evgeny-simplex@users.noreply.github.com> --- .../simplex/common/views/call/CallView.android.kt | 6 +++--- .../kotlin/chat/simplex/common/model/SimpleXAPI.kt | 13 ++++++------- .../chat/simplex/common/views/call/CallManager.kt | 3 +-- .../kotlin/chat/simplex/common/views/call/WebRTC.kt | 8 ++++---- .../simplex/common/views/call/CallView.desktop.kt | 6 +++--- apps/multiplatform/product/glossary.md | 2 +- 6 files changed, 18 insertions(+), 20 deletions(-) diff --git a/apps/multiplatform/common/src/androidMain/kotlin/chat/simplex/common/views/call/CallView.android.kt b/apps/multiplatform/common/src/androidMain/kotlin/chat/simplex/common/views/call/CallView.android.kt index 011619bab0..9ad787a6b1 100644 --- a/apps/multiplatform/common/src/androidMain/kotlin/chat/simplex/common/views/call/CallView.android.kt +++ b/apps/multiplatform/common/src/androidMain/kotlin/chat/simplex/common/views/call/CallView.android.kt @@ -132,7 +132,7 @@ actual fun ActiveCallView() { } Box(Modifier.fillMaxSize()) { WebRTCView(chatModel.callCommand) { apiMsg -> - Log.d(TAG, "received from WebRTCView: $apiMsg") + Log.d(TAG, "received from WebRTCView: ${apiMsg.resp.javaClass.simpleName}") val call = chatModel.activeCall.value if (call != null) { val callState = call.androidCallState as ActiveCallState @@ -711,7 +711,7 @@ fun WebRTCView(callCommand: SnapshotStateList, onResponse: (WVAPIM .collect { while (callCommand.isNotEmpty()) { val cmd = callCommand.removeFirstOrNull() - Log.d(TAG, "WebRTCView LaunchedEffect executing $cmd") + Log.d(TAG, "WebRTCView LaunchedEffect executing ${cmd?.javaClass?.simpleName}") if (cmd != null) { processCommand(wv, cmd) } @@ -785,7 +785,7 @@ class WebRTCInterface(private val onResponse: (WVAPIMessage) -> Unit) { // onResponse(message) onResponse(json.decodeFromString(message)) } catch (e: Exception) { - Log.e(TAG, "failed parsing WebView message: $message") + Log.e(TAG, "failed parsing WebView message") } } } diff --git a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/model/SimpleXAPI.kt b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/model/SimpleXAPI.kt index 9100b5ecea..97e1f025f3 100644 --- a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/model/SimpleXAPI.kt +++ b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/model/SimpleXAPI.kt @@ -941,7 +941,7 @@ object ChatController { val r = json.decodeFromString(rStr) if (log) { Log.d(TAG, "sendCmd response type ${r.responseType}") - if (r is API.Result && (r.res is CR.Response || r.res is CR.Invalid)) { + if (r is API.Result && ((r.res is CR.Response && !r.res.type.startsWith("call")) || r.res is CR.Invalid)) { Log.d(TAG, "sendCmd response json $rStr") } chatModel.addTerminalItem(TerminalItem.resp(rhId, r)) @@ -958,7 +958,7 @@ object ChatController { } else { val r = json.decodeFromString(rStr) Log.d(TAG, "chatRecvMsg: ${r.responseType}") - if (r is API.Result && (r.res is CR.Response || r.res is CR.Invalid)) Log.d(TAG, "chatRecvMsg json: $rStr") + if (r is API.Result && ((r.res is CR.Response && !r.res.type.startsWith("call")) || r.res is CR.Invalid)) Log.d(TAG, "chatRecvMsg json: $rStr") r } } @@ -3367,10 +3367,9 @@ object ChatController { // TODO askConfirmation? // TODO check encryption is compatible withCall(r, r.contact) { call -> - chatModel.activeCall.value = call.copy(callState = CallState.OfferReceived, sharedKey = r.sharedKey) + chatModel.activeCall.value = call.copy(callState = CallState.OfferReceived, hasSharedKey = r.sharedKey != null) val useRelay = appPrefs.webrtcPolicyRelay.get() val iceServers = getIceServers() - Log.d(TAG, ".callOffer iceServers $iceServers") chatModel.callCommand.add(WCallCommand.Offer( offer = r.offer.rtcSession, iceCandidates = r.offer.rtcIceCandidates, @@ -7215,9 +7214,9 @@ sealed class CR { is SndStandaloneFileComplete -> withUser(user, rcvURIs.size.toString()) is SndFileError -> withUser(user, "errorMessage: ${json.encodeToString(errorMessage)}\nchatItem: ${json.encodeToString(chatItem_)}") is SndFileWarning -> withUser(user, "errorMessage: ${json.encodeToString(errorMessage)}\nchatItem: ${json.encodeToString(chatItem_)}") - is CallInvitations -> "callInvitations: ${json.encodeToString(callInvitations)}" - is CallInvitation -> "contact: ${callInvitation.contact.id}\ncallType: $callInvitation.callType\nsharedKey: ${callInvitation.sharedKey ?: ""}" - is CallOffer -> withUser(user, "contact: ${contact.id}\ncallType: $callType\nsharedKey: ${sharedKey ?: ""}\naskConfirmation: $askConfirmation\noffer: ${json.encodeToString(offer)}") + is CallInvitations -> "callInvitations: ${json.encodeToString(callInvitations.map { it.copy(sharedKey = null) })}" + is CallInvitation -> "contact: ${callInvitation.contact.id}\ncallType: ${callInvitation.callType}" + is CallOffer -> withUser(user, "contact: ${contact.id}\ncallType: $callType\naskConfirmation: $askConfirmation\noffer: ${json.encodeToString(offer)}") is CallAnswer -> withUser(user, "contact: ${contact.id}\nanswer: ${json.encodeToString(answer)}") is CallExtraInfo -> withUser(user, "contact: ${contact.id}\nextraInfo: ${json.encodeToString(extraInfo)}") is CallEnded -> withUser(user, "contact: ${contact.id}") diff --git a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/call/CallManager.kt b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/call/CallManager.kt index d6ab57a70d..d95c4846dc 100644 --- a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/call/CallManager.kt +++ b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/call/CallManager.kt @@ -51,13 +51,12 @@ class CallManager(val chatModel: ChatModel) { callUUID = invitation.callUUID, callState = CallState.InvitationAccepted, initialCallType = invitation.callType.media, - sharedKey = invitation.sharedKey, + hasSharedKey = invitation.sharedKey != null, androidCallState = platform.androidCreateActiveCallState() ) showCallView.value = true val useRelay = controller.appPrefs.webrtcPolicyRelay.get() val iceServers = getIceServers() - Log.d(TAG, "answerIncomingCall iceServers: $iceServers") callCommand.add(WCallCommand.Start( media = invitation.callType.media, aesKey = invitation.sharedKey, diff --git a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/call/WebRTC.kt b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/call/WebRTC.kt index 6fa99283d8..6cd0ba95ba 100644 --- a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/call/WebRTC.kt +++ b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/call/WebRTC.kt @@ -21,7 +21,7 @@ data class Call( val localMediaSources: CallMediaSources = CallMediaSources(mic = true, camera = initialCallType == CallMediaType.Video), val localCapabilities: CallCapabilities? = null, val peerMediaSources: CallMediaSources = CallMediaSources(), - val sharedKey: String? = null, + val hasSharedKey: Boolean = false, var localCamera: VideoCamera = VideoCamera.User, val connectionInfo: ConnectionInfo? = null, var connectedAt: Instant? = null, @@ -32,14 +32,14 @@ data class Call( val androidCallState: Closeable ) { - val encrypted: Boolean get() = localEncrypted && sharedKey != null + val encrypted: Boolean get() = localEncrypted && hasSharedKey private val localEncrypted: Boolean get() = localCapabilities?.encryption ?: false val encryptionStatus: String get() = when(callState) { CallState.WaitCapabilities -> "" CallState.InvitationSent -> generalGetString(if (localEncrypted) MR.strings.status_e2e_encrypted else MR.strings.status_no_e2e_encryption) - CallState.InvitationAccepted -> generalGetString(if (sharedKey == null) MR.strings.status_contact_has_no_e2e_encryption else MR.strings.status_contact_has_e2e_encryption) - else -> generalGetString(if (!localEncrypted) MR.strings.status_no_e2e_encryption else if (sharedKey == null) MR.strings.status_contact_has_no_e2e_encryption else MR.strings.status_e2e_encrypted) + CallState.InvitationAccepted -> generalGetString(if (!hasSharedKey) MR.strings.status_contact_has_no_e2e_encryption else MR.strings.status_contact_has_e2e_encryption) + else -> generalGetString(if (!localEncrypted) MR.strings.status_no_e2e_encryption else if (!hasSharedKey) MR.strings.status_contact_has_no_e2e_encryption else MR.strings.status_e2e_encrypted) } val hasVideo: Boolean diff --git a/apps/multiplatform/common/src/desktopMain/kotlin/chat/simplex/common/views/call/CallView.desktop.kt b/apps/multiplatform/common/src/desktopMain/kotlin/chat/simplex/common/views/call/CallView.desktop.kt index 75782d75d7..57f6c48a15 100644 --- a/apps/multiplatform/common/src/desktopMain/kotlin/chat/simplex/common/views/call/CallView.desktop.kt +++ b/apps/multiplatform/common/src/desktopMain/kotlin/chat/simplex/common/views/call/CallView.desktop.kt @@ -31,7 +31,7 @@ val connections = ArrayList() actual fun ActiveCallView() { val scope = rememberCoroutineScope() WebRTCController(chatModel.callCommand) { apiMsg -> - Log.d(TAG, "received from WebRTCController: $apiMsg") + Log.d(TAG, "received from WebRTCController: ${apiMsg.resp.javaClass.simpleName}") val call = chatModel.activeCall.value if (call != null) { Log.d(TAG, "has active call $call") @@ -202,7 +202,7 @@ fun WebRTCController(callCommand: SnapshotStateList, onResponse: ( } while (callCommand.isNotEmpty()) { val cmd = callCommand.removeFirstOrNull() - Log.d(TAG, "WebRTCController LaunchedEffect executing $cmd") + Log.d(TAG, "WebRTCController LaunchedEffect executing ${cmd?.javaClass?.simpleName}") if (cmd != null) { processCommand(cmd) } @@ -289,7 +289,7 @@ class MyWebSocket(val onResponse: (WVAPIMessage) -> Unit, handshakeRequest: IHTT // onResponse(message.textPayload) onResponse(json.decodeFromString(message.textPayload)) } catch (e: Exception) { - Log.e(TAG, "failed parsing browser message: $message") + Log.e(TAG, "failed parsing browser message") } } diff --git a/apps/multiplatform/product/glossary.md b/apps/multiplatform/product/glossary.md index 10203d8a2a..15ed40d3a1 100644 --- a/apps/multiplatform/product/glossary.md +++ b/apps/multiplatform/product/glossary.md @@ -306,7 +306,7 @@ User-defined tags for organizing conversations. CRUD via `ApiCreateChatTag`, `Ap The real-time communication framework used for audio and video calls. The app uses WebRTC for peer-to-peer media streams, with SMP used only for call signaling (offer/answer/ICE candidates). ### Call (data class) -Represents an active call session. Fields: `remoteHostId`, `userProfile`, `contact`, `callUUID`, `callState` (CallState enum), `initialCallType` (Audio/Video), `localMediaSources`, `localCapabilities`, `peerMediaSources`, `sharedKey` (for E2E call encryption), `connectionInfo`, `connectedAt`. +Represents an active call session. Fields: `remoteHostId`, `userProfile`, `contact`, `callUUID`, `callState` (CallState enum), `initialCallType` (Audio/Video), `localMediaSources`, `localCapabilities`, `peerMediaSources`, `hasSharedKey` (whether an E2E call encryption key was agreed), `connectionInfo`, `connectedAt`. *See:* `common/src/commonMain/kotlin/chat/simplex/common/views/call/WebRTC.kt:14`