-
-
Notifications
You must be signed in to change notification settings - Fork 86
Fix memory leaks by cleaning up BrowserViewModel references #1148
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
Conversation
…maining tab content disappear
@@ -282,6 +287,8 @@ struct RootView: View { | |||
// but that's not comming from our window | |||
return | |||
} | |||
windowTracker.current = nil // remove the reference to this window, see guard above |
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.
a very non-obvious problem that was macOS specific
@@ -290,12 +297,9 @@ struct RootView: View { | |||
let browser = BrowserViewModel.getCached(tabID: tabID) | |||
// tab closed by user | |||
browser.pauseVideoWhenNotInPIP() | |||
Task { @MainActor [weak browser] in |
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.
this is already called from navigation.deleteTab(tabID: tabID)
a few lines below.
@@ -132,11 +132,24 @@ final class CompactViewController: UIHostingController<AnyView>, UISearchControl | |||
} | |||
} | |||
|
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.
Fixing by forcing SwiftUI body function switch between a browser based and non browser based views on a higher level, therefore we don't need to reference browserViewModel in the .loading state.
@@ -168,6 +177,10 @@ final class BrowserViewModel: NSObject, ObservableObject, | |||
} | |||
} | |||
} | |||
|
|||
deinit { | |||
debugPrint("🧨 BrowserViewModel deinit 🧨") |
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.
leaving this in, to have a clear indicator that the clean up is working, while we work on other features and change the code.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1148 +/- ##
==========================================
- Coverage 25.09% 24.13% -0.96%
==========================================
Files 136 136
Lines 7098 7179 +81
==========================================
- Hits 1781 1733 -48
- Misses 5317 5446 +129 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
@BPerlakiH Inguess zou have remarked that the CI does not pass? Please ask for review only if the CI pass and keep the PR in draft as long as it does not. |
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.
Thank you! It looks good to me but it's mostly beyond my understanding…
Anyway it's such a big change that we need to keep this in mind for a while as there might be unforseen consequences in other places
Fixes: #1016
Many things had to change in order to clean up the BrowserViewModel references, this (rather large object) is holding a reference to the entire WKWebView for each tab, so it's important to clean it up properly once the tab is closed, otherwise we are using more and more memory.
Tested on iPhone, iPad and macOS.