Skip to content

Commit efccd3a

Browse files
authored
chore: release version 4.1.3 (#18)
1 parent 9bd6406 commit efccd3a

File tree

5 files changed

+74
-8
lines changed

5 files changed

+74
-8
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Change Log
22

3+
## 4.1.3 (Feb 4, 2026)
4+
### Bug Fixes
5+
- Fixed WebGL memory issue by optimizing JSON parsing for message deserialization
6+
37
## 4.1.2 (Nov 3, 2025)
48
### Improvements
59
- Removed unnecessary URL encoding from SB-SDK-User-Agent header

Runtime/Scripts/Internal/Command/DataTransferObject/Message/BaseMessageDto.cs

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ internal static BaseMessageDto JsonStringToMessageDto(string inJsonString)
142142

143143
try
144144
{
145-
return JObjectToMessageDto(JObject.Parse(inJsonString));
145+
return JsonStringToMessageDtoDirectDeserialize(inJsonString);
146146
}
147147
catch (Exception exception)
148148
{
@@ -151,6 +151,32 @@ internal static BaseMessageDto JsonStringToMessageDto(string inJsonString)
151151
}
152152
}
153153

154+
private static BaseMessageDto JsonStringToMessageDtoDirectDeserialize(string inJsonString)
155+
{
156+
string typeString = NewtonsoftJsonExtension.ExtractTypeField(inJsonString);
157+
if (string.IsNullOrEmpty(typeString))
158+
return null;
159+
160+
WsCommandType wsCommandType = WsCommandTypeExtension.JsonNameToType(typeString);
161+
if (wsCommandType == WsCommandType.UserMessage || wsCommandType == WsCommandType.UpdateUserMessage)
162+
{
163+
return UserMessageDto.DeserializeFromJson(inJsonString);
164+
}
165+
166+
if (wsCommandType == WsCommandType.FileMessage || wsCommandType == WsCommandType.UpdateFileMessage)
167+
{
168+
return FileMessageDto.DeserializeFromJson(inJsonString);
169+
}
170+
171+
if (wsCommandType == WsCommandType.AdminMessage || wsCommandType == WsCommandType.UpdateAdminMessage)
172+
{
173+
return AdminMessageDto.DeserializeFromJson(inJsonString);
174+
}
175+
176+
Logger.Warning(Logger.CategoryType.Command, $"Invalid message type:{typeString} json:{inJsonString}");
177+
return null;
178+
}
179+
154180
internal static BaseMessageDto JObjectToMessageDto(JObject inJObject)
155181
{
156182
if (inJObject == null)

Runtime/Scripts/Internal/Common/Json/NewtonsoftJsonExtension.cs

Lines changed: 41 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
//
1+
//
22
// Copyright (c) 2022 Sendbird, Inc.
3-
//
3+
//
44

55
using System;
6+
using System.IO;
67
using Newtonsoft.Json;
78
using Newtonsoft.Json.Linq;
8-
using Newtonsoft.Json.Serialization;
99

1010
namespace Sendbird.Chat
1111
{
@@ -95,10 +95,46 @@ internal static TObject ToPropertyValueIgnoreException<TObject>(this JObject inJ
9595
return inDefaultIfFailed;
9696
}
9797

98-
private static void OnSerializerSettingsErrorHandler(object inSender, ErrorEventArgs inErrorEventArgs)
98+
private static void OnSerializerSettingsErrorHandler(object inSender, Newtonsoft.Json.Serialization.ErrorEventArgs inErrorEventArgs)
9999
{
100100
Logger.Warning(Logger.CategoryType.Json, $"OnSerializerSettingsErrorHandler exception:{inErrorEventArgs.ErrorContext.Error.Message}");
101101
inErrorEventArgs.ErrorContext.Handled = true;
102102
}
103+
104+
internal static JObject ParseToJObject(string inJsonString)
105+
{
106+
if (string.IsNullOrEmpty(inJsonString))
107+
{
108+
return null;
109+
}
110+
111+
return JObject.Parse(inJsonString);
112+
}
113+
114+
internal static string ExtractTypeField(string inJsonString)
115+
{
116+
if (string.IsNullOrEmpty(inJsonString))
117+
{
118+
return null;
119+
}
120+
121+
using (StringReader stringReader = new StringReader(inJsonString))
122+
using (JsonTextReader jsonReader = new JsonTextReader(stringReader))
123+
{
124+
while (jsonReader.Read())
125+
{
126+
if (jsonReader.TokenType == JsonToken.PropertyName &&
127+
string.Equals(jsonReader.Value as string, "type", StringComparison.Ordinal))
128+
{
129+
if (jsonReader.Read() && jsonReader.TokenType == JsonToken.String)
130+
{
131+
return jsonReader.Value as string;
132+
}
133+
}
134+
}
135+
}
136+
137+
return null;
138+
}
103139
}
104-
}
140+
}

Runtime/Scripts/UnityPlatform/UnityPlatformApplication.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ internal class UnityPlatformApplication : IPlatformApplication
1111
{
1212
// NOTE: This version is automatically updated by the PublishPackage workflow during deployment.
1313
// Only update manually when making releases outside of the automated workflow.
14-
string IPlatformApplication.SdkVersion => "4.1.2";
14+
string IPlatformApplication.SdkVersion => "4.1.3";
1515
string IPlatformApplication.PlatformName => "Unity";
1616
string IPlatformApplication.PlatformVersion => Application.unityVersion;
1717
string IPlatformApplication.OsName => Application.platform.ToString();

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "com.sendbird.chat",
33
"displayName": "SendbirdChat",
4-
"version": "4.1.2",
4+
"version": "4.1.3",
55
"documentationUrl": "https://github.com/sendbird/sendbird-chat-sdk-unity",
66
"changelogUrl": "https://github.com/sendbird/sendbird-chat-sdk-unity/blob/master/CHANGELOG.md",
77
"licensesUrl": "https://github.com/sendbird/sendbird-chat-sdk-unity/blob/master/LICENSE.md",

0 commit comments

Comments
 (0)