Skip to content

Commit 1a6b80d

Browse files
FIX: InputEventTrace skipping over empty frames (Unity-Technologies#1368).
1 parent 4ee1554 commit 1a6b80d

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

Assets/Tests/InputSystem/CoreTests_Events.cs

+7-1
Original file line numberDiff line numberDiff line change
@@ -1327,7 +1327,8 @@ public void Events_CanReplayEventsFromEventTrace_FrameByFrame()
13271327
trace.Enable();
13281328

13291329
Press(gamepad.buttonSouth);
1330-
InputSystem.Update();
1330+
InputSystem.Update(); // Record empty frame.
1331+
InputSystem.Update(); // Record empty frame.
13311332
Release(gamepad.buttonSouth);
13321333

13331334
trace.Disable();
@@ -1349,6 +1350,11 @@ public void Events_CanReplayEventsFromEventTrace_FrameByFrame()
13491350

13501351
InputSystem.Update();
13511352

1353+
Assert.That(replay.finished, Is.False);
1354+
Assert.That(gamepad.buttonSouth.isPressed, Is.True);
1355+
1356+
InputSystem.Update();
1357+
13521358
Assert.That(replay.finished, Is.True);
13531359
Assert.That(gamepad.buttonSouth.isPressed, Is.False);
13541360
}

Packages/com.unity.inputsystem/CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ however, it has to be formatted properly to pass verification tests.
3131
- Fixed a problem arising when combining InputSystemUIInputModule and PlayInput with SendMessage or BroadcastMessage callback behavior on the same game object or hierarchy which is an ambiguous input setup. This fix eliminates callbacks into InputSystemUIInputModule. Related to ([1343712](https://issuetracker.unity3d.com/issues/input-system-ui-components-lags-when-using-input-system-ui-input-module-together-with-player-input-component)).
3232
- Fixed inconsistent usage of `ENABLE_PROFILER` define together with `Profiler.BeginSample`/`Profiler.EndSample` by removing `ENABLE_PROFILER` macro check because `BeginSample`/`EndSample` are already conditional with `[Conditional("ENABLE_PROFILER")]` ([case 1350139](https://issuetracker.unity3d.com/issues/inconsistent-enable-profiler-scripting-defines-in-inputmanager-dot-cs-when-using-profiler-dot-beginssample-and-profiler-dot-endsample)).
3333
- Remediated majority of performance issues with high frequency mice (>=1kHz poll rates) in release mode by merging consecutive mouse move events together ([case 1281266](https://issuetracker.unity3d.com/issues/many-input-events-when-using-1000hz-mouse)).
34+
- Fixed `InputEventTrace` replays skipping over empty frames and thus causing playback to happen too fast.
3435

3536
#### Actions
3637

Packages/com.unity.inputsystem/InputSystem/Events/InputEventTrace.cs

+8-2
Original file line numberDiff line numberDiff line change
@@ -1327,16 +1327,22 @@ private void OnBeginFrame()
13271327
// returned from MoveNext).
13281328
if (currentEventPtr.type == FrameMarkerEvent)
13291329
{
1330-
if (!MoveNext(false, out currentEventPtr))
1330+
if (!MoveNext(false, out var nextEvent))
13311331
{
13321332
// Last frame.
13331333
Finished();
13341334
return;
13351335
}
13361336

13371337
// Check for empty frame.
1338-
if (currentEventPtr.type == FrameMarkerEvent)
1338+
if (nextEvent.type == FrameMarkerEvent)
1339+
{
1340+
--position;
1341+
m_Enumerator.m_Current = currentEventPtr;
13391342
return;
1343+
}
1344+
1345+
currentEventPtr = nextEvent;
13401346
}
13411347

13421348
// Inject our events into the frame.

0 commit comments

Comments
 (0)