Skip to content

perf: optimize loading messages in threads#552

Merged
naveensingh merged 19 commits into
mainfrom
naveensingh/improve-thread-loading
Oct 14, 2025
Merged

perf: optimize loading messages in threads#552
naveensingh merged 19 commits into
mainfrom
naveensingh/improve-thread-loading

Conversation

@naveensingh
Copy link
Copy Markdown
Member

@naveensingh naveensingh commented Oct 13, 2025

Type of change(s)

  • Bug fix
  • Feature / enhancement
  • Infrastructure / tooling (CI, build, deps, tests)
  • Documentation

What changed and why

  1. Removed the endless scroll listener in favor of early prefetch based on user scroll. This queues a next page load as soon as the number of remaining messages is found to be less than the specified threshold.
  2. Introduced a simple cache mechanism for getNameAndPhotoFromPhoneNumber() and getThreadParticipants(). The original code was inefficiently querying these values for every message in the thread. Caching the results cut loading time by 50%.
  3. Removed eager dimension reading for attachments when loading MMS messages, as Gilde does it fine without any performance overhead. This was the main reason threads containing MMS messages were slow to load, even with early prefetch from 1.
  4. Removed the circular loading indicator that appeared when the next page was being loaded because it's no longer necessary after 1, 2 & 3.
  5. Increased the initial message load count from 30 to 50. It won't lead to slower initial loads because of the optimizations above. Originally, it was 100, but it was reduced to 30 to workaround existing inefficiencies in the code (Slow rendering when lots of messages for a contact SimpleMobileTools/Simple-SMS-Messenger#44).
  6. Updated the thread adapter code to use actual stable IDs instead of hash codes.

Tests performed

  • Sending & receiving SMS messages
  • Sending & receiving MMS messages
  • Scrolling fast/slow to the very top/bottom of the thread
  • Deleting messages

According to testing on two of my phones, loading is now 4 times faster compared to v1.4.0.

Closes the following issue(s)

Checklist

  • I read the contribution guidelines.
  • I manually tested my changes on device/emulator (if applicable).
  • I updated the "Unreleased" section in CHANGELOG.md (if applicable).
  • I have self-reviewed my pull request (no typos, formatting errors, etc.).
  • All checks are passing.

@naveensingh naveensingh force-pushed the naveensingh/improve-thread-loading branch from de6ff2b to f1fb954 Compare October 13, 2025 17:27
@naveensingh naveensingh added testers needed We need testers for this issue or pull request and removed testers needed We need testers for this issue or pull request labels Oct 13, 2025
@naveensingh naveensingh added the testers needed We need testers for this issue or pull request label Oct 13, 2025
@naveensingh naveensingh force-pushed the naveensingh/improve-thread-loading branch from ff1dd89 to b04bf5a Compare October 14, 2025 12:21
@naveensingh naveensingh force-pushed the naveensingh/improve-thread-loading branch from 921c459 to 291545d Compare October 14, 2025 18:24
@naveensingh naveensingh merged commit 72eb0af into main Oct 14, 2025
5 checks passed
@naveensingh naveensingh deleted the naveensingh/improve-thread-loading branch October 14, 2025 19:16
@naveensingh naveensingh removed the testers needed We need testers for this issue or pull request label Oct 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant