-
Notifications
You must be signed in to change notification settings - Fork 151
Fix memory leaks #595
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix memory leaks #595
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR addresses memory leaks by replacing the legacy memoization pattern with Swift Tasks across multiple services and view controllers. Key changes include:
- Replacing memoize calls with Task-based asynchronous initializations in PDF and EPUB services.
- Updating asynchronous patterns in content iterators, navigators, and view controllers to improve lifecycle management.
- Removing the legacy memoize implementation in favor of Task-based methods to mitigate memory retention issues.
Reviewed Changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.
Show a summary per file
File | Description |
---|---|
Sources/Streamer/Parser/PDF/Services/LCPDFTableOfContentsService.swift | Replaces memoize call with a Task-based property for generating the table of contents. |
Sources/Streamer/Parser/PDF/Services/LCPDFPositionsService.swift | Uses Task-based caching for computing positions by reading order. |
Sources/Shared/Publication/Services/Content/Iterators/HTMLResourceContentIterator.swift | Updates memoization of elements and total progression range to Task-based asynchronous properties. |
Sources/Navigator/Toolkit/PaginationView.swift | Introduces lifecycle handling in didMoveToWindow and converts async calls to synchronous ones where applicable. |
Sources/Navigator/EPUB/EPUBSpreadView.swift, EPUBReflowableSpreadView.swift, EPUBFixedSpreadView.swift | Updates spread loading flags and delegate callbacks to follow async patterns consistently. |
Sources/Navigator/EPUB/EPUBNavigatorViewController.swift | Refactors table of contents title retrieval and spread reloading without awaiting, aligning with updated async workflows. |
Sources/LCP/Content Protection/LCPDecryptor.swift | Adopts Task-based initialization for calculating plain text size. |
Sources/Internal/Memoize.swift | Removed in favor of Task-based approaches. |
Sources/Internal/Extensions/Task.swift | Adds helper methods for task management and replacement. |
Comments suppressed due to low confidence (1)
Sources/Navigator/Toolkit/PaginationView.swift:222
- [nitpick] Converting asynchronous calls to synchronous ones in 'setCurrentIndex' and related methods may affect UI update timing. Verify that these changes maintain UI responsiveness and do not block the main thread.
loadPages()
memoize()
.