Skip to content

Commit

Permalink
Move error check to end of while loop
Browse files Browse the repository at this point in the history
Addresses issues where the warning is not shown even though the bytes of events processed exceed the limit. This turns the check more rigorous.
  • Loading branch information
jfreire-unity committed May 29, 2024
1 parent 3ad8aef commit c2e097a
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions Packages/com.unity.inputsystem/InputSystem/InputManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3062,10 +3062,6 @@ private unsafe void OnUpdate(InputUpdateType updateType, ref InputEventBuffer ev
// Handle events.
while (m_InputEventStream.remainingEventCount > 0)
{
// Discard events in case the maximum event bytes per update has been exceeded
if (WasMaximumEventBytesPerUpdateExceeded(totalEventBytesProcessed))
break;

InputDevice device = null;
var currentEventReadPtr = m_InputEventStream.currentEventPtr;

Expand Down Expand Up @@ -3461,6 +3457,10 @@ private unsafe void OnUpdate(InputUpdateType updateType, ref InputEventBuffer ev
}

m_InputEventStream.Advance(leaveEventInBuffer: false);

// Discard events in case the maximum event bytes per update has been exceeded
if (AreMaximumEventBytesPerUpdateExceeded(totalEventBytesProcessed))
break;
}

m_Metrics.totalEventProcessingTime +=
Expand Down Expand Up @@ -3492,7 +3492,7 @@ private unsafe void OnUpdate(InputUpdateType updateType, ref InputEventBuffer ev
m_CurrentUpdate = default;
}

bool WasMaximumEventBytesPerUpdateExceeded(uint totalEventBytesProcessed)
bool AreMaximumEventBytesPerUpdateExceeded(uint totalEventBytesProcessed)
{
if (m_Settings.maxEventBytesPerUpdate > 0 &&
totalEventBytesProcessed >= m_Settings.maxEventBytesPerUpdate)
Expand Down

0 comments on commit c2e097a

Please sign in to comment.