From 230fdd8a187285c3cffcb9beae9730eedab7b3a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Czemierowski?= Date: Thu, 11 Dec 2025 11:16:54 +0100 Subject: [PATCH] fix events flush getting locked after failed POST & small GC improvement * set 'EventsAPI.lockFlushes' to false even if 'Call' throws exception * check if 'lockFlushes' before allocating new array ('eventsToSend') --- .../Talo/Runtime/APIs/EventsAPI.cs | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/Assets/Talo Game Services/Talo/Runtime/APIs/EventsAPI.cs b/Assets/Talo Game Services/Talo/Runtime/APIs/EventsAPI.cs index ca05eac..4af82fa 100644 --- a/Assets/Talo Game Services/Talo/Runtime/APIs/EventsAPI.cs +++ b/Assets/Talo Game Services/Talo/Runtime/APIs/EventsAPI.cs @@ -80,15 +80,15 @@ public async Task Flush() { Talo.IdentityCheck(); - var eventsToSend = queue.ToArray(); - if (eventsToSend.Length == 0) + if (lockFlushes) { + flushAttemptedDuringLock = true; return; } - if (lockFlushes) + var eventsToSend = queue.ToArray(); + if (eventsToSend.Length == 0) { - flushAttemptedDuringLock = true; return; } @@ -103,14 +103,16 @@ public async Task Flush() await Call(uri, "POST", content); OnFlushed.Invoke(); - - eventsToFlush.Clear(); - lockFlushes = false; } catch (Exception ex) { Debug.LogError(ex.Message); } + finally + { + eventsToFlush.Clear(); + lockFlushes = false; + } if (flushAttemptedDuringLock) {