Skip to content

Load Chromium virtual buffer on state_system_busy#13851

Merged
feerrenrut merged 2 commits into
masterfrom
loadVbufStateSystemBusy
Jul 12, 2022
Merged

Load Chromium virtual buffer on state_system_busy#13851
feerrenrut merged 2 commits into
masterfrom
loadVbufStateSystemBusy

Conversation

@feerrenrut

Copy link
Copy Markdown
Contributor

Link to issue number:

Fixes: #13306

Summary of the issue:

Chromium devs wish to be able to communicate that a document is loading via MSAA STATE_SYSTEM_BUSY exposed via IA2

This prevents NVDA from loading a virtual buffer until the document is no longer considered busy. The definition of STATE_SYSTEM_BUSY is:

The control cannot accept input at this time.

This will introduce special handling for Chromium based browsers, but will match the existing behavior for Firefox.

Description of user facing changes

There should be no observable change in the behavior of NVDA when used with Chrome.

Description of development approach

  • Return a valid TreeInterceptor class from _get_treeInterceptorClass even when the document has STATE_SYSTEM_BUSY.
  • Introduce a feature flag to allow disabling this behavior.
  • Streamline the process of creating new feature flags. Provide reusable classes to help future flags be more consistent.

Testing strategy:

  • Ask Chromium devs to test with an NVDA try build.
  • Allow users to test when the change is introduced to Chromium in the future (after this change reaches a majority of NVDA users)
  • Rely on the feature flag for users to be able to disable this if there are problems.

Known issues with pull request:

None

Change log entries:

None

Code Review Checklist:

  • Pull Request description:
    • description is up to date
    • change log entries
  • Testing:
    • Unit tests
    • System (end to end) tests
    • Manual testing
  • API is compatible with existing add-ons.
  • Documentation:
    • User Documentation
    • Developer / Technical Documentation
    • Context sensitive help for GUI changes
  • UX of all users considered:
    • Speech
    • Braille
    • Low Vision
    • Different web browsers
    • Localization in other languages / culture than English

@feerrenrut feerrenrut marked this pull request as ready for review June 29, 2022 03:31
@feerrenrut feerrenrut requested a review from a team as a code owner June 29, 2022 03:31
@feerrenrut feerrenrut requested a review from seanbudd June 29, 2022 03:31
@AppVeyorBot

This comment was marked as outdated.

@feerrenrut feerrenrut marked this pull request as draft June 29, 2022 05:23
@AppVeyorBot

This comment was marked as outdated.

@feerrenrut

Copy link
Copy Markdown
Contributor Author

Not sure why that selection of chrome tests failed, I ran the build again an they passed.

@feerrenrut feerrenrut marked this pull request as ready for review June 29, 2022 10:13
Comment thread devDocs/featureFlags.md Outdated
Comment thread source/NVDAObjects/__init__.py Outdated
Comment thread source/config/featureFlag.py Outdated
Comment thread tests/unit/test_config.py

@seanbudd seanbudd left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

There's a few minor comments but the approach generally looks good.

General question: would it be more appropriate to add the feature flag design into a separate PR?

Comment thread devDocs/featureFlags.md Outdated
Comment thread source/config/configSpec.py Outdated
Comment thread source/config/__init__.py
Comment thread source/config/__init__.py Outdated
Comment thread source/config/featureFlag.py Outdated
Comment thread source/gui/nvdaControls.py Outdated
Comment thread tests/unit/test_config.py Outdated
Comment thread tests/unit/test_config.py Outdated
Comment thread tests/unit/test_config.py Outdated
Comment thread tests/unit/test_config.py Outdated
@seanbudd

Copy link
Copy Markdown
Member

I think it would be good to have another issue to convert other feature flags to use the new API. We could also consider converting other boolean flags to become feature flags.

@feerrenrut

Copy link
Copy Markdown
Contributor Author

General question: would it be more appropriate to add the feature flag design into a separate PR?

I considered this, but thought it really needs to be paired with context given by usage. I could implement the feature flag "the old way", then follow up with a PR to upgrade it to the new way. That would allow for independent reverts if required.

But given the virtual buffer change is so small, I figured reverting that manually in a new commit is fairly easy.

@feerrenrut feerrenrut force-pushed the loadVbufStateSystemBusy branch 2 times, most recently from 1f8c6f9 to 937266c Compare June 30, 2022 09:22
@feerrenrut

Copy link
Copy Markdown
Contributor Author

Apologies to reviewers for confusing PR diff. I have addressed all feedback for the virtual buffer change in this PR, see commit:
4bdb855

I'll create a new PR to add the feature flag for this config.
The config will change key slightly (case of vbuf) as per review comment , which for alpha users means they will not have an error if using one version then the next.

This PR intentionally doesn't make the value configurable via a GUI, the intention being to reduce wasted effort. In the worst case we could always direct users to manually update the config value.

@feerrenrut feerrenrut mentioned this pull request Jun 30, 2022
5 tasks
@feerrenrut

Copy link
Copy Markdown
Contributor Author

See #13859 and commit 7ac7eaf for further review actions.

@AppVeyorBot

This comment was marked as outdated.

@seanbudd

seanbudd commented Jul 1, 2022

Copy link
Copy Markdown
Member

The config will change key slightly #13851 (comment) , which for alpha users means they will not have an error if using one version then the next.

This can be avoided if we don't let the first PR build complete (e.g. cancel subsequent builds) until both PRs are merged.

Comment thread source/NVDAObjects/IAccessible/chromium.py Outdated
@feerrenrut

Copy link
Copy Markdown
Contributor Author

