-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Android: Issues on hot-restart #3
Comments
Effectively it's even a bit worse. Due to |
Thanks for reporting this issue. Have you tried what happens on iOS in this case? |
It's actually pretty much the same on iOS. Just the plugin's native code is missing even more things to make it possible to detect this error condition on iOS. Working on this right now. For Android I've got a branch which makes it possible to detect the error and work around it on the app level: https://github.com/jusst-engineering/flutter_nsd/tree/fix/notify-startdiscovery-failure |
Pull Request would be greatly appreciated 👍 |
If an app using flutter_nsd is hot-restarted while discovery is active, calling startDiscovery() will fail.
In case timber logging is active it can be seen that a warning is printed, because NSD is already active, but no error is sent back to the app.
This is due to the exception handler in
private fun startDiscovery(serviceType: String)
, which is doing nothing but printing the warning.To get working discovery after a hot-restart, currently a cycle of
discoverServices()
->stopDiscovery()
->startDiscovery()
is required. If the initial error would be notified back to the app it could detect that error condition and only then do an additional stop/start cycle.Doing only
stopDiscovery()
->startDiscovery()
after a restart is currently not working, because theonDiscoveryStopped
handler is called afterstartDiscovery()
only, as at the time of the initialstopDiscovery()
call, no method handler is set in the plugin's channel.The text was updated successfully, but these errors were encountered: