Phone icon indicating copy to clipboard operation
Phone copied to clipboard

Contact search blocks the UI with a large address book

Open Softweb-SA opened this issue 1 month ago • 1 comments

Checklist

  • [x] I can reproduce the bug with the latest release, 1.11.1.
  • [x] I searched open and closed issues for an existing report of this Contacts-tab search performance problem.
  • [x] I searched the organization's discussions for an existing report.
  • [x] I read the app's bundled FAQ text; this problem is not listed.
  • [x] I have taken the time to fill in the required details and understand that incomplete reports may be dismissed.
  • [x] This issue contains only one bug.
  • [x] I have read and understood the contribution guidelines.

Affected app version

1.11.1

Affected Android/Custom ROM version

Android 10

Affected device model

Huawei LYA-L29

How did you install the app?

Built from source (foss debug builds for the before/after measurements).

Steps to reproduce the bug

  1. Use an address book with several thousand contacts (3,520 contacts containing phone numbers in my test).
  2. Open the Contacts tab and activate search.
  3. Type and delete queries of 1 to 7 characters.
  4. Observe UI stalls while typing.

Expected behavior

Typing and deleting a query should remain responsive with a large address book.

Actual behavior

Contact filtering and repeated normalization run on the main thread for each keystroke, causing visible stalls.

Screenshots/Screen recordings

Not attached. Timing measurements are included below.

Additional information

I have a working version with a fix, tested on the same phone and address book. I reproduced the original problem and verified the improvement on the device. Search feels substantially faster and more responsive in everyday use.

Measurement Before Working version
Main-thread work per keystroke 70 to 185 ms 2 to 31 ms, typically 3 to 6 ms
Filtering On the main thread 7 to 30 ms on a background thread

The first keystroke in the baseline took 437 ms. The measurements used temporary SystemClock.elapsedRealtime() instrumentation around the search handler, with roughly 60 keystrokes of typing and deleting queries. These are single-device results, and main-thread time is not the same as end-to-end result latency.

ContactsFragment.onSearchQueryChanged() repeatedly normalizes up to six fields per contact on every keystroke. My patch precomputes searchable text once per contact list, performs filtering on a background thread, and discards outdated results when the query changes or search closes. It preserves the existing matching and ordering rules, including accent-insensitive and numeric searches, which I have tested on the device.

This concerns typing in the Contacts tab, rather than initial contact loading or search in the dial pad/call history.

I'd like to contribute this as a focused PR. Your contribution guidelines require the help wanted label before submission. Could a maintainer add it so I can open the PR?

Softweb-SA avatar Oct 12 '26 20:10 Softweb-SA

Please open a new issue using the appropriate issue form and keep its required sections and labels intact. If your GitHub client does not support issue forms, please use a web browser.

fossifybot avatar Oct 12 '26 20:10 fossifybot