-
-
Notifications
You must be signed in to change notification settings - Fork 302
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: prevent memory leak on macOS, closes #536 #587
fix: prevent memory leak on macOS, closes #536 #587
Conversation
I think you meant removing the script message handler for the IPC? wry/src/webview/wkwebview/mod.rs Line 307 in 494a110
|
This PR is based on https://stackoverflow.com/questions/58454042/wkwebview-instances-and-memory-leak. |
Maybe we can also use removeAllScriptMessageHandlers. |
Sounds like exactly what we need :) |
2b2eb6d
to
632d543
Compare
632d543
to
d5cdd30
Compare
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.
I changed all of commit because I found new solution 🙇
#[cfg(target_os = "macos")] | ||
let _: Id<_> = Id::from_ptr(self.ns_window); | ||
let _: Id<_> = Id::from_ptr(self.manager); | ||
let _: Id<_> = Id::from_retained_ptr(self.webview); |
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.
I found the Id::from_ptr
is not working well, so id object is not dropped.
I fixed these code to use Id::from_retained_ptr
with reference to rust-objc-id example.
If we use Id::from_retained_ptr
, navigation to about:blank
is not needed :)
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.
Yep, tested it and it indeed cleans up the process we were talking about correctly! nice 🥳
What it still doesn''t cleanup is the Networking process, but since it does the same on Linux it looks like a webkit problem 🤔
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.
I think network connection is closed but network memory is still remained. I think this is because networking process is single process, networking memory is shared between multiple webview 👀
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 process is responsible for handling network requests as well as storage management. All WebContent processes in a single session (default vs. private browsing) share a single networking session in the networking process.
https://github.com/WebKit/WebKit/blob/main/Introduction.md
This is webkit description.
I think we can remove cache but all of webview cache will be removed. It will bring to bad page loading performance.
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.
I will try to use this gist to remove cache in another PR.
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.
@keiya01 LGTM. Do you want to merge this now?
I suppose networking process will be another PR right? Could you choose an issue and make it the main tracking issue?
Also you can just add a branch in this repo next time.
Yes, I want to merge this PR now. |
What kind of change does this PR introduce?
Does this PR introduce a breaking change?
Checklist
fix: remove a typo, closes #___, #___
)Other information