Skip to content

Commit a02386a

Browse files
committed
metrics: fix for pending jobs being delayed one or more frames
The list of pending jobs was being traversed using an index that was unconditionally incremented, even after removing an item from the list. This could cause a job to be skipped in `SendPendingEvents`, at least until the next frame. This was not a fatal error as any skipped jobs would be handled in the later calls to SendPendingEvents (next tick). Noticed while auditing the code for a reported issue with dropped events.
1 parent 0f52d96 commit a02386a

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

Runtime/Model/Metrics/MetricsSubmissionQueue.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,14 +138,18 @@ internal void SendPayload(ICollection<T> events, uint attempts = 0)
138138

139139
public void SendPendingEvents(float time)
140140
{
141-
for (int index = 0; index < _submissionJobs.Count; index++)
141+
for (int index = 0; index < _submissionJobs.Count; )
142142
{
143143
var submissionJob = _submissionJobs.ElementAt(index);
144144
if (submissionJob.NextInvokeTime < time)
145145
{
146146
SendPayload(submissionJob.Events, submissionJob.NumberOfAttempts);
147147
_submissionJobs.RemoveAt(index);
148148
}
149+
else
150+
{
151+
index++;
152+
}
149153
}
150154
}
151155

0 commit comments

Comments
 (0)