From 3446f04895b78f5f403886d0c975eea56049670f Mon Sep 17 00:00:00 2001 From: Dan Field Date: Thu, 8 Nov 2018 11:18:59 -0800 Subject: [PATCH] Fix mDNS publishing for iOS simulator (flutter/engine#6789) * Don't block the platfrorm thread on simulator mDNS publishing --- .../Source/FlutterObservatoryPublisher.mm | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterObservatoryPublisher.mm b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterObservatoryPublisher.mm index b8111067c8..980bec0854 100644 --- a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterObservatoryPublisher.mm +++ b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterObservatoryPublisher.mm @@ -67,7 +67,7 @@ return self; } -- (void)dealloc { +- (void)stopService { #if TARGET_IPHONE_SIMULATOR if (_dnsServiceRef) { DNSServiceRefDeallocate(_dnsServiceRef); @@ -76,20 +76,17 @@ #else // TARGET_IPHONE_SIMULATOR [_netService.get() stop]; #endif // TARGET_IPHONE_SIMULATOR +} + +- (void)dealloc { + [self stopService]; blink::DartServiceIsolate::RemoveServerStatusCallback(std::move(_callbackHandle)); [super dealloc]; } - (void)publishServiceProtocolPort:(std::string)uri { -#if TARGET_IPHONE_SIMULATOR - if (_dnsServiceRef) { - DNSServiceRefDeallocate(_dnsServiceRef); - _dnsServiceRef = NULL; - } -#else // TARGET_IPHONE_SIMULATOR - [_netService.get() stop]; -#endif // TARGET_IPHONE_SIMULATOR + [self stopService]; if (uri.empty()) { return; } @@ -115,7 +112,7 @@ if (err != 0) { FML_LOG(ERROR) << "Failed to register observatory port with mDNS."; } else { - DNSServiceProcessResult(_dnsServiceRef); + DNSServiceSetDispatchQueue(_dnsServiceRef, dispatch_get_main_queue()); } #else // TARGET_IPHONE_SIMULATOR _netService.reset([[NSNetService alloc] initWithDomain:@"local." @@ -128,7 +125,7 @@ } - (void)netServiceDidPublish:(NSNetService*)sender { - FML_LOG(INFO) << "FlutterObservatoryPublisher is ready!"; + FML_DLOG(INFO) << "FlutterObservatoryPublisher is ready!"; } - (void)netService:(NSNetService*)sender didNotPublish:(NSDictionary*)errorDict {