Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.

[in_app_purchase] Fix Memory Leak #5357

Closed
wants to merge 3 commits into from

Conversation

yimao009
Copy link
Contributor

Create a flutter module that depends on the in_app_purchase plugin, and use the pod in my ios native project to use the module. When the flutter engine is created, it is found that it cannot be destroyed. The registry of the in_app_purchase plugin will hold the flutter engine, so it cannot be released.
I don't understand why this in-app purchase plugin calls [registrar textures],

List which issues are fixed by this PR. You must list at least one issue.

If you had to change anything in the flutter/tests repo, include a link to the migration guide as per the breaking change policy.

Pre-launch Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I read and followed the relevant style guides and ran the auto-formatter. (Unlike the flutter/flutter repo, the flutter/plugins repo does use dart format.)
  • I signed the CLA.
  • The title of the PR starts with the name of the plugin surrounded by square brackets, e.g. [shared_preferences]
  • I listed at least one issue that this PR fixes in the description above.
  • I updated pubspec.yaml with an appropriate new version according to the pub versioning philosophy, or this PR is exempt from version changes.
  • [] I updated CHANGELOG.md to add a description of the change, following repository CHANGELOG style.
  • [] I updated/added relevant documentation (doc comments with ///).
  • [] I added new tests to check the change I am making, or this PR is test-exempt.
  • All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel on Discord.

@yimao009 yimao009 requested a review from cyanglaz as a code owner April 24, 2022 09:14
@flutter-dashboard
Copy link

It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact Hixie on the #hackers channel in Chat (don't just cc him here, he won't see it! He's on Discord!).

If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix?

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.

@google-cla
Copy link

google-cla bot commented Apr 24, 2022

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

For more information, open the CLA check for this pull request.

Copy link
Contributor

@cyanglaz cyanglaz left a comment

Choose a reason for hiding this comment

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

Thanks for sending out this PR! Do you mind creating an issue explain the issue and details?

XCUITests could be added to test these things too.

@@ -26,7 +26,7 @@ @interface InAppPurchasePlugin ()
// Callback channel to dart used for when a function from the payment queue delegate is triggered.
@property(strong, nonatomic, readonly) FlutterMethodChannel *paymentQueueDelegateCallbackChannel;

@property(strong, nonatomic, readonly) NSObject<FlutterTextureRegistry> *registry;
@property(weak, nonatomic, readonly) NSObject<FlutterTextureRegistry> *registry;
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like registry is unused in the plugin code and can be completely removed. "messenger" can also be removed with a little tweak in the code.

And it looks like registrar can be weak as the engine should keep a strong reference to the registrar and plugin should out live the engine.

@cyanglaz
Copy link
Contributor

Dup of #5358, since the other one has CLA, im going to close this in favor of the other

@cyanglaz cyanglaz closed this Apr 25, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants