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

[iOS] Add turnstile events for Snapshotter #13476

Merged
merged 2 commits into from
Dec 6, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions platform/darwin/src/MGLMapSnapshotter.mm
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#import "MGLAttributionInfo_Private.h"
#import "MGLLoggingConfiguration_Private.h"
#import "MGLRendererConfiguration.h"
#import "MGLMapboxEvents.h"

#if TARGET_OS_IPHONE
#import "UIImage+MGLAdditions.h"
Expand Down Expand Up @@ -74,6 +75,7 @@ - (instancetype)initWithImage:(nullable MGLImage *)image scale:(CGFloat)scale po
_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?

}
return self;
}
Expand Down