Skip to content

Look up only the selected conversation, off the main thread, for its options - #2244

Draft
mpretty-cyro wants to merge 2 commits into
devfrom
fix/conversation-options-sheet-lookup
Draft

mpretty-cyro wants to merge 2 commits into
devfrom
fix/conversation-options-sheet-lookup

Conversation

@mpretty-cyro

@mpretty-cyro mpretty-cyro commented Oct 28, 2026 •

Copy link
Copy Markdown
Collaborator

Contributor checklist

  • I have tested my contribution on these devices:
  • Virtual device: Pixel 6 profile, API 37 (arm64), play flavour, debug
  • My contribution is fully baked and ready to be merged as is
  • I ensure that all the open issues my contribution fixes are mentioned in the commit message of my first commit using the Fixes #1234 syntax

Description

ANR clusters with top frames nativeExecuteForCursorWindow and nativePrepareStatement have the main thread in
ConversationOptionsBottomSheet.onCreate → DefaultConversationRepository.getConversationList() → ThreadDatabase.getThreads:
long-pressing a conversation loaded every thread to find one.

A new ConversationRepository.getConversation(address) queries that one thread. The sheet loads it, and the group record, on Dispatchers.IO and binds once they arrive; it stays invisible
until then so the options don't flash. The legacy-group options use that group record rather than reading it again on the main thread. If the conversation isn't found, the sheet is dismissed allowing state loss, since the lookup can finish after the app is backgrounded.

Testing: on an emulator with debug-only main-thread database logging (not in this PR): on dev the sheet ran getConversationList → getThreads and GroupDatabase on the main thread; with this change it runs none. Options, Pin and Unpin behave as before. The ANR wasn't reproduced (it needs many conversations).

…options

Long-pressing a conversation on the home screen loaded the whole
conversation list (every thread with its last message and unread counts)
on the main thread in the options sheet's onCreate, just to find the one
that was pressed. With many conversations, or a busy database, that
froze the home screen until the app was killed for not responding.
Query the one thread on a background thread and bind the sheet once it
arrives.

@mpretty-cyro mpretty-cyro left a comment •

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.

The legacy-group branch still read the group on the main thread, and the
not-found path could dismiss after the state was saved.

@mpretty-cyro mpretty-cyro left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

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