-
Notifications
You must be signed in to change notification settings - Fork 179
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
Hi, how to make the mqtt listen loop runs in isolate #562
Comments
I'm not a flutter user so I don't know exactly what flutter can offer but Dart has isolates as you know, you could put your whole mqtt code in its own isolate and just pass subscriptions/incoming messages to/from it, or you could maybe just put the listen loop in its own isolate, its up to you really. Other flutter users may be able to help you better with this, the client has no in built support for isolating parts of its code. |
@shamblett Yes, but we hopefully mqtt_client could treat flutter as higher priority since this is the only lib with dart can be used in flutter supports mqtt. Using isolates would means the whole operation are apart from main thread, the changes won't make UI update instantly. Same issue actually existed as well, for example, the drfit sqlite client in dart, they offered an implemetation with isolate support built-in. I have to say, flutter is cubersome, not dart, not mqtt_client, really apperaciated your kindly opensource. But we have get into this siutaiton, flutter is single threaded, every heavy operation would caused main UI thread janky. Any thoughts on how to make mqtt more smooth on UI side? |
Unfortunately the client can't favour flutter, it is a Dart library, if you want to use it in flutter in a certain way then you are free to do so but that's up to you. As I've said above I'm sure other flutter users have encountered the same problem as yourselves and overcome it. There is this package that specialises the client for use in flutter. This may or may not help you. |
I recently found, the apps would get janky when network is not stable or slow. I first think it was from flutter, but the simplest page transition would janky as well, then I thought it might comes from my mqtt loop.
We learned that flutter actually single thread, which means any loop runs in main UI thread would caused janky.
Is that possible make mqtt listen loop runs in isolate, while the messages arrives could also be listen and writes into sql and can ware in main thread so that UI gets update?
The text was updated successfully, but these errors were encountered: