Skip to content

Improve card browser scrolling performance.#21068

Open
Galal-20 wants to merge 1 commit into
ankidroid:mainfrom
Galal-20:Optimize-CardBrowser-scrolling
Open

Improve card browser scrolling performance.#21068
Galal-20 wants to merge 1 commit into
ankidroid:mainfrom
Galal-20:Optimize-CardBrowser-scrolling

Conversation

@Galal-20
Copy link
Copy Markdown
Contributor

Purpose / Description

This PR addresses the jittery scrolling issue in the Card Browser.
The performance degradation was primarily caused by frequent, synchronous JNI calls to the backend during onBindViewHolder and expensive UI operations like repeated background drawable updates and regex processing for every row being bound.

Fixes

Approach

To restore smooth scrolling, the following optimizations were implemented:

Backend Caching: Added an LruCache for BrowserRow data to minimize expensive JNI calls during scrolling.

  • ViewHolder Optimization: Cached UI states color, selection, truncation to skip redundant updates, particularly background/ripple creation.
  • Data Consistency: Implemented cache invalidation for all state changing operations marking, flags, search refreshes.

How Has This Been Tested?

  • Unit Tests: Executed CardBrowserTest and CardBrowserViewModelTest to ensure no regressions in browser logic.
  • Manual Verification: Verified the fix by simulating slow scrolling in the Card Browser with multiple columns enabled.
  • Android Version: Android 16 and 12.
scroll.mp4

Checklist

  • You have a descriptive commit message with a short title.
  • You have commented your code, particularly in hard-to-understand areas
  • You have performed a self-review of your own code
  • UI changes: include screenshots of all affected screens (in particular showing any new or changed strings)
  • UI Changes: You have tested your change using the [Google Accessibility Scanner]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Scrolling the card browser is jittery

1 participant