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

Fabric: fix border memory leaks #23815

Closed
wants to merge 4 commits into from

Conversation

ericlewis
Copy link
Contributor

Summary

This fixes a few memory leaks in fabrics handling of colors for borders, when using CGColorRef's we must be diligent about releasing the memory back.

Changelog

[iOS] [Fixed] - Border style memory leaks

Test Plan

Run RNTester, and ensure it is working, notice no memory leaks from CoreGraphics.

@ericlewis ericlewis self-assigned this Mar 7, 2019
@ericlewis ericlewis requested a review from shergin March 7, 2019 20:12
@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Mar 7, 2019
Copy link
Contributor

@shergin shergin left a comment

Choose a reason for hiding this comment

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

This is 100% valid concern ❤️!
... but probably not the best solution.

I think we should rename the method (or create an additional one) to RCTCGColorRefUnretainedFromSharedColor, annotate it with CF_RETURNS_NOT_RETAINED and don't use Create inside.
RCTBorderColors

@ericlewis
Copy link
Contributor Author

@shergin I think I addressed your feedback.

@@ -396,7 +398,9 @@ - (void)invalidateLayer
}

layer.borderWidth = (CGFloat)borderMetrics.borderWidths.left;
layer.borderColor = RCTCGColorRefFromSharedColor(borderMetrics.borderColors.left);
CGColorRef borderColor = RCTCGColorRefFromSharedColor(borderMetrics.borderColors.left)
Copy link
Contributor

Choose a reason for hiding this comment

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

I am not sure that this part is correct (or optimal), but I trust you.

@facebook-github-bot facebook-github-bot added the Import Started This pull request has been imported. This does not imply the PR has been approved. label Mar 12, 2019
Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

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

@shergin is landing this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

Copy link
Contributor

@shergin shergin left a comment

Choose a reason for hiding this comment

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

CI says that it does not compile and needs linting. :)

@ericlewis
Copy link
Contributor Author

@shergin maybe this fixes the complaints? :)

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

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

@shergin is landing this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@react-native-bot
Copy link
Collaborator

This pull request was successfully merged by @ericlewis in 8e490d4.

When will my fix make it into a release? | Upcoming Releases

@react-native-bot react-native-bot added Merged This PR has been merged. and removed Import Started This pull request has been imported. This does not imply the PR has been approved. labels Mar 13, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Merged This PR has been merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants