Skip to content

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

Merged
merged 5 commits into from
May 21, 2025
Merged

Fix memory leaks #595

merged 5 commits into from
May 21, 2025

Conversation

mickael-menu
Copy link
Member

  • Fix memory leaks using memoize().
  • Fix memory leaks in the EPUB navigator.
  • Display the initial decorations faster in the EPUB navigator.

Copy link

@Copilot Copilot AI left a 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()

@mickael-menu mickael-menu merged commit 68fb1cb into develop May 21, 2025
5 checks passed
@mickael-menu mickael-menu deleted the fix/memory-leaks branch May 21, 2025 19:02
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