android-maps-compose icon indicating copy to clipboard operation
android-maps-compose copied to clipboard

#138 - prevent a memory leak on AndroidView which may not call ON_DES…

Open polivmi1 opened this issue 1 year ago • 2 comments

This PR fixes a memory leak that can happen in AndroidView when navigating to another screen. The Lifecycle ON_DESTROY event is never called because in onDispose we remove the mapLifecycleObserver and this method is called before the Lifecycle ON_DESTROY event.

We have to handle any Lifecycle ON_DESTROY in the onDispose method.


Before submitting your PR, there are a few things you can do to make sure it goes smoothly:

  • [x] Make sure to open a GitHub issue as a bug/feature request before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea
  • [ ] Ensure the tests and linter pass
  • [x] Code coverage does not decrease (if any source code was changed)
  • [x] Appropriate docs were updated (if necessary)

Fixes #138 🦕

polivmi1 avatar Aug 14 '22 12:08 polivmi1

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).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

google-cla[bot] avatar Aug 14 '22 12:08 google-cla[bot]

I signed it.

polivmi1 avatar Aug 14 '22 12:08 polivmi1

@arriolac I see the test problems have been fixed - can we re-run this and merge unless there is no problem?

polivmi1 avatar Sep 19 '22 15:09 polivmi1

This should be good to merge. Will let @wangela take over from here

arriolac avatar Sep 21 '22 08:09 arriolac

Thank you for your contribution @polivmi1 !

wangela avatar Sep 21 '22 18:09 wangela

:tada: This PR is included in version 2.7.1 :tada:

The release is available on:

Your semantic-release bot :package::rocket:

googlemaps-bot avatar Sep 21 '22 19:09 googlemaps-bot

So sorry @polivmi1, would you mind git commit --amend the commit message in your branch to:

fix: Prevent a memory leak on AndroidView which may not call ON_DESTROY

and then push the branch again? The reason for this is the original commit message did not follow conventional commit conventions, and was interpreted by our semantic release bot as not triggering a new release when in fact it is a bugfix and should trigger a patch release. I have reverted the merge from this PR so you can re-submit your changes.

Once you push the branch, it will create a new PR and you can reference this PR #188 and the original issue that is fixed #138 in the new PR's description, to link to the historical discussion preserved in this PR review.

Apologies for not catching the commit message format during the main review.

wangela avatar Sep 21 '22 19:09 wangela

@wangela I have changed the commit message in https://github.com/polivmi1/android-maps-compose/tree/138_memory_leak it hasn't created a new PR (this is already in state merged). Should I create a completely new PR and mention this one there?

polivmi1 avatar Sep 21 '22 19:09 polivmi1

@polivmi1 Yes, I see a "Create pull request" button here that you can use: https://github.com/googlemaps/android-maps-compose/compare/main...polivmi1:android-maps-compose:138_memory_leak

wangela avatar Sep 21 '22 22:09 wangela

Waiting for this release to be fixed

basurahan avatar Sep 22 '22 06:09 basurahan

@wangela see https://github.com/googlemaps/android-maps-compose/pull/206

polivmi1 avatar Sep 22 '22 06:09 polivmi1