Skip to content

Perf: Don't do raycasts for the GazeProvider if it's behavior is set …#10340

Merged
RogPodge merged 10 commits into
microsoft:prerelease/2.8.0from
jverral:user/joverral/opt_gazebehavior
May 16, 2022
Merged

Perf: Don't do raycasts for the GazeProvider if it's behavior is set …#10340
RogPodge merged 10 commits into
microsoft:prerelease/2.8.0from
jverral:user/joverral/opt_gazebehavior

Conversation

@jverral

@jverral jverral commented Nov 24, 2021

Copy link
Copy Markdown
Contributor

…to off.

Overview

Was noting some perf hits in the profiler in our project w/ Gaze...when we set the behavior to AlwaysOff.

Changes

  • Fixes: # .

Verification

This optional section is a place where you can detail the specific type of verification
you want from reviewers. For example, if you want reviewers to checkout the PR locally
and validate the functionality of specific scenarios, provide instructions
on the specific scenarios and what you want verified.

If there are specific areas of concern or question feel free to highlight them here so
that reviewers can watch out for those issues.

As a reviewer, it is possible to check out this change locally by using the following
commands (substituting {PR_ID} with the ID of this pull request):

git fetch origin pull/{PR_ID}/head:name_of_local_branch

git checkout name_of_local_branch

@keveleigh

Copy link
Copy Markdown
Contributor

/azp run

@keveleigh keveleigh added this to the MRTK 2.x future milestone Nov 24, 2021
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 2 pipeline(s).

@@ -578,7 +578,7 @@ private void UpdateGazeProvider()
{
// The gaze hit result may be populated from the UpdatePointers call. If it has not, then perform

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is an interesting one. This second pass was introduced to ensure an app could always query what the head/eyes were targeting regardless of if the MRTK input system would send events over it. This change would be a behavioral breaking change if apps are relying on this info while setting the gaze pointer to always be off.

On the other hand...setting the gaze pointer to be always off could imply that it will never be used for anything. Maybe we can take this change and heavily document the meaning.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Building on this comment: we specifically have tests that ensure the assertion I made above is true, which this PR is failing:
image

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Seems like maybe the gaze target should be something lazy evaluated, especially if the behavior is set to AlwaysOff.

@david-c-kline david-c-kline self-assigned this Feb 23, 2022
@david-c-kline

Copy link
Copy Markdown

Perhaps add an optional "dont raycast if gaze pointer is off" option.

Also, @jverral, how much time does this save?

@jverral jverral requested a review from RogPodge as a code owner May 16, 2022 06:30
@RogPodge RogPodge changed the base branch from main to prerelease/2.8.0 May 16, 2022 06:30
@RogPodge

Copy link
Copy Markdown
Contributor

Made some changes to better indicate the way we intend users to disable gaze provider raycasts, i.e. directly disabling the gaze provider component. The inspector changes + updated doc comments should be sufficient for addressing this issue

@RogPodge

Copy link
Copy Markdown
Contributor

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 2 pipeline(s).

Comment thread Assets/MRTK/Core/Inspectors/Profiles/MixedRealityPointerProfileInspector.cs Outdated
Comment thread Assets/MRTK/Core/Interfaces/InputSystem/IPointerPreferences.cs Outdated
{
using (UpdateGazeProviderPerfMarker.Auto())
{
bool gazeProviderEnabled = (CoreServices.InputSystem.GazeProvider?.Enabled).GetValueOrDefault(false);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Do you think there's anywhere reasonable to cache the input system or the gaze provider in this class? And maybe update the cache if something goes null, but otherwise I'm not sure we need to re-query every frame. Could get expensive 😬

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Cached it as much as possible without storing it at top level, since it doesn't look like we follow that pattern anywhere else in code.

Comment thread Assets/MRTK/Core/Interfaces/InputSystem/IPointerPreferences.cs Outdated
Comment thread Assets/MRTK/Services/InputSystem/FocusProvider.cs Outdated
Comment thread Assets/MRTK/Services/InputSystem/FocusProvider.cs Outdated
Comment thread Assets/MRTK/Services/InputSystem/FocusProvider.cs Outdated
@RogPodge

Copy link
Copy Markdown
Contributor

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 2 pipeline(s).

@RogPodge

Copy link
Copy Markdown
Contributor

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 2 pipeline(s).

@RogPodge RogPodge merged commit 48aa466 into microsoft:prerelease/2.8.0 May 16, 2022
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.

4 participants