Conversation
…r paint The preview lock serves requests in call order and the paint loop walks pages by index, so with a cache extent the page above the viewport was rendered before the one on screen. Requests are now collected during the loop and issued by distance from the visible rect. removeCacheImagesIfCacheBytesExceedsLimit removed an image before checking the budget, and it ran once per page inside the loop. Out-of-extent previews were evicted even under budget and re-rendered on scroll-back. The budget is now checked first and the trim runs once after the loop.
…sued startTextSearch cancelled the running session before search() returned early for an identical pattern, so the matches stayed half collected and isSearching stuck at true. An identical pattern now only drops a pending search for another pattern; _restartSearch clears the condition so it can still rerun the same pattern. goToMatch now notifies listeners, so UI such as a "3/120" counter can follow the current match, and a new pattern clears the position left by the previous one.
…ter eviction When the last listener leaves while a document is loading (e.g. a viewer torn down to retry a slow load), the listenable is evicted and the next resolve builds a new one. The in-flight load still completed into the evicted listenable, where nothing could reach or dispose the document. The load now disposes it instead.
palmoni5
added a commit
to palmoni5/otzaria
that referenced
this pull request
Sep 27, 2026
הענף מכיל את עיגון התצוגה באותו פריים (espresso3389/pdfrx#724) ואת התיקונים של espresso3389/pdfrx#729: רינדור העמודים שעל המסך לפני שכניהם, פינוי מטמון התמונות רק מעל התקציב, חיפוש טקסט שלא נקטע בשליחה חוזרת של אותה שאילתה ומודיע במעבר בין התאמות, ושחרור מסמך שטעינתו הסתיימה אחרי שכל המאזינים עזבו. חוזרים ל-pub.dev רק אחרי ששני ה-PR ימוזגו וישוחררו.
Y-PLONI
pushed a commit
to palmoni5/otzaria
that referenced
this pull request
Sep 28, 2026
הענף מכיל את עיגון התצוגה באותו פריים (espresso3389/pdfrx#724) ואת התיקונים של espresso3389/pdfrx#729: רינדור העמודים שעל המסך לפני שכניהם, פינוי מטמון התמונות רק מעל התקציב, חיפוש טקסט שלא נקטע בשליחה חוזרת של אותה שאילתה ומודיע במעבר בין התאמות, ושחרור מסמך שטעינתו הסתיימה אחרי שכל המאזינים עזבו. חוזרים ל-pub.dev רק אחרי ששני ה-PR ימוזגו וישוחררו.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Three independent fixes found while profiling a reader app built on
PdfViewer. Each is its own commit.1. Render on-screen previews first; trim the image cache once per paint
removeCacheImagesIfCacheBytesExceedsLimitremoved an image before checking the budget, so every call evicted at least one out-of-extent preview even when the cache was undermaxImageBytesCachedOnMemory. It was also called once per page inside the paint loop. Out-of-extent previews were therefore dropped on almost every paint and re-rendered on scroll-back. The budget is now checked before each removal, and the trim runs once after the loop.2.
PdfTextSearcher: re-issuing the running pattern no longer kills the searchstartTextSearchcancelled the running session first, andsearch()then returned early because the pattern was identical to the last condition. The matches stayed half collected andisSearchingstayedtrue. This is easy to hit from a search field that fires again with unchanged text. An identical pattern now only drops a pending search for a different pattern._restartSearchclears the condition so it can still rerun the same pattern after a page's content changes.goToMatchnow callsnotifyListeners(), so UI such as a "3/120" counter can follow the current match.currentIndex/currentMatch. The previous pattern's position does not index into the new matches.3.
PdfDocumentListenable: dispose a document whose load finished after evictionWhen the last listener is removed while a document is still loading (e.g. an app that tears the viewer down to retry a slow load), the listenable is evicted from the ref cache and the next
resolveListenable()creates a new one. The in-flight load still completed into the evicted listenable viasetDocument, where nothing could reach the document or dispose it. The load now disposes the document when its listenable is no longer the registered one.Testing
test/pdf_text_searcher_test.dart(new):goToMatchOfIndexnotifies listeners;The first and third fail without the fix.
test/pdf_document_ref_abandoned_load_test.dart(new):Fix 1 has no dedicated test: the preview queue and image cache are private, and render tracing goes to
developer.log. It is covered by the existing viewer tests.packages/pdfrx:PDFIUM_PATH=... flutter test: all 48 tests passed, includinglazy_loading_test.dartagainst real PDFium.flutter analyze lib test: clean apart from the pre-existing info intest/lazy_loading_test.dart.