Skip to content

awaitMap can prevent cancellation forever, triggering memory leaks or suspending deadlocks #90

@LouisCAD

Description

@LouisCAD

The awaitMap() extension function for SupportMapFragment uses the non cancellable suspendCoroutine function from the kotlin.coroutines package, so if the map is never shown, it'll never resume, even if cancelled.

The solution is to use suspendCancellationCoroutine from the kotlinx.coroutines package, even if there's no way to unregister the underlying callback in the current Google Maps API for Android.

It's better than what we have now because in the first case, the leaked objects can reach well beyond the SupportMapFragment, while in the second case, we only have a temporary leak (until the callback finally gets called, for example after the map is shown, or once the SupportMapFragment gets garbage collected).

Metadata

Metadata

Assignees

Labels

priority: p1Important issue which blocks shipping the next release. Will be fixed prior to next release.releasedtype: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions