Improve extension service lifecycle, isolate robustness, dedupe lists, and UI/lifecycle cleanups#644
Merged
kodjodevf merged 7 commits intokodjodevf:mainfrom Feb 13, 2026
Merged
Conversation
By moving provider-dependent init to didChangeDependencies. (dependOnInheritedWidget)
- Add StreamSubscription to manage ReceivePort listener lifecycle - Introduce handshake timeout when waiting for isolate SendPort to prevent hangs - Add response timeout in get<T>() to avoid indefinitely waiting for isolate replies - Replace direct ReceivePort.listen with tracked subscription for safer cleanup - Improve error handling for invalid or missing isolate responses - Strengthen isolate startup reliability and shutdown consistency
- Introduce _addLog() helper to manage log insertion - Enforce a maximum log history of 200 entries to prevent unbounded memory growth - Replace direct _logsNotifier.value.add(event) with safe, immutable-style list update - Improve log handling consistency and avoid mutating notifier state in place
- Added _initializedLocales to prevent repeated locale initialization - Improved evaluateJavascriptViaWebview with safer lifecycle handling (try/finally + null checks) - Minor cleanup and consistency improvements across MBridge utilities
- Replace list→set→list conversions with LinkedHashSet for stable ordering - Ensure PageUrl uniqueness based on URL - Ensure Video uniqueness based on url + originalUrl - Add null‑safety checks when building PageUrl and Video objects - Improve readability and reduce unnecessary allocations
This commit improves memory management, reduces redundant interpreter instantiation, and standardizes service usage patterns. - Add `dispose()` to `ExtensionService` interface and implement it across Dart, JS, LNReader, and Mihon services. - Replace repeated interpreter creation in `DartExtensionService` with a persistent `_interpreter` instance initialized once in the constructor. - Add disposal logic for JS DOM selector and Cheerio instances to prevent memory leaks. - Introduce `withExtensionService()` helper to ensure services are always disposed after use. - Update call sites across the codebase to use `withExtensionService()` or manual try/finally disposal. - Improve isolate service message handling by extracting `responsePort` earlier. - Ensure safer defaults (e.g., returning empty lists, const lists) when service calls fail.
kodjodevf
approved these changes
Feb 13, 2026
kodjodevf
approved these changes
Feb 13, 2026
kodjodevf
approved these changes
Feb 13, 2026
kodjodevf
approved these changes
Feb 13, 2026
kodjodevf
approved these changes
Feb 13, 2026
kodjodevf
approved these changes
Feb 13, 2026
kodjodevf
approved these changes
Feb 13, 2026
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.
Add proper disposal and lifecycle handling for extension services, harden isolate communication with timeouts, deduplicate page/video lists, limit log growth, and clean up multiple UI/lifecycle issues across the codebase.
This PR fixes several classes of issues discovered while working on extension execution and long-running isolate workflows:
dispose()lifecycle toExtensionServiceimplementations.withExtensionService()helper to guarantee disposal.LinkedHashSetpreserving order and improving memory/CPU usage.initStatetodidChangeDependencies, desktop webview null-checks, category swap code cleanup).