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

Proposal: Add tracing/tooling to aid in tracking focus state changes #3479

Open
kmelmon opened this issue Oct 24, 2020 · 2 comments
Open

Proposal: Add tracing/tooling to aid in tracking focus state changes #3479

kmelmon opened this issue Oct 24, 2020 · 2 comments
Labels
area-FocusManager Focus APIs such as Control.Focus(), FocusManager.Try[Move]Focus[Async], keyboarding with [shift+]tab feature proposal New feature proposal needs-winui-3 Indicates that feature can only be done in WinUI 3.0 or beyond. (needs winui 3) team-Reach Issue for the Reach team

Comments

@kmelmon
Copy link
Contributor

kmelmon commented Oct 24, 2020

Proposal: Add tracing/tooling to aid in tracking focus state changes

Summary

This came out of root causing microsoft/react-native-windows#6181
To debug this issue, I had to manually debug through FocusManager code, which is very time consuming and requires deep knowledge of the focus code. There are many scenarios (eg TabFocusNavigation behavior, apps changing focus in the middle of getting focus, etc), and no tooling to make the debugging process easier.

I am proposing adding tracing or other tooling to shed light on the process FocusManager goes through when focus is being changed. This tooling would shed light on why a given control is being given focus, thus making it easier to understand what factors influenced the algorithm, allowing customers to fix or workaround problems where focus is not working as expected.

Rationale

  • Customers can unblock themselves when encountering issues
  • Time saver for the dev team

Scope

Capability Priority
This proposal will allow developers to more easily understand why a given control is receiving focus without debugging FocusManager code Must

Important Notes

Open Questions

@kmelmon kmelmon added the feature proposal New feature proposal label Oct 24, 2020
@ghost ghost added the needs-triage Issue needs to be triaged by the area owners label Oct 24, 2020
@ranjeshj ranjeshj added the team-Reach Issue for the Reach team label Oct 26, 2020
@ranjeshj
Copy link
Contributor

Sounds like a great idea. The two tools I have found useful in the past are to put breakpoints in the framework code and adding a page level FocusChanged event to trace out who got focus.

@Austin-Lamb
Copy link

Lack of visibility into focus's more complex cases has been a sore point for many users, I agree this is a good feature proposal to have on the backlog.

As a mitigation, one thing that exists now is a set of static events on FocusManager which can tell you about any focus change occurring on the thread - even if they're in unparented popups, where you wouldn't have a good place to listen to a bubbling focus event from UIElement.

Each of these static events has an EventArgs that has a 'CorrelationId' property which is a GUID. This ID is uniquely created when a focus movement operation begins - then as focus meanders through various controls, maybe being redirected as it goes, this ID remains constant so you can tie all the events together in your own logging/debugging. Then, when focus terminates in a new place, that ID is discarded and the next time focus moves we'll create another GUID.

So, that can be one helpful way to debug focus, though it's not great or easy. But at least it's something while this remains on the backlog.

@Austin-Lamb Austin-Lamb added area-FocusManager Focus APIs such as Control.Focus(), FocusManager.Try[Move]Focus[Async], keyboarding with [shift+]tab needs-winui-3 Indicates that feature can only be done in WinUI 3.0 or beyond. (needs winui 3) and removed needs-triage Issue needs to be triaged by the area owners labels Jan 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-FocusManager Focus APIs such as Control.Focus(), FocusManager.Try[Move]Focus[Async], keyboarding with [shift+]tab feature proposal New feature proposal needs-winui-3 Indicates that feature can only be done in WinUI 3.0 or beyond. (needs winui 3) team-Reach Issue for the Reach team
Projects
None yet
Development

No branches or pull requests

3 participants