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

Conversation

@lloydsheng
Copy link
Contributor

@lloydsheng lloydsheng commented Nov 29, 2018

Snapshotter (i.e. https://www.mapbox.com/android-docs/maps/overview/snapshotter) is part of the Maps SDK and should be sending turnstile events before usage on both iOS and Android (Snapshotter requests need the same access token we use for regular tile requests).
We should add turnstile events for Snapshotter.

@lloydsheng lloydsheng requested a review from 1ec5 as a code owner November 29, 2018 10:37
@lloydsheng lloydsheng changed the title [WIP] Add turnstile events for Snapshotter [darwin] Add turnstile events for Snapshotter Nov 29, 2018
@lloydsheng lloydsheng requested a review from ChrisLoer November 29, 2018 10:40
@zugaldia zugaldia requested review from julianrex and removed request for 1ec5 and ChrisLoer November 29, 2018 14:39
_latLngForFn = std::move(latLngForFn);
_scale = scale;
_image = image;
[MGLMapboxEvents pushTurnstileEvent];
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this should be in -startWithQueue:completionHandler: - an MGLMapSnapshotter may be allocated and not used, or used multiple times.

Perhaps sending the turnstile event somewhere around

self.completion = completion;
self.resultQueue = queue;
self.cancelled = NO;
__weak __typeof__(self) weakSelf = self;
// mbgl::Scheduler::GetCurrent() scheduler means "run callback on current (ie UI/main) thread"
// capture weakSelf to avoid retain cycle if callback is never called (ie snapshot cancelled)
_snapshotCallback = std::make_unique<mbgl::Actor<mbgl::MapSnapshotter::Callback>>(

would make sense?

Copy link
Contributor

Choose a reason for hiding this comment

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

It looks like Android sends it in the initializer too: #13475

Which should it be? /cc @tobrun

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@julianrex I think the behavior should consist with MGLMapview did.

if ([UIApplication sharedApplication].applicationState != UIApplicationStateBackground) {
[MGLMapboxEvents pushTurnstileEvent];
[MGLMapboxEvents pushEvent:MMEEventTypeMapLoad withAttributes:@{}];
}

The turnstile events send in the initializer of mapview.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@julianrex @tobrun What's your opinion? Can I merge this PR?

Copy link
Contributor

@julianrex julianrex left a comment

Choose a reason for hiding this comment

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

We can go ahead and merge this for consistency (with the existing landed Android PR) - though I'd like to fully understand why it shouldn't be in the start... method.

@lloydsheng lloydsheng changed the title [darwin] Add turnstile events for Snapshotter [iOS] Add turnstile events for Snapshotter Dec 6, 2018
@lloydsheng lloydsheng merged commit 86117eb into master Dec 6, 2018
@springmeyer
Copy link
Contributor

We can go ahead and merge this for consistency (with the existing landed Android PR) - though I'd like to fully understand why it shouldn't be in the start... method.

Is there a ticket tracking this question? We should get to a resolution. /cc @lloydsheng @julianrex

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants