swiftbar / SwiftBar

Powerful macOS menu bar customization tool
https://swiftbar.app
MIT License
2.93k stars 92 forks source link

Feature Request: webview persistence control #359

Closed ontipto closed 10 months ago

ontipto commented 1 year ago

When using a webview, the page stays open when hidden, but reloads when redisplayed. If this could be controlled via an action attribute, persistence and background resources could be tailored to the page.

E.g., when displaying a music website, staying open works great for streaming. But, it's interrupted on redisplay as the page reloads. On a complex page, significant resources can be used even when hidden.

If the persistence and load-on-display could be controlled via something like webviewpersistent=true to only load at initial display and stay open when hidden, and =false to close the page when hidden and reload on display, these two cases would be more useful.

melonamin commented 1 year ago

Great idea, thanks.

I made it persistent by default and now existing refreshOnOpen parameter can be used with webview plugin as well. While I was at it I made this view detachable as well #374

ontipto commented 1 year ago

Excellent - thanks! Looking forward to v2.

ontipto commented 1 year ago

Tried this using:

webviewpersistent=false webviewPersistent=false

yet I still see a process in Activity Monitor for the page after first opened; was expecting SwiftBar webviews to act like Safari tabs, where when they're closed, all resources released.

Let me know if I have the param or expectations wrong.

Thanks - exciting to see the first 2.0.0 drop!

chew-z commented 1 year ago

I made it persistent by default

This should be clearly marked as breaking change as it breaks logic of multiple plugins...

I used to display on click graphs in webview. No I am getting the same graph over and over again.

chew-z commented 1 year ago

Let me re-phrase...

<swiftbar.refreshOnOpen>true</swiftbar.refreshOnOpen> forces plugin to update on click but in my case it makes several network calls which makes plugin seem not responsive.

Still it makes webview display the same graph on each line. I need to refresh plugin again to see another graph.

I would like to not force plugin refresh and be able to see separate graph on each line.

So I suggest using separate parameter for refreshing plugin and for refreshing webview. That would allow for flexible control of plugin's behavior.

x-f commented 10 months ago

I have the same issue as @chew-z - I don't want to refresh the plugin on every click (scheduling suits better), but I want the page in webview to reload on click, otherwise I'm seeing the same old content every time I click on the icon. I have a time-related Javascript there.

"webviewpersistent=true|false" is not available as a parameter. I have to revert back to v1.5.0.

melonamin commented 10 months ago

@chew-z and @x-f thanks for your input, this approach makes sense to me.

Updated as follows:

Web view will always refresh when Plugin refreshes, either on schedule or manually.

ontipto commented 10 months ago

persistentWebView = false works great re: killed web view process, but only when menu is detached then clicked outside of.

Also, all detached web view windows close on desktop click, even when persistentWebView = true (process persists in latter case 👍). Should stay open unless explicitly closed, regardless of persistentWebView?

melonamin commented 10 months ago

all detached web view windows close on desktop click

This is a bug, oppened an issue #397