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

8329667: [macos] Issue with JTree related fix for JDK-8317771 #19255

Closed
wants to merge 4 commits into from

Conversation

azuev-java
Copy link
Member

@azuev-java azuev-java commented May 16, 2024

Caching children and selected children of the thee on the native level;
Caching all children of a specific parent in CAccessibility to enhance recursive children selection algorithm;
Removing fix for JDK-8317771 as no longer needed;


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-8329667: [macos] Issue with JTree related fix for JDK-8317771 (Bug - P3)

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 19255

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

Using diff file

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

Webrev

Link to Webrev Comment

Caching children and selected children of the thee on the native level;
Caching all children of a specific parent in CAccessibility to enhance recursive children selection algorythm;
Removing fix for JDK-8317771 as no longer needed;
@bridgekeeper
Copy link

bridgekeeper bot commented May 16, 2024

👋 Welcome back kizune! 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 16, 2024

@azuev-java 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:

8329667: [macos] Issue with JTree related fix for JDK-8317771

Reviewed-by: asemenov, abhiscxk, psadhukhan

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 181 new commits pushed to the master branch:

  • 239c1b3: 8332807: Parallel: Make some APIs in ParMarkBitMap private
  • 9b61a76: 8332615: RISC-V: Support vector unsigned comparison instructions for machines with RVV
  • a71b404: 8331398: G1: G1HeapRegionPrinter reclamation events should print the original region type
  • af056c1: 8332106: VerifyError when using switch pattern in this(...) or super(...)
  • da3001d: 8331975: Enable case-insensitive check in ccache and keytab entry lookup
  • 424eb60: 8331683: Clean up GetCarrierThread
  • 9b1d6d6: 8316328: Test jdk/jfr/event/oldobject/TestSanityDefault.java times out for some heap sizes
  • f8a3e4e: 8328998: Encoding support for Intel APX extended general-purpose registers
  • ddd73b4: 8332082: Shenandoah: Use consistent tests to determine when pre-write barrier is active
  • 0a9d1f8: 8332749: Broken link in MemorySegment.Scope.html
  • ... and 171 more: https://git.openjdk.org/jdk/compare/2d622152b07bba0aba8fd5b1e24293e28d6e69f5...master

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 openjdk bot added the rfr Pull request is ready for review label May 16, 2024
@openjdk
Copy link

openjdk bot commented May 16, 2024

@azuev-java 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.

@mlbridge
Copy link

mlbridge bot commented May 16, 2024

Webrevs

@victordyakov
Copy link

victordyakov commented May 16, 2024

@savoptik @kumarabhi006 @prsadhuk please review

NSMutableArray<id<NSAccessibilityRow>> *rowCache;
BOOL rowCacheValid;
NSMutableArray<id<NSAccessibilityRow>> *selectedRowCache;
BOOL selectedRowCacheValid;
Copy link
Contributor

Choose a reason for hiding this comment

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

And can we use a single array for the cache in the same way as we do in Table Accessibility?

Copy link
Member Author

Choose a reason for hiding this comment

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

They have different meanings and different content - plus selection being requested by OS much more frequently. And we do not want to invalidate the whole rows cache when selection changes - otherwise it will be pretty costly.

@@ -349,6 +349,9 @@ - (void)postSelectedTextChanged
- (void)postSelectionChanged
{
AWT_ASSERT_APPKIT_THREAD;
if ([self respondsToSelector:NSSelectorFromString(@"invalidateSelectionCache")]) {
Copy link
Contributor

Choose a reason for hiding this comment

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

You can override this method for the tree. to avoid checking the selector support... This is a time-consuming procedure.

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure.

- Rolled back changes to the CommonComponentAccessibility and added relevant post*
methods overrides to the OutlineAccessibility.
@@ -39,7 +39,9 @@
import java.lang.reflect.Constructor;
Copy link
Contributor

Choose a reason for hiding this comment

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

Please remove unused import import javax.swing.tree.TreePath;.

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed.

[super postTreeNodeExpanded];
}

- (void)postSelectedCellsChanged
Copy link
Contributor

Choose a reason for hiding this comment

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

Does OutlineRowAccessibility use CellAccessibility?

Copy link
Member Author

Choose a reason for hiding this comment

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

It does not - i am just covering all methods that can be potentially called on the table-like controls. It does no harm to override method that will never be called. But it will cause some discrepancies in the behavior if some custom control will call this notification and we fail to update the selection cache accordingly.

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
It seems to me that it would be a good idea to do the same for lists.


- (BOOL)isCacheValid
{
if (rowCacheValid && [[self parent] respondsToSelector:NSSelectorFromString(@"isCacheValid")]) {
Copy link
Contributor

Choose a reason for hiding this comment

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

When isCacheValid is invoked for the first time then rowCacheValid is FALSE and we return FALSE value from this method and then the accessibilityChildren method from super class is invoked to get all children and store them in an array(rowCache). Subsequently rowCacheValid will be set to TRUE.

As per my understanding [[self parent] respondsToSelector:NSSelectorFromString(@"isCacheValid")] condition will be checked only if rowCacheValid is true and once we have a valid array of children then what is the point of checking isCacheValid method in parent ?

Copy link
Member Author

Choose a reason for hiding this comment

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

In multilevel trees when someone in the parent's path is collapsed the treeCollapsed event will be delivered to that node. We can either invalidate all leaf nodes caches (which is costly) or mark that exact node's cache as invalid and when the expand will happen when a11y cursor will try to position inside one of the childrens it will check that parent was invalidated and will regenerate its own cache.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok.
Is it possible to add a test to verify this behavior?

Copy link
Member Author

Choose a reason for hiding this comment

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

The test would be manual and it is hard to even describe what is the result of the test should look or sound like since we do not provide any string messages, VoiceOver does it and we can not tell ahead how it will be put. And for multilivel trees i am just running the SwingSet2 JTree demo and see that VoiceOver correctly handles full/partial collapse and expand - that after that there are no anomalies like VO output does not correspond to where cursor actually positioned.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok. I was thinking of something like when nodes are collapsed or expanded then can we log some output like Children are valid or invalid.
Otherwise I have tested the fix with swingset2 demo and the test mentioned in JDK-8320664 which behaves fine with the fix.


- (nullable NSArray<id<NSAccessibilityRow>> *)accessibilityChildren
{
if (![self isCacheValid]) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why can't we use rowCacheValid value to check like it is done for accessibilitySelectedChildren method?

Copy link
Member Author

Choose a reason for hiding this comment

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

Again - to cover the situation where expand/collapse events were delivered to the parent node. Or to the parent's parent.

…no effect but it is more uiform and according to the ObjectibeC convention where objects are referred as nil and references to the primitives as NULL.
Copy link
Contributor

@kumarabhi006 kumarabhi006 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 to me.

[self invalidateSelectionCache];
[super postSelectedCellsChanged];
}

Copy link
Contributor

Choose a reason for hiding this comment

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

It seems to me that it is also worth defining a destructor that will destroy the cache before destroying the instance.

Copy link
Member Author

Choose a reason for hiding this comment

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

The problem is that on Java side we are notified when the accessibility is being enabled but we have no notification of when it is no longer used so we do not deliberately release native peers and in my testing even when i add dealloc function to the class it is never being called.

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.

Ok.

Copy link
Contributor

@prsadhuk prsadhuk left a comment

Choose a reason for hiding this comment

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

I hope you have ran the whole gamut of jtreg tests, if not, please do it before integrating and SwingSet2 too..

@openjdk openjdk bot added the ready Pull request is ready to be integrated label May 24, 2024
@azuev-java
Copy link
Member Author

Of course i did all the tests - just to be on the safe side i rerun all of available tests on the latest changeset and got 100% pass rate.

@azuev-java
Copy link
Member Author

/integrate

@openjdk
Copy link

openjdk bot commented May 25, 2024

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

  • 7bf1989: 8320575: generic type information lost on mandated parameters of record's compact constructors
  • 253508b: 8332303: Better JMX interoperability with older JDKs, after removing Subject Delegation
  • ebc520e: 8332841: GenShen: Pull shared members from control thread into common base class
  • 236432d: 8332084: Ensure JdkConsoleImpl.restoreEcho visibility in a shutdown hook
  • b3b3366: 8332631: Update nsk.share.jpda.BindServer to don't use finalization
  • f66a586: 8332641: Update nsk.share.jpda.Jdb to don't use finalization
  • cd3e4c0: 8326734: text-decoration applied to lost when mixed with or
  • c2cca2a: 8330647: Two CDS tests fail with -UseCompressedOops and UseSerialGC/UseParallelGC
  • 6d2aeb8: 8332745: Method::is_vanilla_constructor is never used
  • cfdc64f: 8331291: java.lang.classfile.Attributes class performs a lot of static initializations
  • ... and 186 more: https://git.openjdk.org/jdk/compare/2d622152b07bba0aba8fd5b1e24293e28d6e69f5...master

Your commit was automatically rebased without conflicts.

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

openjdk bot commented May 25, 2024

@azuev-java Pushed as commit 05f13e7.

💡 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 [email protected] integrated Pull request has been integrated
5 participants