Skip to content
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

Add drawsBackground parameter for WKWebView #1

Merged
merged 6 commits into from
Apr 15, 2024

Conversation

repalash
Copy link
Contributor

@repalash repalash commented Sep 8, 2023

Add a drawsBackground parameter in Info.plist, which when set to false allows for a transparent background in <html> and <body>.

Copy link
Owner

@jtbandes jtbandes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution! And sorry it took me a while to get around to reviewing this. I was concerned about using an undocumented API for this, but I think as long as it is opt-in, it should be ok. I've added a setValue:forUndefinedKey: implementation to try and avoid crashing if the method stops working in the future.

@repalash
Copy link
Contributor Author

Thanks. And for the library. I have been using it on 3dviewer.xyz

There is an issue I have been facing where the process started for quicklook is never quit and you can see it in Activity Monitor taking up memory. It's called Preview extension Web Content. Have you had this kind of issue before?

@jtbandes jtbandes merged commit d7d407e into jtbandes:main Apr 15, 2024
2 checks passed
@jtbandes
Copy link
Owner

Hm, I have not noticed that, but it's possible that macos keeps the extension alive so it can be reused for multiple previews. Is that what you think is happening, or is it creating a new instance for each preview?

@repalash
Copy link
Contributor Author

repalash commented Apr 15, 2024

Its creating a new process each time I open quicklook. Also seems like its created after the quicklook is closed but that could be just a delay and because I was doing it pretty fast. Its even creating multiple processes for the same file

Screen.Recording.2024-04-15.at.10.05.32.PM.mp4

Also looks like these are never killed, I found them by going through activity monitor after it handn't been restarted for days and found 50+ of these.

@jtbandes
Copy link
Owner

I can reproduce the same behavior on my machine but it looks like they do eventually go away, at least sometimes... I wonder if there is some way to tell WKWebView to tear down the content process after the preview is closed?

@jtbandes
Copy link
Owner

If the OS is keeping PreviewViewController around just in case you preview the same file again, then it might need to be updated to support unloading & reloading the web view each time to avoid this.

@repalash
Copy link
Contributor Author

Yeah I am looking for some way to stop the process.
But it's creating a new content process for the same file everytime it's opened.
The only thing I found is that we can use process pool for webview.

@repalash
Copy link
Contributor Author

I guess if JavaScript keeps running in the webview we can use that to detect when the user closes the view either by some window load event or resize event. And then use that to stop the web view in swift.

@jtbandes
Copy link
Owner

I would hope that we can use viewDidDisappear, but I have not tried it yet

@jtbandes
Copy link
Owner

Moving discussion to a new issue #7

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.

2 participants