InputSystem icon indicating copy to clipboard operation
InputSystem copied to clipboard

FIX: JsonParser / ParseStringValue now creates unescaped strings

Open AlexTyrer opened this issue 1 year ago • 0 comments

Description

Comparing escaped and non-escaped strings is very slow - this happens when devices are deactivated/reactivated such as when the Quest2 headset and controllers enter and awake from sleep mode.

The high cost comes from having to compare each string character-by-character (skipping '' escapes) each time entering the C# runtime to perform System.Globalization.ToUpperInvariant.

Changes made

This change to TryMatchDisconnectedDevice() means that any parsed strings that contain escape characters are converted to non-escaped strings for much quicker comparison.

This saves approximately 0.5ms / frame when an Oculus headset or controller is reactivated.

Testing

Local testing with the Quest2 headset and controllers using Superluminal to capture the cost of device awakening.

Risk

We allocate a temporary string where before we did not.

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 %<ID>%). 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.

AlexTyrer avatar Aug 19 '24 08:08 AlexTyrer