From 228e402d34a49665f9501cc8450085c7402ae474 Mon Sep 17 00:00:00 2001 From: Julian Rex Date: Mon, 15 Jul 2019 14:44:26 -0400 Subject: Addressed PR feedback. Calls delegate method on main queue. --- platform/darwin/src/MGLNetworkConfiguration.m | 7 +++++-- platform/ios/test/MGLNetworkConfigurationTests.m | 1 + 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/platform/darwin/src/MGLNetworkConfiguration.m b/platform/darwin/src/MGLNetworkConfiguration.m index 2335fcce0b..0e5046e7a3 100644 --- a/platform/darwin/src/MGLNetworkConfiguration.m +++ b/platform/darwin/src/MGLNetworkConfiguration.m @@ -67,8 +67,8 @@ NSString * const kMGLDownloadPerformanceEvent = @"mobile.performance_trace"; } - (void)startDownloadEvent:(NSString *)urlString type:(NSString *)resourceType { - NSDate *startDate = [NSDate date]; if (urlString && ![self eventDictionaryForKey:urlString]) { + NSDate *startDate = [NSDate date]; [self setEventDictionary:@{ MGLStartTime: startDate, MGLResourceType: resourceType } forKey:urlString]; } } @@ -87,8 +87,11 @@ NSString * const kMGLDownloadPerformanceEvent = @"mobile.performance_trace"; NSString *urlString = response.URL.relativePath; if (urlString && [self eventDictionaryForKey:urlString]) { NSDictionary *eventAttributes = [self eventAttributesForURL:response withAction:action]; - [self.metricsDelegate networkConfiguration:self didGenerateMetricEvent:eventAttributes]; [self removeEventDictionaryForKey:urlString]; + + dispatch_async(dispatch_get_main_queue(), ^{ + [self.metricsDelegate networkConfiguration:self didGenerateMetricEvent:eventAttributes]; + }); } } diff --git a/platform/ios/test/MGLNetworkConfigurationTests.m b/platform/ios/test/MGLNetworkConfigurationTests.m index 56a2074ff9..bfb63f57af 100644 --- a/platform/ios/test/MGLNetworkConfigurationTests.m +++ b/platform/ios/test/MGLNetworkConfigurationTests.m @@ -7,6 +7,7 @@ @implementation MGLNetworkConfigurationTests +// Regression test for https://github.com/mapbox/mapbox-gl-native/issues/14982 - (void)testAccessingEventsFromMultipleThreads { MGLNetworkConfiguration *configuration = [[MGLNetworkConfiguration alloc] init]; -- cgit v1.2.1