Skip to content

fix(database): refactor "removeObserver" to fix memory leak #2717

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

Merged
merged 6 commits into from
Apr 21, 2021

Conversation

ened
Copy link
Contributor

@ened ened commented Jun 7, 2020

Description

Similar to #261, this PR removes a memory leak when a App is analyzed using the LeakCanary plugin.

The Android lifecycle is very strict when the "Don't Keep Activities" developer setting is turned on. In that case, only the native side of the plugin will get a callback to release the resources. This has been partially mentioned in flutter/flutter#32948.

Checklist

Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes ([x]). This will ensure a smooth and quick review process.

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • If the pull request affects only one plugin, the PR title starts with the name of the plugin in brackets (e.g. [cloud_firestore])
  • My PR includes unit or integration tests for all changed/updated/fixed behaviors (See Contributor Guide).
  • All existing and new tests are passing.
  • I updated/added relevant documentation (doc comments with ///).
  • The analyzer (flutter analyze) does not report any problems on my PR.
  • I read and followed the Flutter Style Guide.
  • I updated pubspec.yaml with an appropriate new version according to the pub versioning philosophy.
  • I updated CHANGELOG.md to add a description of the change.
  • I signed the CLA.
  • I am willing to follow-up on review comments in a timely manner.

Breaking Change

Does your PR require plugin users to manually update their apps to accommodate your change?

  • Yes, this is a breaking change (please indicate a breaking change in CHANGELOG.md and increment major revision).
  • No, this is not a breaking change.

@ened
Copy link
Contributor Author

ened commented Jun 8, 2020

@invertase This PR, along with a followup for a similar implementation on cloud_firestore would be a suggestion.

@ened
Copy link
Contributor Author

ened commented Jun 19, 2020

@kroikie, @ditman after #2733 , perhaps you are interested in the same thing, but for the database component? :-)

@kroikie
Copy link
Collaborator

kroikie commented Jun 22, 2020

Thanks @ened I'll take a look.

@kroikie kroikie self-assigned this Jun 22, 2020
@ened
Copy link
Contributor Author

ened commented Sep 9, 2020

@kroikie do you have any update or thoughts on this?

@ened
Copy link
Contributor Author

ened commented Jan 2, 2021

@Ehesp - FYI - guess this becomes obselete once the rework is ready?

@Salakar Salakar changed the title [firebase_database] Refactor "removeObserver" and remove memory leak fix(database): Refactor "removeObserver" and fix memory leak Apr 21, 2021
@Salakar Salakar changed the title fix(database): Refactor "removeObserver" and fix memory leak fix(database): refactor "removeObserver" and fix memory leak Apr 21, 2021
@Salakar Salakar changed the title fix(database): refactor "removeObserver" and fix memory leak fix(database): refactor "removeObserver" to fix memory leak Apr 21, 2021
@Salakar
Copy link
Member

Salakar commented Apr 21, 2021

@ened is this PR still valid, if so I'd like to get it reviewed and shipped - let me know, thanks :)

@ened
Copy link
Contributor Author

ened commented Apr 21, 2021

@Salakar still relevant, yes.
This has been tested manually, only.
A good goal in the future could be integration of https://square.github.io/leakcanary/recipes/#running-leakcanary-in-instrumentation-tests into instrumentation/driver tests.

Copy link
Member

@Salakar Salakar left a comment

Choose a reason for hiding this comment

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

LGTM, thank you again for another PR :)

@Salakar
Copy link
Member

Salakar commented Apr 21, 2021

A good goal in the future could be integration of square.github.io/leakcanary/recipes/#running-leakcanary-in-instrumentation-tests into instrumentation/driver tests.

Agree, we're still tweaking the new CI setup on GitHub actions but I think once we're comfortable everything is running smoothly, de-flaked and stable we can start introducing new checks like this and other things like pod lint and Android lint build checks too.

@Salakar Salakar merged commit abbab55 into firebase:master Apr 21, 2021
@firebase firebase locked and limited conversation to collaborators May 22, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants