Skip to content
This repository was archived by the owner on Aug 8, 2023. It is now read-only.
Merged
Changes from all commits
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
6 changes: 6 additions & 0 deletions platform/darwin/src/MGLMapSnapshotter.mm
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
#import "MGLAttributionInfo_Private.h"
#import "MGLLoggingConfiguration_Private.h"
#import "MGLRendererConfiguration.h"
#if TARGET_OS_IPHONE || TARGET_OS_SIMULATOR
#import "MGLMapboxEvents.h"
#endif

#if TARGET_OS_IPHONE
#import "UIImage+MGLAdditions.h"
Expand Down Expand Up @@ -74,6 +77,9 @@ - (instancetype)initWithImage:(nullable MGLImage *)image scale:(CGFloat)scale po
_latLngForFn = std::move(latLngForFn);
_scale = scale;
_image = image;
#if TARGET_OS_IPHONE || TARGET_OS_SIMULATOR
[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?

#endif
}
return self;
}
Expand Down