- 
                Notifications
    
You must be signed in to change notification settings  - Fork 329
 
          FIX: An infinite loop in InputSystemUIInputModule was causing an editor / player hang
          #2102
        
          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
Conversation
5ff4e7b    to
    9790a08      
    Compare
  
    | 
           Good catch! I can have a look today or Monday 👍  | 
    
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks ok, good find!
Just added a question before approving. Also added QA to test this and make sure Touch functionality has no regression.
        
          
                Packages/com.unity.inputsystem/InputSystem/Plugins/UI/InputSystemUIInputModule.cs
          
            Show resolved
            Hide resolved
        
      | 
           Hi @MahumKhan , could you help with checking the switch platform?  | 
    
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Helped with some testing:
Can reproduce the bug and it looks fixed with this PR.
TouchSamples project also still works.
Tested on:
- Win11 touchscreen
 - Pixel 6a
 - Unity 22.3 + 6.0
 
…cceed - this assumption meant we were always deprecating a loop index ultimately leading to an infinite loop (when using touch input)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, checked touch + PS5/Xbox input on the user repro project as well as the internal Touch Event/Sensor project on Mi 8 Lite, iPhone 8 and did not notice any unexpected issues or crashes
9790a08    to
    7ce637e      
    Compare
  
    There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested this on Switch with and without the fix, can confirm that without installing this fixed package, the project freezes. With it installed, it doesn't freeze.
Tested by spamming A and touching the white square on the screen repeatedly.
Description
Fixes ISXB-1258
This was caused by the assumption that
RemovePointerAtIndexwould always successfully remove the pointer, which is not the case with touch based pointers.The following code highlights the issue:
If
SendPointerExitEventsAndRemovePointerfails to remove the pointer from the list; decrementingiis incorrect and will lead to attempting to remove the pointer at the same index again, which will fail and we'll loop ad infinitum.Testing status & QA
I've tested this locally on a Windows 11 touch-enabled machine (laptop), but it would be great to get some testing across mobile devices (including Switch) to ensure no additional issues were introduced.
Overall Product Risks
Comments to reviewers
The only remaining concern I have with this solution is with the
OnDisablecode. The first thing we call inOnDisablefor the Input system UI module isResetPointers- how important is it that the pointers are all 100% reset here? If it is an absolute must, we could always add a force flag as a parameter to theSendPointerExitEventsAndRemovePointermethod.Checklist
Before review:
Changed,Fixed,Addedsections.Area_CanDoX,Area_CanDoX_EvenIfYIsTheCase,Area_WhenIDoX_AndYHappens_ThisIsTheResult.During merge:
NEW: ___.FIX: ___.DOCS: ___.CHANGE: ___.RELEASE: 1.1.0-preview.3.After merge: