Skip to content

Commit 7ed4909

Browse files
authored
Fix mDNS publishing for iOS simulator (#6789)
* Don't block the platfrorm thread on simulator mDNS publishing
1 parent 86d34e0 commit 7ed4909

1 file changed

Lines changed: 8 additions & 11 deletions

File tree

shell/platform/darwin/ios/framework/Source/FlutterObservatoryPublisher.mm

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ - (instancetype)init {
6767
return self;
6868
}
6969

70-
- (void)dealloc {
70+
- (void)stopService {
7171
#if TARGET_IPHONE_SIMULATOR
7272
if (_dnsServiceRef) {
7373
DNSServiceRefDeallocate(_dnsServiceRef);
@@ -76,20 +76,17 @@ - (void)dealloc {
7676
#else // TARGET_IPHONE_SIMULATOR
7777
[_netService.get() stop];
7878
#endif // TARGET_IPHONE_SIMULATOR
79+
}
80+
81+
- (void)dealloc {
82+
[self stopService];
7983

8084
blink::DartServiceIsolate::RemoveServerStatusCallback(std::move(_callbackHandle));
8185
[super dealloc];
8286
}
8387

8488
- (void)publishServiceProtocolPort:(std::string)uri {
85-
#if TARGET_IPHONE_SIMULATOR
86-
if (_dnsServiceRef) {
87-
DNSServiceRefDeallocate(_dnsServiceRef);
88-
_dnsServiceRef = NULL;
89-
}
90-
#else // TARGET_IPHONE_SIMULATOR
91-
[_netService.get() stop];
92-
#endif // TARGET_IPHONE_SIMULATOR
89+
[self stopService];
9390
if (uri.empty()) {
9491
return;
9592
}
@@ -115,7 +112,7 @@ - (void)publishServiceProtocolPort:(std::string)uri {
115112
if (err != 0) {
116113
FML_LOG(ERROR) << "Failed to register observatory port with mDNS.";
117114
} else {
118-
DNSServiceProcessResult(_dnsServiceRef);
115+
DNSServiceSetDispatchQueue(_dnsServiceRef, dispatch_get_main_queue());
119116
}
120117
#else // TARGET_IPHONE_SIMULATOR
121118
_netService.reset([[NSNetService alloc] initWithDomain:@"local."
@@ -128,7 +125,7 @@ - (void)publishServiceProtocolPort:(std::string)uri {
128125
}
129126

130127
- (void)netServiceDidPublish:(NSNetService*)sender {
131-
FML_LOG(INFO) << "FlutterObservatoryPublisher is ready!";
128+
FML_DLOG(INFO) << "FlutterObservatoryPublisher is ready!";
132129
}
133130

134131
- (void)netService:(NSNetService*)sender didNotPublish:(NSDictionary*)errorDict {

0 commit comments

Comments
 (0)