Skip to content

⚡ Prevent redundant image request enqueueing in ReaderScreen#27

Open
Aatricks wants to merge 1 commit intomainfrom
optimize-reader-prefetch-5370321204973087897
Open

⚡ Prevent redundant image request enqueueing in ReaderScreen#27
Aatricks wants to merge 1 commit intomainfrom
optimize-reader-prefetch-5370321204973087897

Conversation

@Aatricks
Copy link
Owner

@Aatricks Aatricks commented Feb 6, 2026

💡 What:

  • Extracted prefetch logic in ReaderScreen.kt to prefetchImages helper function.
  • Introduced requestedIndices set (remembered by content.url) to track and skip already-processed paragraphs.
  • Added unit test ReaderScreenPrefetchTest.kt to verify deduplication behavior.

🎯 Why:

  • The previous implementation re-enqueued ImageRequests for the same images on every pixel of scroll within the prefetch window.
  • This caused unnecessary CPU overhead and allocation churn (creating Builders and Requests).

📊 Measured Improvement:

  • Algorithmic Complexity: Reduced request generation complexity from O(N * WindowSize) to O(N) where N is total items.
  • Verification: Unit test confirms that overlapping scroll windows do not trigger redundant requests.

PR created automatically by Jules for task 5370321204973087897 started by @Aatricks

Co-authored-by: Aatricks <113598245+Aatricks@users.noreply.github.com>
@google-labs-jules
Copy link
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

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