This can be avoided if we don't let the first PR build complete (e.g. cancel subsequent builds) until both PRs are merged.

Yes. But I think it's an acceptable outcome if there are separate builds. It is confusing to have two similarly named config settings, but that's the worst of the impact (vs an error on config load and config gets reset to default)

@AppVeyorBot

This comment was marked as outdated.

feerrenrut added a commit that referenced this pull request Jul 12, 2022
- This is the default behavior
- Update changes file for PR #13851
@feerrenrut feerrenrut force-pushed the loadVbufStateSystemBusy branch from 712adb2 to 8ef45ec Compare July 12, 2022 07:59
@AppVeyorBot

Copy link
Copy Markdown

See test results for failed build of commit 253ac40d93

- This is the default behavior
- Update changes file for PR #13851
@feerrenrut feerrenrut force-pushed the loadVbufStateSystemBusy branch from 8ef45ec to 1bcd5d4 Compare July 12, 2022 09:32
See base PR #13851
Adds support for multi value feature flags from PR #13871

### Summary:
NVDA increasingly makes use of feature flags to expose experimental changes to users.
There are already several approaches already in use.
It is easy to miss use-cases for changing default behavior, potentially overriding an advanced users preferred config.

Some feature flags require more than just a Boolean enabled/disabled outcome (in addition to 'default'), E.G.:
- AllowUiaInMSWord [WHEN_NECESSARY, WHERE_SUITABLE, ALWAYS]
- AllowUiaInChromium [WHEN_NECESSARY, YES, NO]

Several approaches have been tried:
- Store an int in the config that match with enum values, as per (AllowUiaInMSWord and AllowUiaInChromium)
- Use "options" in config (several string values). Literal strings in code to compare refer to these.

These approaches can hide errors:
- Looking at the config, what are the valid values when an integer is used.
- Using string "options":
  - What are the valid options?
  - How do you find all usages?
  - Change the strategy for default?
- For both, when looking at the config or configSpec, how can the behavior of default be determined?

### Description of user facing changes
The target user of this change are developers.
This introduces constructs and utilities to streamline the approach to adding feature flags.

Adding a new feature flag:
- Most feature flags can use the BoolFlag.
- If more values are required, define a new enum class in featureFlagEnums.py (include a DEFAULT member) E.G.: MyNewFeature
- Add the entry to the configSpec.py E.G.
  shouldUseMyNewFeature = featureFlag(optionsEnumClass="MyNewFeature", behaviorOfDefault="ON_WEEKENDS")
- Add a GUI option for it, using FeatureFlagCombo
- Wrap the code for the feature with:
   config.conf["section"]["shouldUseMyNewFeature "] == MyNewFeature.ON_WEEKENDS

### Development approach
Introduction of a generic BoolFlag type (enabled/disabled) which needs to account for 3 states:
- The current NVDA default (IE user has no preference)
- User has a preference of enabled
- User has a preference of disabled

To facilitate this, one of the three values (default, enabled, disabled) is stored in the config.
Spec/config transformations are provided to streamline the support.
A featureFlag type in the spec is automatically converted to a FeatureFlag class instance.
The FeatureFlag class abstracts the consideration of "default", allowing the FeatureFlag to treated as a boolean within internal NVDA logic.

A utility GUI control is added which presents the FeatureFlag option to the user, and allows developers to give translated names to the logical values (enabled, disabled), the name for default incorporates the behaviorOfDefault (and is also translated).

Note:
- The configSpec explicitly defines what the behavior of default is.
- The enum class that backs the config is defined, allows for type / value checking.
- Existing flags have not been upgraded, these would require upgrade code for the config, this introduces unnecessary complexity.

### Known issues:
This approach bypasses the handling for defaults provided by configObj.
It was considered whether the default not written on read behavior (of the configObj library) to facilitate the third (default) state.
However:
- This would require explicit code to test for the existence of the key to know if the value returned by `conf["section"]["myKey"]` was just the default or an explicit setting.
- It also requires careful diligence to ensure that the value is not ever written accidentally.
- Code to delete the key is required whenever attempting to return to the default.
- The way validation checks are created in `configObj` makes transforming the type (to provide an abstraction) difficult. It is not possible to get access to the `default` without a similar approach used in this PR. If adopting the complexity of a spec and config transform step, then it is preferable to have explicit values for default. Explicit values make the config easier to inspect and make the approach more robust.
@feerrenrut feerrenrut merged commit 9172c09 into master Jul 12, 2022
@feerrenrut feerrenrut deleted the loadVbufStateSystemBusy branch July 12, 2022 10:38
@nvaccessAuto nvaccessAuto added this to the 2022.3 milestone Jul 12, 2022
- 'behaviorOfDefault'
- 'optionsEnum'
"""
log.info(f"specString: {specString}, kwargs: {kwargs}")

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.

Why is this log present at info level? The logged message is not self-explaining.

If it is a debug log needed only for this PR's development, it should be removed. If it has any added value to for future debug, it may be kept at debug level and maybe with a more explicit message on its goal. If there is a justification to keep it at a so high level could you please elaborate?

@feerrenrut , @seanbudd, any idea?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This should probably be debug level or removed

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.

Yes, I'll remove this. It was helpful for debugging during development.

seanbudd pushed a commit that referenced this pull request Aug 5, 2022
Summary of the issue:
A log message used during development was left in PR #13851

Description of user facing changes
Reduces noise in the NVDA.log

Description of development approach
Removed the logging of this message.
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.

Create virtual buffer for Chrome content even if STATE_SYSTEM_BUSY is present

6 participants