Skip to content

When loading contacts the app hangs, because serializing the contacts is done on the main thread #32

@noamraph

Description

@noamraph

Hi, when I run the simple example, the GUI stops for some time, instead of having the circular progress indicator continue spinning until the contacts are shown. I first reported it here flutter/flutter#91992 , but now I understand this is a flutter_contacts issue. See a video here:

flutter-slow-contacts.mp4

I checked, and I'm pretty sure that the cause is that serializing the contacts is done on the main thread. I checked this by replacing this line:

                    GlobalScope.launch(Dispatchers.Main) { result.success(contacts) }

With this:

                    GlobalScope.launch(Dispatchers.Main) { result.success(contacts.subList(0, 5)) }

Meaning that all the contacts are retrieved from the phone, but only the first 5 are sent to the flutter app. In this case, the app doesn't hang.

I would be happy to try to fix this and send a pull request. I already managed to move the serialization to a thread in a sample app. However, android studio can't analyze the android directory for some reason, so it makes fixing this much harder. I reported it here: #31

Thanks,
Noam

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions