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

8275720: CommonComponentAccessibility.createWithParent isWrapped causes mem leak #6081

Closed
wants to merge 2 commits into from

Conversation

forantar
Copy link
Contributor

@forantar forantar commented Oct 22, 2021

This is a reimplementation of the isWrapped logic in the method:

+[CommonComponentAccessibility createWithParent:accessible:role:index:withEnv:withView:isWrapped:]

The isWrapped arg was used to create an a11y element which is wrapped into an object that does not have direct peer in Java (like ListRowAccessibility, TableRowAccessibility). The problem is that such objects leak, because when the wrapped element is created (isWrapped == YES), the native pointer to the element is rewritten in the associated java peer (the accessible arg) and the element object is then released via the CFRetainedResource mechanism. However the wrapping object (ListRowAccessibility, TableRowAccessibility) is never released.

This fix proposes a dedicated class for creating such paired objects, where a wrapper object releases its wrapped child when the deallocation is triggered by garbage collecting the associated java peer.


Progress

  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • Change must be properly reviewed

Issue

  • JDK-8275720: CommonComponentAccessibility.createWithParent isWrapped causes mem leak

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.java.net/jdk pull/6081/head:pull/6081
$ git checkout pull/6081

Update a local copy of the PR:
$ git checkout pull/6081
$ git pull https://git.openjdk.java.net/jdk pull/6081/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 6081

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

Using diff file

Download this PR as a diff file:
https://git.openjdk.java.net/jdk/pull/6081.diff

@bridgekeeper
Copy link

bridgekeeper bot commented Oct 22, 2021

👋 Welcome back ant! 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 openjdk bot changed the title 8275720: CommonComponentAccessibility.createWithParent isWrapped caus… 8275720: CommonComponentAccessibility.createWithParent isWrapped causes mem leak Oct 22, 2021
@openjdk openjdk bot added the rfr Pull request is ready for review label Oct 22, 2021
@openjdk
Copy link

openjdk bot commented Oct 22, 2021

@forantar 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 Oct 22, 2021
@mlbridge
Copy link

mlbridge bot commented Oct 22, 2021

Webrevs

@@ -35,24 +35,6 @@ - (NSAccessibilityRole)accessibilityRole
return NSAccessibilityCellRole;;
}

- (NSArray *)accessibilityChildren
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 accessibilityChildren method is now inherited from ComponentWrapperAccessibility.

@@ -49,61 +49,6 @@ - (NSAccessibilityRole)accessibilityRole
return NSAccessibilityColumnRole;
}

- (NSArray *)accessibilityChildren
Copy link
Contributor Author

Choose a reason for hiding this comment

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

By removing this method I'm duplicating the change proposed in ttps://github.com//pull/6020. So this fix should be merged after the referred commit is integrated.

@@ -38,25 +38,6 @@ - (NSAccessibilityRole)accessibilityRole
return NSAccessibilityRowRole;
}

- (NSArray *)accessibilityChildren
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 method is now inherited.

withEnv:env
withView:self->fView];

[childrenCells addObject:child];
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Here we create a wrapping object and we rely on the default release logic, so we do not need to additionally retain/release it.

@victordyakov
Copy link

@azuev-java @pankaj-bansal please review

@azuev-java
Copy link
Member

@azuev-java @pankaj-bansal please review

Note that this change can be applied only after the #6020 so i'm testing that change at the moment and will report on it first.

@openjdk
Copy link

openjdk bot commented Oct 25, 2021

@forantar 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:

8275720: CommonComponentAccessibility.createWithParent isWrapped causes mem leak

Reviewed-by: kizune, pbansal

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 no new commits pushed to the master branch. If another commit should be pushed before you perform the /integrate command, your PR will be automatically rebased. If you prefer to avoid any potential 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 ready Pull request is ready to be integrated label Oct 25, 2021
@forantar
Copy link
Contributor Author

/integrate

@openjdk
Copy link

openjdk bot commented Oct 26, 2021

Going to push as commit 574f890.

@openjdk openjdk bot closed this Oct 26, 2021
@openjdk openjdk bot added integrated Pull request has been integrated and removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Oct 26, 2021
@openjdk
Copy link

openjdk bot commented Oct 26, 2021

@forantar Pushed as commit 574f890.

💡 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
4 participants