Skip to content
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

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

Open
noamraph opened this issue Oct 21, 2021 · 4 comments

Comments

@noamraph
Copy link

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

@joachimvalente
Copy link
Contributor

joachimvalente commented Oct 23, 2021

Hi @noamraph

Thanks for looking into this and working on a PR! As I said on the other thread I'm not sure how to fix the static analysis issue.

Do you have a draft PR though? Or could you tell me the idea? If you're not able to send a fix because of static analysis, I could give it a shot.

@noamraph
Copy link
Author

Hi @joachimvalente , I pushed what I have as a PR: #33

There is still non-responsiveness - I haven't managed to move everything to a thread. The change in kotlin might be worthwhile to merge.

Thanks for all your work, it's very helpful!
Noam

@marcodecarolisidt
Copy link

I wonder if the issue is causing this:

thread #47, name = 'DartWorker', stop reason = EXC_BAD_ACCESS (code=1, address=0x680)

Sometimes my app crashes

@aytunch
Copy link

aytunch commented Nov 30, 2023

Hi, for users having too many contacts, app gets janky on startup. Is there any plans to make any enhancements?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants