From b7630d0c9ffa83f6fd6e3308d1e66168af70d463 Mon Sep 17 00:00:00 2001 From: Haesu Gwon Date: Tue, 4 Jan 2022 09:09:49 +0900 Subject: [PATCH] [WebRTC] Prevent cb instance from GC (#3835) --- src/Tizen.Multimedia.Remoting/WebRTC/WebRTC.cs | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/Tizen.Multimedia.Remoting/WebRTC/WebRTC.cs b/src/Tizen.Multimedia.Remoting/WebRTC/WebRTC.cs index 0e6d427..d319925 100755 --- a/src/Tizen.Multimedia.Remoting/WebRTC/WebRTC.cs +++ b/src/Tizen.Multimedia.Remoting/WebRTC/WebRTC.cs @@ -229,11 +229,15 @@ namespace Tizen.Multimedia.Remoting tcsSdpCreated.TrySetResult(sdp); }; - NativeWebRTC.CreateSDPOfferAsync(Handle, new SafeBundleHandle(), cb, IntPtr.Zero). + string offer = null; + using (var cbKeeper = ObjectKeeper.Get(cb)) + { + NativeWebRTC.CreateSDPOfferAsync(Handle, new SafeBundleHandle(), cb, IntPtr.Zero). ThrowIfFailed("Failed to create offer asynchronously"); - var offer = await tcsSdpCreated.Task.ConfigureAwait(false); - await Task.Yield(); + offer = await tcsSdpCreated.Task.ConfigureAwait(false); + await Task.Yield(); + } return offer; } @@ -258,11 +262,15 @@ namespace Tizen.Multimedia.Remoting tcsSdpCreated.TrySetResult(sdp); }; - NativeWebRTC.CreateSDPAnswerAsync(Handle, new SafeBundleHandle(), cb, IntPtr.Zero). + string answer = null; + using (var cbKeeper = ObjectKeeper.Get(cb)) + { + NativeWebRTC.CreateSDPAnswerAsync(Handle, new SafeBundleHandle(), cb, IntPtr.Zero). ThrowIfFailed("Failed to create answer asynchronously"); - var answer = await tcsSdpCreated.Task.ConfigureAwait(false); - await Task.Yield(); + answer = await tcsSdpCreated.Task.ConfigureAwait(false); + await Task.Yield(); + } return answer; } -- 2.7.4