diff options
author | Julian Rex <julian.rex@mapbox.com> | 2019-07-15 14:44:26 -0400 |
---|---|---|
committer | Julian Rex <julian.rex@mapbox.com> | 2019-07-15 14:45:56 -0400 |
commit | 228e402d34a49665f9501cc8450085c7402ae474 (patch) | |
tree | 25f883c677594f212b9c9c5ac6291e8e99f77054 | |
parent | 4250e0801529a595f39e43588ec7f09d58b850f9 (diff) | |
download | qtlocation-mapboxgl-upstream/jrex/14982-start-download-event.tar.gz |
Addressed PR feedback. Calls delegate method on main queue.upstream/jrex/14982-start-download-event
-rw-r--r-- | platform/darwin/src/MGLNetworkConfiguration.m | 7 | ||||
-rw-r--r-- | 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]; |