Skip to content

FIX: Pen touch input triggers UI/Click action two times (ISXB-1456) #2201

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: develop
Choose a base branch
from

Conversation

jfreire-unity
Copy link
Collaborator

@jfreire-unity jfreire-unity commented Jul 7, 2025

Description

This fixes ISXB-1546 by reverting the changes from #1982, which introduced a regression while addressing ISXB-687. Additionally, new tests have been added to prevent future regressions in this area.

The fix for ISXB-687 now checks whether the pointer state list contains the pointer before attempting removal.
Previously, users could set up a button listener event that could call InputSystemUIInputModule.OnDisable(), which would reset the pointer state during InputSystemUIInputModule.Process(). This would lead to attempts to remove pointer states that were removed during the reset.

Testing status & QA

Tested ISXB-1546 with a Samsung tablet with an active Pen. It would be ideal if @Pauliusd01 or some CQA could test this on device to make sure I didn't miss something.

Tested ISXB-687 reproduction steps which now don't raise an error.

Additionally, If you copy UITest.cs changes from this PR into develop, the tests should fail.

Overall Product Risks

Please rate the potential complexity and halo effect from low to high for the reviewers. Note down potential risks to specific Editor branches if any.

  • Complexity: 0
  • Halo Effect: 1

Comments to reviewers

Make sure to replicate steps from the Jira tickets and make sure they now work as expected.

Checklist

Before review:

  • Changelog entry added.
    • Explains the change in Changed, Fixed, Added sections.
    • For API change contains an example snippet and/or migration example.
    • JIRA ticket linked, example (case %%). If it is a private issue, just add the case ID without a link.
    • Jira port for the next release set as "Resolved".
  • Tests added/changed, if applicable.
    • Functional tests Area_CanDoX, Area_CanDoX_EvenIfYIsTheCase, Area_WhenIDoX_AndYHappens_ThisIsTheResult.
    • Performance tests.
    • Integration tests.
  • Docs for new/changed API's.
    • Xmldoc cross references are set correctly.
    • Added explanation how the API works.
    • Usage code examples added.
    • The manual is updated, if needed.

During merge:

  • Commit message for squash-merge is prefixed with one of the list:
    • NEW: ___.
    • FIX: ___.
    • DOCS: ___.
    • CHANGE: ___.
    • RELEASE: 1.1.0-preview.3.

After merge:

  • Create forward/backward port if needed. If you are blocked from creating a forward port now please add a task to ISX-1444.

@codecov-github-com
Copy link

codecov-github-com bot commented Jul 7, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

@@             Coverage Diff             @@
##           develop    #2201      +/-   ##
===========================================
- Coverage    68.11%   68.11%   -0.01%     
===========================================
  Files          367      367              
  Lines        53610    53603       -7     
===========================================
- Hits         36519    36512       -7     
  Misses       17091    17091              
Flag Coverage Δ
mac_2021.3_pkg 5.40% <0.00%> (+<0.01%) ⬆️
mac_2021.3_project 70.36% <100.00%> (-0.01%) ⬇️
mac_2022.3_pkg 5.18% <ø> (ø)
mac_2022.3_project 65.23% <100.00%> (-0.01%) ⬇️
mac_6000.0_pkg 5.19% <ø> (ø)
mac_6000.0_project 68.03% <100.00%> (-0.01%) ⬇️
mac_6000.1_pkg 5.19% <ø> (ø)
mac_6000.1_project 68.02% <100.00%> (-0.01%) ⬇️
mac_6000.2_pkg 5.19% <ø> (ø)
mac_6000.2_project 68.02% <100.00%> (-0.01%) ⬇️
mac_trunk_pkg 5.19% <ø> (ø)
mac_trunk_project 68.02% <100.00%> (-0.01%) ⬇️
win_2021.3_pkg 5.41% <0.00%> (+<0.01%) ⬆️
win_2021.3_project 70.44% <100.00%> (-0.01%) ⬇️
win_2022.3_pkg 5.18% <ø> (ø)
win_2022.3_project 65.30% <100.00%> (-0.01%) ⬇️
win_6000.0_pkg 5.19% <ø> (ø)
win_6000.0_project 68.10% <100.00%> (-0.01%) ⬇️
win_6000.1_pkg 5.19% <ø> (ø)
win_6000.1_project 68.10% <100.00%> (-0.01%) ⬇️
win_6000.2_pkg 5.19% <ø> (ø)
win_6000.2_project 68.09% <100.00%> (-0.02%) ⬇️
win_trunk_pkg 5.19% <ø> (ø)
win_trunk_project 68.09% <100.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...InputSystem/Plugins/UI/InputSystemUIInputModule.cs 93.13% <100.00%> (-0.05%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@jfreire-unity jfreire-unity requested a review from Copilot July 11, 2025 13:34
Copilot

This comment was marked as outdated.

@jfreire-unity jfreire-unity force-pushed the isxb-1456-fix-pen-touch-double-ui-clicks branch from fb31fe7 to 96b6291 Compare July 11, 2025 13:58
@jfreire-unity jfreire-unity force-pushed the isxb-1456-fix-pen-touch-double-ui-clicks branch from bd091b8 to 4343463 Compare July 14, 2025 14:00
@jfreire-unity jfreire-unity requested a review from Copilot July 14, 2025 14:00
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

A fix for double-firing UI click events when pen and touch input arrive simultaneously.

  • Updated pointer removal logic to handle empty state lists and only decrement indices when removal actually occurs.
  • Simplified filtering to immediately remove non–mouse/pen pointers when a mouse or pen event is detected.
  • Expanded UITests with cleanup steps, simultaneous mouse+touch scenarios, and a test for disabling the UI module during a click.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
Packages/com.unity.inputsystem/.../InputSystemUIInputModule.cs Reordered empty-state check, moved the assert, removed legacy touch-delay logic, and refined removal in Process.
Assets/Tests/InputSystem/Plugins/UITests.cs Added touch cleanup, new simultaneous-input tests, and a disabling-module-during-click test.
Comments suppressed due to low confidence (3)

Assets/Tests/InputSystem/Plugins/UITests.cs:1536

  • [nitpick] The method name ends with a duplicate "Works"; consider renaming to improve clarity (e.g., UI_DisablingEventSystemOnClickWorksWithTouchPointers).
    public IEnumerator UI_DisablingEventSystemOnClickEventWorksWithTouchPointersWorks()

Packages/com.unity.inputsystem/InputSystem/Plugins/UI/InputSystemUIInputModule.cs:2075

  • Consider validating that the index parameter is also less than m_PointerStates.length before accessing m_PointerStates[index] to avoid potential out-of-range errors.
            if (m_PointerStates.length == 0)

Assets/Tests/InputSystem/Plugins/UITests.cs:1464

  • The same touch ID (1) is used for ending touches on different devices; ensure each EndTouch call uses the matching ID from its corresponding BeginTouch.
        EndTouch(1, secondPosition, screen: touch1);

if (state.pointerType == UIPointerType.Touch && (state.leftButton.isPressed || state.leftButton.wasReleasedThisFrame))
{
// The pointer was not removed
// Pointers can have be reset before (e.g. when calling OnDisable) which would make m_PointerStates
Copy link
Preview

Copilot AI Jul 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Grammar: "have be reset" should be "have been reset".

Suggested change
// Pointers can have be reset before (e.g. when calling OnDisable) which would make m_PointerStates
// Pointers can have been reset before (e.g. when calling OnDisable) which would make m_PointerStates

Copilot uses AI. Check for mistakes.

@jfreire-unity jfreire-unity marked this pull request as ready for review July 15, 2025 09:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy