drift icon indicating copy to clipboard operation
drift copied to clipboard

There is an application that may have multiple locations where SQL is written simultaneously. However, this has caused the user interface to become stuck every time.

Open lucasjinreal opened this issue 1 year ago • 19 comments

There is an application that may have multiple locations where SQL is written simultaneously. However, this has caused the user interface to become stuck every time. I am aware that Flutter operates on a single thread. Consequently, every SQL write operation is performed within an await future.

I am curious about the following:

  1. Why does this occur with certainty?
  2. What are the possible solutions? How can we ensure that multiple operations do not cause the UI to freeze when performing operations.

Background: My application is a chat app that listens to a websocket for message updates. This occurs when the app is opened or resumed. New messages may arrive, and each time new data arrives, the UI becomes unresponsive (or very laggy). (The messages have two types, one is normal chat, and the other is news. They are listened to simultaneously, so they could be written at a very close time.)

However, currently, I am experiencing this unresponsive behavior every single time.

I have already opened the database with isolate.

lucasjinreal avatar Sep 16 '24 12:09 lucasjinreal