Skip to content

Conversation

@kumarabhi006
Copy link
Contributor

@kumarabhi006 kumarabhi006 commented May 27, 2025

VoiceOver announce incorrect number of child for a submenu of JPopupMenu when it is visible for the first time only. After that VO is able to announce the number of items correctly.

Issue: Problem is with the a11y subsystem method call to get the accessible children details.

Analysis: When the Submenu of a JPopupMenu is opened, accessible component of PopupMenu is created dynamically in the native side implementation and PostMenuOpened notification is sent to the a11y subsystem for the newly created PopupMenu. Once the notification is sent to a11y sub-system, it invokes the accessibilityChildren method to get the children details for the menu component. A11y subsystem always retrieve the information of the root level PopupMenu irrespective of the submenu's PopupMenu (PopupMenu is associated with each JMenu) and thus announce the root level PopupMenu child count which is incorrect.

Proposed Fix: Proposed fix is to ensure the correct child details are sent back to a11y sub-system for correct announcement. So, whenever the accessibilityChildren method is invoked, first try to find out the current accessible PopupMenu which is opened for the Submenu and then return the child details.

Testing : Manual test case is attached to verify the fix and there is no failure with fix in CI pipeline.

Current fix also ensures the correct child counts are announced for the JMenu's Submenu which are present in the JMenubar.

Note : While verifying the fix, a new issue is unearthed for multi-level submenu where VO is failed to announce the Submenu's text. Since the issue exists without the proposed fix too, it shall be treated as a new bug finding and will raise a separate JBS issue.


Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue

Issue

  • JDK-8341311: [Accessibility,macOS,VoiceOver] VoiceOver announces incorrect number of items in submenu of JPopupMenu (Bug - P3)

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/25470/head:pull/25470
$ git checkout pull/25470

Update a local copy of the PR:
$ git checkout pull/25470
$ git pull https://git.openjdk.org/jdk.git pull/25470/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 25470

View PR using the GUI difftool:
$ git pr show -t 25470

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/25470.diff

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented May 27, 2025

👋 Welcome back abhiscxk! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk
Copy link

openjdk bot commented May 27, 2025

@kumarabhi006 This change now passes all automated pre-integration checks.

ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details.

After integration, the commit message for the final commit will be:

8341311: [Accessibility,macOS,VoiceOver] VoiceOver announces incorrect number of items in submenu of JPopupMenu

Reviewed-by: asemenov, kizune

You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

At the time when this comment was updated there had been 65 new commits pushed to the master branch:

As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.

➡️ To integrate this PR with the above commit message to the master branch, type /integrate in a new comment.

@openjdk
Copy link

openjdk bot commented May 27, 2025

@kumarabhi006 The following label will be automatically applied to this pull request:

  • client

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command.

@openjdk openjdk bot added the client client-libs-dev@openjdk.org label May 27, 2025
@kumarabhi006
Copy link
Contributor Author

@azuev-java Please review the proposed fix.

@kumarabhi006
Copy link
Contributor Author

/dummy

@openjdk openjdk bot added the rfr Pull request is ready for review label May 27, 2025
@openjdk
Copy link

openjdk bot commented May 27, 2025

@kumarabhi006 Unknown command dummy - for a list of valid commands use /help.

@mlbridge
Copy link

mlbridge bot commented May 27, 2025

Webrevs

* @run main/manual TestPopupMenuChildCount
*/

public class TestPopupMenuChildCount {
Copy link
Member

Choose a reason for hiding this comment

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

Nitpick: as far as I understand, this is for macOS only. Do you think it would make more sense to have a name mention that the test is Mac only? The same for test description. Seems to me a bit confusing otherwise

It's fine with me if you leave it as it is though.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This test is only for macOS and that is conveyed through the jtreg tag here. I don't think test name needs to be changed.

Although it is not essentially required but will update the test summary and instruction.

Copy link
Contributor

Choose a reason for hiding this comment

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

This test is only for macOS and that is conveyed through the jtreg tag here. I don't think test name needs to be changed.

Although it is not essentially required but will update the test summary and instruction.

It seems to me that this test should be generalized for all a11y platforms, since it is a regression test and can help identify regression of this functionality on other platforms.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The behaviour on Windows with a11y clients (JAWS or NVDA) is different. They don't announce the child count for the menu and submenus for java application and it is similar to the native application (notepad++) too.

So, the regression test restricted for macOS seems suitable for now.

AccessibleContext ac = a.getAccessibleContext();
if (ac != null) {
Accessible aComp = null;
for (int i = 0; i < ac.getAccessibleChildrenCount(); i++) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I suggest replacing for with while. If the desired submenu is at the beginning of the list, there’s no need to traverse it further.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think even though the submenu is at the beginning but if it is not visible then we need to traverse further to check for other submenu if present.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Optimized the code to not traverse further if the desired submenu is fetched. Verified the recent change with the test code.

Copy link
Contributor

Choose a reason for hiding this comment

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

Optimized the code to not traverse further if the desired submenu is fetched. Verified the recent change with the test code.

You could, of course, put this in the while condition, but this way is also fine.

JNIEnv *env = [ThreadUtilities getJNIEnv];
GET_CACCESSIBILITY_CLASS_RETURN(nil);
DECLARE_STATIC_METHOD_RETURN(sjm_getCurrentAccessiblePopupMenu, sjc_CAccessibility,
"getCurrentAccessiblePopupMenu",
Copy link
Contributor

Choose a reason for hiding this comment

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

Won’t it be possible to get the correct object like this, as it’s done in outlineRowAccessibility.m?

jobject currentAccessible = [self currentAccessibleWithENV:env];

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I tried to utilize this method but getCurrentAccessiblePopupMenu throws NPE.
java.lang.NullPointerException: Cannot invoke "sun.swing.SwingAccessor$AccessibleComponentAccessor.getCurrentAccessible(javax.accessibility.AccessibleContext)" because the return value of "sun.swing.SwingAccessor.getAccessibleComponentAccessor()" is null

Copy link
Contributor

@savoptik savoptik left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@azuev-java azuev-java left a comment

Choose a reason for hiding this comment

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

Looks good.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label May 29, 2025
@kumarabhi006
Copy link
Contributor Author

Note : While verifying the fix, a new issue is unearthed for multi-level submenu where VO is failed to announce the Submenu's text. Since the issue exists without the proposed fix too, it shall be treated as a new bug finding and will raise a separate JBS issue.

@azuev-java @savoptik Created a new JBS bug JDK-8358121 to track the multi level submenu text announcement issue

@kumarabhi006
Copy link
Contributor Author

/integrate

@openjdk
Copy link

openjdk bot commented May 30, 2025

Going to push as commit e33eeee.
Since your change was applied there have been 77 commits pushed to the master branch:

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label May 30, 2025
@openjdk openjdk bot closed this May 30, 2025
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels May 30, 2025
@openjdk
Copy link

openjdk bot commented May 30, 2025

@kumarabhi006 Pushed as commit e33eeee.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

client client-libs-dev@openjdk.org integrated Pull request has been integrated

Development

Successfully merging this pull request may close these issues.

4 participants