Skip to content

Commit c1f24b2

Browse files
committed
Version 1.9.2,
1 parent 7c60d73 commit c1f24b2

26 files changed

+122
-136
lines changed

Runtime/API/UGC/KinetixUGC.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ public void GetUgcUrl(Action<string> _UrlFetchedCallback)
3030
KinetixUGCBehaviour.GetUgcUrl(_UrlFetchedCallback);
3131
}
3232

33+
[Obsolete("RetakeEmoteProcess now returns the full url. This method will be deleted")]
3334
public void GetRetakeUgcUrl(string _RetakeToken, Action<string> _UrlFetchedCallback)
3435
{
3536
KinetixUGCBehaviour.GetRetakeUgcUrl(_RetakeToken, _UrlFetchedCallback);
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Starting compiling Kinetix.Retarget.dll
2-
D:\UnityInstall\2020.3.33f1\Editor\Data\Tools\RoslynScripts\unity_csc.bat /noconfig @Temp/UnityTempFile-11c7cc3f5ec7f534695b43269a793491
3-
# Starting IL post processing on Kinetix.Retarget.dll
4-
D:/UnityInstall/2020.3.33f1/Editor/Data/MonoBleedingEdge/bin/mono.exe D:/UnityInstall/2020.3.33f1/Editor/Data/Tools/ILPostProcessorRunner/ILPostProcessorRunner.exe @D:/Kinetix/kinetix-emote-wheel/Temp/UnityTempFile-495fa8d13cdfcfb40af0fed8dd6be891
1+
# Starting compiling Kinetix.Clip.dll
2+
D:\UnityInstall\2020.3.33f1\Editor\Data\Tools\RoslynScripts\unity_csc.bat /noconfig @Temp/UnityTempFile-9cb02fd81e620e84aacdcf7466598e45
3+
# Starting IL post processing on Kinetix.Clip.dll
4+
D:/UnityInstall/2020.3.33f1/Editor/Data/MonoBleedingEdge/bin/mono.exe D:/UnityInstall/2020.3.33f1/Editor/Data/Tools/ILPostProcessorRunner/ILPostProcessorRunner.exe @D:/Kinetix/kinetix-emote-wheel/Temp/UnityTempFile-720b05da632498e418886589e176f1ab

Runtime/Retarget/CompilationLog.txt.meta renamed to Runtime/Clip/CompilationLog.txt.meta

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Runtime/Clip/Kinetix.Clip.dll

0 Bytes
Binary file not shown.

Runtime/Const/KinetixConstants.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ namespace Kinetix.Internal
88
{
99
public static class KinetixConstants
1010
{
11-
public const string version = "1.9.1";
11+
public const string version = "1.9.2";
1212
public static bool C_ShouldUGCBeAvailable = true;
1313

1414
#if STAGING_KINETIX

Runtime/Emote/KinetixEmote.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,9 @@ public string GetAnimationURLOrNull(string _AvatarId = null)
8181
public string GetAnimationURLOrNull(string _Extension, string _AvatarId)
8282
{
8383
if (_AvatarId == null)
84-
return Metadata.UrlByFormat[_Extension];
84+
return Metadata.UrlByFormat.ValueOrDefault(_Extension);
8585

86-
return GetAvatarMetadata(_AvatarId)?.UrlByFormat[_Extension];
86+
return GetAvatarMetadata(_AvatarId)?.UrlByFormat.ValueOrDefault(_Extension);
8787
}
8888
}
8989
}

Runtime/Managers/AccountManager.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,9 +222,9 @@ public async void RetakeEmoteProcess(string _ProcessId, Action<string> _OnSucces
222222
{
223223
try
224224
{
225-
SdkApiProcess process = await KinetixCoreBehaviour.ServiceLocator.Get<ProviderService>().RetakeEmote(_ProcessId);
225+
SdkTokenValidityResult process = await KinetixCoreBehaviour.ServiceLocator.Get<ProviderService>().RetakeEmote(_ProcessId);
226226

227-
_OnSuccess?.Invoke(process.Uuid.ToString());
227+
_OnSuccess?.Invoke(process.url.ToString());
228228
}
229229
catch (Exception e)
230230
{

Runtime/Providers/Providers/IProviderWrapper.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@ public interface IProviderWrapper
1717
public Task<AnimationMetadata> GetAnimationMetadataOfAvatar(AnimationIds _AnimationIds, string _AvatarId, AnimationMetadata _Metadata = null);
1818
public Task<SdkApiProcess[]> GetAnimationProcessesOfOwner(string _AccountId);
1919
public Task<SdkApiProcess> ValidateEmote(string _EmoteId);
20-
public Task<SdkApiProcess> RetakeEmote(string _EmoteId);
20+
public Task<SdkTokenValidityResult> RetakeEmote(string _EmoteId);
2121
}
2222

Runtime/Providers/Providers/SdkApi/ApiClasses/SdkTokenValidityResult.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
namespace Kinetix.Internal
22
{
3-
internal class SdkTokenValidityResult
3+
public class SdkTokenValidityResult
44
{
5+
public string url;
56
public int expireIn;
67
public System.DateTime expire;
78
}

Runtime/Providers/Providers/SdkApi/SdkApiProviderWrapper.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -241,9 +241,9 @@ public async Task<SdkApiProcess> ValidateEmote(string _ProcessId)
241241
return await tcs.Task;
242242
}
243243

244-
public async Task<SdkApiProcess> RetakeEmote(string _ProcessId)
244+
public async Task<SdkTokenValidityResult> RetakeEmote(string _ProcessId)
245245
{
246-
TaskCompletionSource<SdkApiProcess> tcs = new TaskCompletionSource<SdkApiProcess>();
246+
TaskCompletionSource<SdkTokenValidityResult> tcs = new TaskCompletionSource<SdkTokenValidityResult>();
247247

248248
string url = KinetixConstants.c_SDK_API_URL + "/v1/process/" + _ProcessId + "/retake";
249249

@@ -264,7 +264,7 @@ public async Task<SdkApiProcess> RetakeEmote(string _ProcessId)
264264
if (!response.IsSuccess)
265265
throw new Exception(response.Error);
266266

267-
tcs.SetResult(JsonConvert.DeserializeObject<SdkApiProcess>(response.Content));
267+
tcs.SetResult(JsonConvert.DeserializeObject<SdkTokenValidityResult>(response.Content));
268268
}
269269
catch (Exception e)
270270
{

Runtime/Retarget/Kinetix.Retarget.dll

0 Bytes
Binary file not shown.

Runtime/Retarget/Webgl/CompilationLog.txt

Lines changed: 0 additions & 4 deletions
This file was deleted.

Runtime/Retarget/Webgl/CompilationLog.txt.meta

Lines changed: 0 additions & 7 deletions
This file was deleted.
6 KB
Binary file not shown.

Runtime/Retarget/Webgl/Kinetix.Retarget.dll.meta

Lines changed: 0 additions & 54 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
-104 KB
Binary file not shown.

Runtime/Retarget/Webgl/Kinetix.Retarget.pdb.meta

Lines changed: 0 additions & 7 deletions
This file was deleted.

Runtime/Services/AnimationFile/AAnimLoader.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
using Kinetix.Internal.Retargeting.AnimationData;
22
using Kinetix.Utils;
3+
using System;
34
using System.IO;
45
using System.Threading;
56
using System.Threading.Tasks;
67

78
namespace Kinetix.Internal
89
{
9-
public abstract class AAnimLoader
10+
public abstract class AAnimLoader : IDisposable
1011
{
1112
public abstract string Extension { get; }
1213
protected readonly ServiceLocator serviceLocator;
@@ -51,5 +52,7 @@ public string EnsureDirectoryExists(string filepath)
5152

5253
return filepath;
5354
}
54-
}
55+
56+
public virtual void Dispose() {}
57+
}
5558
}

Runtime/Services/AnimationFile/KinanimLoader.cs

Lines changed: 40 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,22 @@ namespace Kinetix.Internal
1414
{
1515
internal class KinanimLoader : AAnimLoader
1616
{
17+
List<KinanimLoader> instance = new List<KinanimLoader>();
18+
1719
const long HEADER_DOWNLOAD_SIZE = 1000 * 5;
1820

1921
private readonly Dictionary<string, KinanimServiceData> kinanimIndexerByFilepath = new Dictionary<string, KinanimServiceData>();
2022
protected readonly EmoteDownloadSpeedService downloadSpeedService;
2123

2224
public KinanimLoader(ServiceLocator _ServiceLocator) : base(_ServiceLocator)
2325
{
26+
if (instance.Count != 0)
27+
{
28+
Debug.LogWarning(nameof(KinanimLoader) + "'s already has an instance. This could lead to " + nameof(IOException) + "s");
29+
}
30+
31+
instance.Add(this);
32+
2433
downloadSpeedService = _ServiceLocator.Get<EmoteDownloadSpeedService>();
2534
}
2635

@@ -32,7 +41,8 @@ public override async Task<RuntimeRetargetFrameIndexer> Load(KinetixEmote emote,
3241

3342
if (kinanimIndexerByFilepath.TryGetValue(filepath, out KinanimServiceData data))
3443
{
35-
data.exporter?.Dispose();
44+
if (data.exporter != null)
45+
DisposeExporter(data);
3646
data.exporter = new KinanimExporter(new FileStream(filepath, FileMode.OpenOrCreate, FileAccess.Write));
3747
}
3848
else
@@ -48,7 +58,7 @@ public override async Task<RuntimeRetargetFrameIndexer> Load(KinetixEmote emote,
4858
await
4959
AsyncDownloadRemainingFrames(data, url, null, true)
5060
.Catch((e) => KinetixDebug.LogException(e))
51-
.Then(() => { data.exporter.Dispose(); });
61+
.Then(() => DisposeExporter(data));
5262
}
5363

5464
return await Task.FromResult<RuntimeRetargetFrameIndexer>(data.indexer);
@@ -85,7 +95,7 @@ public override async Task<RuntimeRetargetFrameIndexer> Download(KinetixEmote em
8595
//Download remaining frames
8696
_ = AsyncDownloadRemainingFrames(kinanim, url, null, false)
8797
.Catch(KinetixDebug.LogException)
88-
.Then(kinanim.exporter.Dispose);
98+
.Then(() => DisposeExporter(kinanim));
8999

90100
return kinanim.indexer;
91101
}
@@ -150,19 +160,22 @@ private KinanimServiceData GetStartDataFromEmote(string filepath, Stream readStr
150160
BinaryReader byteReader = new BinaryReader(readStream);
151161
importer.ReadHeader(byteReader);
152162
importer.ReadFrames(byteReader);
153-
byteReader.Dispose();
154-
readStream.Dispose();
163+
readStream.Close();
155164

156165
//Set local dictionary with : KinanimDataIndexer
157166
KinanimDataIndexer indexer = new KinanimDataIndexer(importer, !string.IsNullOrEmpty(avatarId));
158167
indexer.Init();
159-
indexer.UpdateIndexCount();
160168
data = new KinanimServiceData(indexer, new KinanimExporter(new FileStream(filepath, FileMode.OpenOrCreate, FileAccess.Write)));
161169

162170
if (!(readStream is FileStream))
163171
data.exporter.OverrideHeader(data.indexer.dataSource.UncompressedHeader); //Frame size changed so we need to rewrite the header
164172

173+
kinanimIndexerByFilepath.ValueOrDefault(filepath)?.exporter.Dispose();
165174
kinanimIndexerByFilepath[filepath] = data;
175+
176+
//Update the indexer at the end only
177+
indexer.UpdateIndexCount();
178+
166179
return data;
167180
}
168181

@@ -183,6 +196,7 @@ private async Task GetServerHeader(KinanimDataIndexer indexer, string url, Cance
183196
indexer.dataSource.MoveHeaderToUncompressedHeader();
184197
indexer.dataSource.ReadHeader(stream);
185198
indexer.UpdateIndexCount();
199+
stream.Close();
186200
}
187201

188202
private async Task<(int frameMin, int frameMax)> LoadBatchFrameKinanim(KinanimDataIndexer indexer, string url, CancellationTokenSource cancellationToken)
@@ -202,11 +216,30 @@ private async Task GetServerHeader(KinanimDataIndexer indexer, string url, Cance
202216
MemoryStream stream = new MemoryStream(response.bytes);
203217
indexer.dataSource.ReadFrames(stream);
204218
indexer.UpdateIndexCount();
205-
219+
stream.Close();
206220
#if DEV_KINETIX
207221
KinetixLogger.LogDebug("Kinanim,Download", $"downloaded frames {minFrame}-{maxFrame} (byte={byteMin}-{byteMax})", true);
208222
#endif
209223
return (minFrame, maxFrame);
210224
}
225+
226+
private void DisposeExporter(KinanimServiceData data)
227+
{
228+
data.exporter.Dispose();
229+
}
230+
231+
public override void Dispose()
232+
{
233+
base.Dispose();
234+
try
235+
{
236+
instance.Remove(this);
237+
}
238+
catch (Exception) {}
239+
foreach (var item in kinanimIndexerByFilepath)
240+
{
241+
item.Value.exporter?.Dispose();
242+
}
243+
}
211244
}
212245
}

Runtime/Services/AnimationFile/LoadAnimService.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
namespace Kinetix.Internal
1010
{
11-
public class LoadAnimService : IKinetixService
11+
public class LoadAnimService : IKinetixService, IDisposable
1212
{
1313
private const string NO_METADATA_FOUND_FOR_EMOTE = "No metadata found for emote : ";
1414

@@ -215,5 +215,13 @@ bool First(AAnimLoader loader)
215215
throw new Exception($"Couldn't find file extension '{extension}'", e);
216216
}
217217
}
218-
}
218+
219+
public void Dispose()
220+
{
221+
for (int i = loaders.Length - 1; i >= 0; i--)
222+
{
223+
loaders[i].Dispose();
224+
}
225+
}
226+
}
219227
}

Runtime/Services/ProviderService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ public async Task<SdkApiProcess> ValidateEmote(string _EmoteId)
107107
}
108108

109109
/// <summary>
110-
public async Task<SdkApiProcess> RetakeEmote(string _EmoteId)
110+
public async Task<SdkTokenValidityResult> RetakeEmote(string _EmoteId)
111111
{
112112
try
113113
{

0 commit comments

Comments
 (0)