Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Mapbox memory leak crashes app when LeakCanary is enabled #8477

Closed
cvance opened this issue Mar 21, 2017 · 8 comments
Closed

Mapbox memory leak crashes app when LeakCanary is enabled #8477

cvance opened this issue Mar 21, 2017 · 8 comments
Assignees
Labels
Android Mapbox Maps SDK for Android

Comments

@cvance
Copy link

cvance commented Mar 21, 2017

Not entirely sure if this is a Mapbox bug (or Mapzen or LeakCanary or a bug in my code) but I believe it is. Either way this seems to stem from a memory leak in Mapbox.

Platform: Android
Mapbox SDK version: 5.0.0

Steps to trigger behavior

  1. Add and enable LeakCanary to a project using Mapbox 5.0.0
  2. Open an activity with a mapview, location engine and location engine listener
  3. Background the app

Expected behavior

LeakCanary catches a memory leak from Mapbox

Actual behavior

LeakCanary crashes the app. Disabling LeakCanary seems to resolve this crash.

java.lang.ClassCastException: android.os.BinderProxy cannot be cast to com.mapzen.android.lost.internal.FusedLocationProviderService$FusedLocationProviderBinder
                                                                                    at com.mapzen.android.lost.internal.FusedLocationProviderApiImpl.onServiceConnected(FusedLocationProviderApiImpl.java:45)
                                                                                    at com.mapzen.android.lost.internal.FusedLocationServiceConnectionManager.onServiceConnected(FusedLocationServiceConnectionManager.java:79)
                                                                                    at com.mapzen.android.lost.internal.FusedLocationProviderApiImpl.onServiceConnected(FusedLocationProviderApiImpl.java:65)
                                                                                    at android.app.LoadedApk$ServiceDispatcher.doConnected(LoadedApk.java:1453)
                                                                                    at android.app.LoadedApk$ServiceDispatcher$RunConnection.run(LoadedApk.java:1481)
                                                                                    at android.os.Handler.handleCallback(Handler.java:751)
                                                                                    at android.os.Handler.dispatchMessage(Handler.java:95)
                                                                                    at android.os.Looper.loop(Looper.java:154)
                                                                                    at android.app.ActivityThread.main(ActivityThread.java:6119)
                                                                                    at java.lang.reflect.Method.invoke(Native Method)
                                                                                    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
                                                                                    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
@tobrun
Copy link
Member

tobrun commented Mar 21, 2017

@cvance can you share the code of the related to mapview, location engine and location engine listener?

@tobrun tobrun added the Android Mapbox Maps SDK for Android label Mar 21, 2017
@cvance
Copy link
Author

cvance commented Mar 21, 2017

I'm able to reproduce the crash using this sample activity, LeakCanary 1.5 and Mapbox SDK 5.0 and Mapbox UI 2.0 on my Nexus 6P (7.1.2beta)

@tobrun tobrun added this to the android-v5.1.0 milestone Mar 22, 2017
@Guardiola31337
Copy link
Contributor

Same issue reported in MAS.

@Emeritus-DarranKelinske

I fixed this by removing all location permission from the manifest. There is a suggestion to use tools:remove in the manifest in the upstream bug, but I have not figured that out yet.

@tobrun
Copy link
Member

tobrun commented Apr 27, 2017

@cvance, would you be able to retest this with latest SNAPSHOT? I'm thinking that #8825 might have resolved the issue (not able to reproduce with that code).

Installation instructions for SNAPSHOT:

repositories {
    mavenCentral()
    maven { url "http://oss.sonatype.org/content/repositories/snapshots/" }
}

dependencies {
    compile ('com.mapbox.mapboxsdk:mapbox-android-sdk:5.1.0-SNAPSHOT@aar') {
        transitive=true
    }
}

@tobrun tobrun self-assigned this Apr 27, 2017
@cvance
Copy link
Author

cvance commented Apr 27, 2017

I'm able to reproduce still with 5.1.0-SNAPSHOT. Side note, it also appears to crash Pixel XL on launch, somewhere in native code.

@tobrun
Copy link
Member

tobrun commented May 4, 2017

In #8872, I'm updating LOST to the latest 2.30-SNAPSHOT.
This should include the fix that addresses this issue.

@tobrun
Copy link
Member

tobrun commented Jun 7, 2017

I'm going to close this issue, so we have more clarity on the milestone related to the LOST issue. I'm opting to track this in #9139 as we have a PR tackling that in #9142. In this PR we working on resolving the current outstanding upstream issues (lostzen/lost#213). Thank you all for chipping in, continuing this issue in #9139.

@tobrun tobrun closed this as completed Jun 7, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Android Mapbox Maps SDK for Android
Projects
None yet
Development

No branches or pull requests

4 participants