From 7f90049c7300716b7842e0a1a4f474b119301747 Mon Sep 17 00:00:00 2001 From: bgrozev Date: Wed, 7 Dec 2022 13:20:33 -0600 Subject: [PATCH] fix: Temporary fix for JingleSession-s being GC too early (#1019) JingleSessions register with JingleIqHandler which saves a weak reference and there are no other references to the object until the session is accepted and saved as Participant.jingleSession. If the weak reference expires before session-accept is received the session fails to establish. This is a quick and dirty fix, a proper solution will follow later. --- .../org/jitsi/jicofo/conference/ParticipantInviteRunnable.java | 2 ++ .../src/main/kotlin/org/jitsi/jicofo/conference/Participant.kt | 3 +++ 2 files changed, 5 insertions(+) diff --git a/jicofo/src/main/java/org/jitsi/jicofo/conference/ParticipantInviteRunnable.java b/jicofo/src/main/java/org/jitsi/jicofo/conference/ParticipantInviteRunnable.java index 348bf6ade0..3fd67bfa51 100644 --- a/jicofo/src/main/java/org/jitsi/jicofo/conference/ParticipantInviteRunnable.java +++ b/jicofo/src/main/java/org/jitsi/jicofo/conference/ParticipantInviteRunnable.java @@ -387,6 +387,8 @@ private boolean doInviteOrReinvite(Offer offer, ColibriAllocation colibriAllocat jingleSession.terminate(Reason.UNDEFINED, null, false); } jingleSession = participant.createNewJingleSession(); + // Save a reference to jingleSession to prevent it from being garbage collected. Temporary fix! + participant.setJingleSessionTmp(jingleSession); logger.info("Sending session-initiate to: " + participant.getMucJid() + " sources=" + sources); ack = jingleSession.initiateSession( offer.getContents(), diff --git a/jicofo/src/main/kotlin/org/jitsi/jicofo/conference/Participant.kt b/jicofo/src/main/kotlin/org/jitsi/jicofo/conference/Participant.kt index e6d746408e..3133237b5e 100644 --- a/jicofo/src/main/kotlin/org/jitsi/jicofo/conference/Participant.kt +++ b/jicofo/src/main/kotlin/org/jitsi/jicofo/conference/Participant.kt @@ -80,6 +80,9 @@ open class Participant @JvmOverloads constructor( addContext("participant", endpointId) } + // Save a reference to jingleSession to prevent it from being garbage collected. Temporary fix! + var jingleSessionTmp: JingleSession? = null + /** * The layer which keeps track of which sources have been signaled to this participant. */