Skip to content

Pass application context.#1172

Merged
yunikkk merged 5 commits intomainfrom
yds-fix-activity-context-usage
Feb 23, 2022
Merged

Pass application context.#1172
yunikkk merged 5 commits intomainfrom
yds-fix-activity-context-usage

Conversation

@yunikkk
Copy link
Contributor

@yunikkk yunikkk commented Feb 21, 2022

Summary of changes

Pass application context to the location provider to avoid possible memory leaks due to Binder holding context.

User impact (optional)

Pull request checklist:

  • Briefly describe the changes in this PR.
  • Include before/after visuals or gifs if this PR includes visual changes.
  • Write tests for all new functionality. If tests were not written, please explain why.
  • Optimize code for java consumption (@JvmOverloads, @file:JvmName, etc).
  • Add example if relevant.
  • Document any changes to public APIs.
  • Run ./gradlew apiDump to update generated api files, if there's public API changes, otherwise the verify-kotlin-binary-compatibility CI will fail.
  • Apply changelog label ('breaking change', 'bug 🪲', 'build', 'docs', 'feature 🍏', 'performance ⚡', 'testing 💯') or use the label 'skip changelog'
  • Add an entry inside this element for inclusion in the mapbox-maps-android changelog: <changelog></changelog>.
  • If this PR is a v10.[version] release branch fix / enhancement, merge it to main firstly and then port to v10.[version] release branch.

Fixes: < Link to related issues that will be fixed by this pull request, if they exist >

PRs must be submitted under the terms of our Contributor License Agreement CLA.

@yunikkk yunikkk requested a review from a team as a code owner February 21, 2022 22:03
Copy link
Contributor

@Chaoba Chaoba left a comment

Choose a reason for hiding this comment

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

Nice catch 👍

Copy link
Contributor

@kiryldz kiryldz left a comment

Choose a reason for hiding this comment

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

Please update changelog entry for fixing location component leak by adding reference to this PR as well as the one created by @Chaoba
Also please fix unit test

@yunikkk yunikkk force-pushed the yds-fix-activity-context-usage branch from 8cc4e47 to 2225ac6 Compare February 22, 2022 10:14
@yunikkk yunikkk requested a review from kiryldz February 22, 2022 13:14
Copy link
Member

@pengdev pengdev left a comment

Choose a reason for hiding this comment

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

LGTM % nit

@ank27 ank27 added the bug 🪲 Something isn't working label Feb 22, 2022
* Fix location puck not being shown if map is created without initial style (e.g. MapInitOptions.styleUri == null) and then loaded asynchronously. ([#1114](https://github.com/mapbox/mapbox-maps-android/pull/1114))
* Fix crash within location plugin that happens when style is reloaded simultaneously with location plugin updates. ([#1112](https://github.com/mapbox/mapbox-maps-android/pull/1112))
* Fix memory leak in location component. ([#1093](https://github.com/mapbox/mapbox-maps-android/pull/1093))
* Fix memory leak in location component. ([#1093](https://github.com/mapbox/mapbox-maps-android/pull/1093), [#1172](https://github.com/mapbox/mapbox-maps-android/pull/1172))
Copy link
Contributor

Choose a reason for hiding this comment

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

as I've said before I'd remove link to #1093 as it does not actually fix the leak if I understood correctly

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually #1093 resolved it, by adding WeakReference context that lives on CompassEngine is no more kept by GoogleLocationEngine callback.

And 1172 just adds more safety, additionally using applicationContext everywhere in the LocationEngine/CompassEngine, thus making any leaks not possible now and in future.

Basically any of those fixes would be sufficient, and both of them work too =)

Copy link
Contributor

@kiryldz kiryldz left a comment

Choose a reason for hiding this comment

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

LGTM with one nit.
Great work on digging to the very root cause by the way!

@yunikkk yunikkk force-pushed the yds-fix-activity-context-usage branch from 27571ba to bdd3c75 Compare February 23, 2022 10:56
@yunikkk yunikkk closed this Feb 23, 2022
@yunikkk yunikkk reopened this Feb 23, 2022
@yunikkk yunikkk merged commit a184773 into main Feb 23, 2022
@yunikkk yunikkk deleted the yds-fix-activity-context-usage branch February 23, 2022 15:38
@tyofemi tyofemi added this to the V10.4 milestone Mar 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug 🪲 Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants