robrix icon indicating copy to clipboard operation
robrix copied to clipboard

Optimize Member Search to Avoid Blocking Main UI Thread

Open ZhangHanDong opened this issue 6 months ago • 3 comments

Currently, the member search functionality can still result in iterating over the entire members list on the main UI thread, which is a significant performance concern. The recent solution of limiting matching results (currently to 2x the visible entries) provides some relief when there are many matches, but it does not address the worst-case scenario. If there are no matches or matches only occur at the end of the list, the entire members list is still traversed on the main thread, leading to potential UI freezes or slowdowns.

Proposed Solution:


To resolve this, the search and matching process should be moved to a background thread. The ideal implementation would stream matching users to the main UI thread as they are found (either individually or in small batches), allowing the MentionableTextInput widget to update responsively and avoiding long wait times.

However, since streaming results is more complex, a good first step would be to perform the entire search/match operation on a background thread and then send the results to the main thread in a single step.

Summary of Steps:

  1. Move member search/matching logic off the main UI thread.
  2. Optionally, implement streaming or batching of results to the UI for even better responsiveness.

This change should significantly improve performance, especially in cases with large member lists or few/no matches.

ZhangHanDong avatar Jun 04 '25 10:06 ZhangHanDong

Thanks for filing this issue. I noticed you marked it as a "good first issue", but it doesn't seem like it. This requires pretty complex knowledge of makepad actions, tokio, robrix, and how to create effectively a generator/coroutine-like relationship between a background task and the MentionableTextInput.

kevinaboos avatar Jun 04 '25 14:06 kevinaboos

Yeah, this isn’t a simple issue to implement. @kevinaboos

This is how I see it: because this issue involves context spanning Makepad, Robrix architecture, and backend-to-UI communication, it’s actually a great opportunity for potential contributors to systematically learn about the project while solving it. I’ve already posted this issue in the community and am available to provide guidance. I hope to use it as a way to discover and attract better new contributors.

It’s a “special first issue.” 😄

ZhangHanDong avatar Jun 06 '25 07:06 ZhangHanDong

Haha I see, that's a good point. I'll add the help wanted label for that.

kevinaboos avatar Jun 06 '25 08:06 kevinaboos