Skip to content

Commit 93088fd

Browse files
authored
FIX: Remoting code producing invalid pointers on 32bit Android (#1240).
1 parent f439e23 commit 93088fd

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

Assets/Tests/InputSystem/CoreTests_Remoting.cs

-3
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,6 @@ public void Remote_OnlyGeneratedLayoutsAreSentToRemotes()
118118

119119
[Test]
120120
[Category("Remote")]
121-
#if UNITY_ANDROID && !UNITY_EDITOR
122-
[Ignore("Case 1254567")]
123-
#endif
124121
public void Remote_EventsAreSentToRemotes()
125122
{
126123
var gamepad = InputSystem.AddDevice<Gamepad>();

Packages/com.unity.inputsystem/InputSystem/Devices/Remote/InputRemoting.cs

+3-2
Original file line numberDiff line numberDiff line change
@@ -624,8 +624,9 @@ public static unsafe void Process(InputRemoting receiver, Message msg)
624624
var eventCount = 0;
625625
var eventPtr = new InputEventPtr((InputEvent*)dataPtr);
626626
var senderIndex = receiver.FindOrCreateSenderRecord(msg.participantId);
627-
628-
while ((Int64)eventPtr.data < dataEndPtr.ToInt64())
627+
// Don't use IntPtr.ToInt64() function, on 32 bit systems, the pointer is first converted to Int32 and then casted to Int64
628+
// Thus for big pointer value, you might get a negative value even though the pointer value will be less than Int64.MaxValue
629+
while ((void*)eventPtr.data < dataEndPtr.ToPointer())
629630
{
630631
// Patch up device ID to refer to local device and send event.
631632
var remoteDeviceId = eventPtr.deviceId;

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

+5-2
Original file line numberDiff line numberDiff line change
@@ -2900,8 +2900,11 @@ private static void SetUpRemotingInternal()
29002900
#if !UNITY_EDITOR
29012901
private static bool ShouldEnableRemoting()
29022902
{
2903-
////FIXME: is there a better way to detect whether we are running tests?
2904-
var isRunningTests = Application.productName == "UnityTestFramework";
2903+
#if UNITY_INCLUDE_TESTS
2904+
var isRunningTests = true;
2905+
#else
2906+
var isRunningTests = false;
2907+
#endif
29052908
if (isRunningTests)
29062909
return false; // Don't remote while running tests.
29072910
return true;

0 commit comments

Comments
 (0)