capacitor-community / contacts

Contacts Plugin for Capacitor
https://capacitor-community.github.io/contacts/
119 stars 52 forks source link

ANR android crash #116

Closed trinitiwowka closed 6 months ago

trinitiwowka commented 6 months ago

Describe the bug After I added the plugin and started using it, my ANR errors increased

To Reproduce Steps to reproduce the behavior: Just call this function:

const getContacts: () => Promise<ContactPayload[]> = () => {
    if (Capacitor.isNativePlatform()) {
        return Contacts.getContacts({
            projection: {
                name: true,
                organization: true,
                birthday: true,
                note: true,
                phones: true,
                emails: true,
                urls: true,
                postalAddresses: true,
                image: false
            }
        })
            .then((result: GetContactsResult) => result.contacts)
    }

    return new Promise((resolve) => resolve(MOCK_CONTACTS));
}

Expected behavior It was not possible to reproduce locally, I think that there are clients who have thousands of contacts and this causes a freeze

Screenshots

image image

Platforms: Android 10/11/12/13

BTW look like https://github.com/capacitor-community/contacts/issues/3

trinitiwowka commented 6 months ago

The documentation says you need to use NOT the main thread, maybe it will be helpful? https://developer.android.com/topic/performance/vitals/anr#lock-contention

trinitiwowka commented 6 months ago

Maybe it's solution https://github.com/capacitor-community/contacts/pull/117/files ?