andriydruk / RxDNSSD

Android version of mDNSResponder
Apache License 2.0
297 stars 75 forks source link

Fix for multicast lock fatal crash. #196

Closed neveroffline closed 3 years ago

neveroffline commented 3 years ago

To reproduce, setup an Executor to run every 10 seconds (plenty of time for the round trips). private DNSSDService browseTCPService; private DNSSDService browseUDPService; private DNSSD dnssd;

oncreate.... dnssd = new DNSSDBindable(this);

ExecutorRun - if(browseTCPService != null) { browseTCPService.stop(); browseTCPService = null; } if(browseUDPService != null) { browseUDPService.stop(); browseUDPService = null; }

browseTCPService = dnssd.browse(... new BrowseListener())...

browseUDPService = dnssd.browse(... new BrowseListener())...

Let run for a while (an hr plus) with a minimum of 8 results total (4 TCP, 4 UDP) and the fatal over lock allocation will happen. Add debug to DNSSD onstarting/stopping to see over allocation of lock attempts. I have seen this across API 26-28 in my testing of various phones from Galaxy S7 to others.

At the very minimum you shouldn't be forcing a lock on the end user.

andriydruk commented 3 years ago

I still not really understand how you stop service. Please provide all codes of your sample. Push it to sample DNSSDActivity.java

neveroffline commented 3 years ago

I still not really understand how you stop service. Please provide all codes of your sample. Push it to sample DNSSDActivity.java

I am stopping at top of executor if browseTCPService or browseUDPService are not null, running .stop() on them and then nulling them with the re-setup of the calls to follow.

In any case, this fork has solved my issue. Thank you.

andriydruk commented 3 years ago

Still can't reproduce your issue. Probably a problem in synchronization of your browseTCPService.stop(); I'm closing PR