Skip to content

fix(android): setTelemetryEnabled no longer creates a hidden MapView - #4458

Open
mfazekas wants to merge 1 commit into
mainfrom
fix/android-telemetry-no-mapview-4456
Open

mfazekas wants to merge 1 commit into
mainfrom
fix/android-telemetry-no-mapview-4456

Conversation

@mfazekas

Copy link
Copy Markdown
Contributor

Description

Fixes #4456. This is @Noitham's change from #4457, which they closed without comment; their commit and authorship are kept.

On Android, setTelemetryEnabled created a MapView only to reach MapTelemetry, and never destroyed it. Creating it sends a billable MAPS_MAUS turnstile, even for users who never open a map, and leaks about 6 views per call. MapTelemetry.setUserTelemetryRequestState only calls TelemetryUtils.setEventsCollectionState(enabled, callback), in every v11 version, so this calls it directly. iOS is unchanged.

TelemetryUtils's static methods are annotated @RestrictTo(LIBRARY_GROUP_PREFIX) in Mapbox Common, so a future Mapbox SDK could change them without notice. The Navigation SDK uses the same call.

Checklist

  • I've read CONTRIBUTING.md
  • I updated the doc/other generated code with running yarn generate in the root folder (not needed, Kotlin only)
  • I have tested the new feature on /example app.
    • In V11 mode/ios (iOS unchanged)
    • In New Architecture mode/ios (iOS unchanged)
    • In V11 mode/android
    • In New Architecture mode/android
  • I added/updated a sample - if a new feature was implemented (/example) (bug fix)

Before / after

Example app on an API 34 emulator, reproducer from #4456 (no MapView on screen):

main This PR
Live views, before / after 1 call / after 101 calls 171 / 177 / 777 171 / 171 / 171
GLMapboxRenderThread created after 101 calls 101 0
Connection to events.mapbox.com within a second of the first call none
Native heap after 101 calls +17 MB no change

TelemetryUtils.getEventsCollectionState() / getClientServerEventsCollectionState() give the same values on both builds: false/TurnstileEventsOnly after setTelemetryEnabled(false), true/Enabled after setTelemetryEnabled(true), and both survive an app restart.

Component to reproduce the issue you're fixing

The reproducer is in #4456.

The MapView was only used to reach MapTelemetry, whose
setUserTelemetryRequestState calls TelemetryUtils.setEventsCollectionState.
Creating it sent a MAPS_MAUS turnstile, started a render thread and was
never destroyed. Call TelemetryUtils directly instead.

Fixes #4456

This branch was previously deployed

1 inactive deployment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Android setTelemetryEnabled creates a hidden MapView that sends a MAU turnstile and is never destroyed

2 participants