Skip to content
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

FIX: Avoid potential for NullReferenceException in FireStateChangeNotifications (ISXB-724). #1927

Merged
merged 8 commits into from
May 24, 2024

Conversation

graham-huws
Copy link
Collaborator

@graham-huws graham-huws commented May 13, 2024

Description

A tentative fix, given no known repro, for ISXB-724.

Changes made

Added early returns in cases we'd otherwise crash.

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.
    • FogBugz ticket attached, example ([case %number%](https://issuetracker.unity3d.com/issues/...)).
    • FogBugz is marked as "Resolved" with next release version correctly set.
  • 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.

@graham-huws
Copy link
Collaborator Author

@stefanunity I realise there's nothing really to test here given that there's no repro steps for the original issue, but just wanted you aware of this regardless in case you had anything to add 😃

Copy link
Collaborator

@stefanunity stefanunity left a comment

Choose a reason for hiding this comment

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

OK, given we don't have a repro for it.

@graham-huws graham-huws requested a review from ekcoh May 16, 2024 09:51
@graham-huws
Copy link
Collaborator Author

N.B. tvos failure is also happening on develop branch.

Copy link
Collaborator

@ekcoh ekcoh left a comment

Choose a reason for hiding this comment

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

LGTM

- Fixed Composite binding isn't triggered after ResetDevice() called during Action handler [ISXB-746](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-746)

### Fixed
- Avoid potential crashes from NullReferenceException in FireStateChangeNotifications.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Minor: Use code formatting quotes, e.g. NullReferenceException in FireStateChangeNotifications.


### Fixed
- Avoid potential crashes from NullReferenceException in FireStateChangeNotifications.
- Fixed Composite binding isn't triggered after ResetDevice() called during Action handler [ISXB-746](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-746).
Copy link
Collaborator

Choose a reason for hiding this comment

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

I would suggest rewriting this to explain the actual problem in a more readable sentence than copying the subject of the ticket, e.g.
"Fixed an issue where a composite binding would not be consecutively triggered after ResetDevice() has been called from the associated action handler." + link as currently.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe not part of your PR but would be good to address. Also noticed fixe lines below lack full stop at the end.

@@ -86,7 +86,7 @@ public struct GamepadState : IInputStateTypeInfo
internal const string ButtonSouthShortDisplayName = "Cross";
internal const string ButtonNorthShortDisplayName = "Triangle";
internal const string ButtonWestShortDisplayName = "Square";
internal const string ButtonEastShortDisplayName = "East";
internal const string ButtonEastShortDisplayName = "Circle";
Copy link
Collaborator

Choose a reason for hiding this comment

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

Good catch, but realize this is solved in a very platform-dependent way in what is supposed to be platform-agnostic code. Will feed this into a doc I am creating on the subject.

@@ -349,14 +349,28 @@ private unsafe bool ProcessStateChangeMonitors(int deviceIndex, void* newStateFr

internal unsafe void FireStateChangeNotifications(int deviceIndex, double internalTime, InputEvent* eventPtr)
{
Debug.Assert(m_StateChangeMonitors != null);
Debug.Assert(m_StateChangeMonitors.Length > deviceIndex);
if (m_StateChangeMonitors == null)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think this is better, good change.

@graham-huws graham-huws merged commit 5016d79 into develop May 24, 2024
76 of 78 checks passed
@graham-huws graham-huws deleted the ISXB-724-android-state-change-notif-crash branch May 24, 2024 10:13
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.

None yet

3 participants