xmtp / xmtp-flutter

XMTP client SDK for Flutter applications written in Dart.
MIT License
31 stars 6 forks source link

UI frequently freezes for a few seconds when continuously listening to conversations #27

Closed nileshrathore closed 1 year ago

nileshrathore commented 1 year ago

I have noticed that the app's UI frequently freezes for a few seconds when I am continuously listening to conversations and messages. This issue seems to occur more frequently when I have a large number of conversations, such as 45-50, in my conversation list. Is there any way to resolve this issue?

ps: I'm using DB architecture same as used in the example app.

dmccartney commented 1 year ago

I suspect this has to do with the DB/hooks layers if you lifted them from the example app.

I'm not sure if your app uses/will use the DB for other stuff -- and it could be platform specific -- but one fix might be to move the DB into a background isolate: https://drift.simonbinder.eu/docs/advanced-features/isolates/

Depending on your app's drift DB setup, this is sometimes as simple as changing NativeDatabase(...) -> NativeDatabase.createInBackground(...)

nileshrathore commented 1 year ago

Thank you for your help. Running the database in the background resolved most of the issues. However, I have noticed that the UI still occasionally freezes, especially after this log: xmtp: <-- #004 /xmtp.message_api.v1.MessageApi/Query. I believe this is a remote query. Are all remote calls also running in a background thread?"

dmccartney commented 1 year ago

It sounds like this was partially resolved and the remaining bits are being addressed with more targeted issues as they're identified.