-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
feat: disable background throttling #12181
base: dev
Are you sure you want to change the base?
feat: disable background throttling #12181
Conversation
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.
thanks so much. If nothing major changes in the Wry PR i only have 2 very small comments:
Co-authored-by: Fabian-Lars <[email protected]>
Package Changes Through c62e002There are 8 changes which include tauri-cli with minor, tauri-runtime with minor, tauri-runtime-wry with minor, tauri-utils with minor, tauri with minor, @tauri-apps/api with minor, @tauri-apps/cli with minor, tauri-bundler with patch Planned Package VersionsThe following package releases are the planned based on the context of changes in this pull request.
Add another change file through the GitHub UI by following this link. Read about change files or the docs at github.com/jbolda/covector |
@FabianLars I changed the comments according to your suggestions and also updated the wry PR with a version check. Let me know if there is anything else I should do before this PR can be merged. |
…tner/tauri into feat/background-throttling-pr
…tner/tauri into feat/background-throttling-pr
I changed the wry version to |
@FabianLars is there something still missing in this PR or can we merge this with the release of wry 0.48.1 ? |
sorry, i was waiting with minor PRs intentionally to not block patch releases until the webview2-com and windows updates, but that ended up with me completely ignoring those prs. Just skipping over the code one major issue i see is that tauri-utils cannot depend on wry, so that has to be reverted. That may also fix some of the build issues. Api wise i don't think it makes sense to have Option in the WebviewBuilder and WebviewWindowBuilder setter methods. We can use the enum directly here. Lastly 2 small doc things: 1) the enum and maybe the methods should document clearly what the default variant is. 2) The |
@FabianLars thank you! Implemented the requested changes. I have one question left: Since we have the I'm uncertain if/how this works. I doubt that I can change the value once the webview is loaded. But when I open a new window through JS, it should be possible to specify it. |
ah didn't even notice that. since wry has no runtime method for this, only one to set it on the builder you can remove that ts function again. Only the WebviewOptions property will work here. therefore this is a bit offtopic but the setter function would belong in webview.ts not window.ts because well, it's a webview method and not related to the window / windowing library. |
@FabianLars removed it. Also had to update snapshot tests. I don't really know why. Would be great if you could let me know if I should undo those. Maybe it's due to my environment? |
never touched nor looked at the snapshot stuff so no idea 😂 |
@FabianLars is there anything missing or can we merge it soon? |
i don't see anything missing, no. Just wanted to release a patch release before merging the minor prs. I currently have monday in mind to start merging those because i'm busy over the weekend. apologies for the long wait times. |
This PR relates to #5250
It requires a change of
wry
for which I've opened another PR: tauri-apps/wry#1445I've added an option
disableBackgroundThrottling
to allow developers to choose if their view should automatically be throttled / suspended by the browser after a certain time of being hidden or minimised. In the worst case, this default behaviour of browsers can lead to broken applications running in the background.For instance if a websocket connection is the only reason not to suspend a "tab" and the machine goes into sleep mode and wakes up again, the connection is often lost and the browser won't have any reason to keep the background tab active and therefore unload it, which will not allow the hidden view to "heal" itself.
This default behaviour effectively renders any browser capabilities unusable for long running background processes. One alternative might be moving logic from the frontend to the backend, but browsers have meanwhile become a great choice for local first apps and if the browser already offers the required features easily accessible, why force developers to leave a territory they feel comfortable with?
As of now, this is only available for WebKit based browsers on iOS 17.0+,iPadOS 17.0+,Mac Catalyst 17.0+, macOS 14.0+, visionOS 1.0+ ( see https://developer.apple.com/documentation/webkit/wkpreferences/inactiveschedulingpolicy-swift.enum?language=objc ).
It can be assumed that it will also be implemented for WebView2 (Windows). And it might be that it's already usable for linux and android, although I couldn't find any documentation about it and also cannot test it locally due to a lack of devices.
As an alternative for windows and non-webkit browsers, one can setup a pending WebLock transaction, which, according to the docs, can also keep the browser from suspending it.
I needed to update a snapshot test and am unsure if this is at all related to this change. Please let me know if I did something wrong here.
Pending Tasks
wry
package version when feat: disable background throttling wry#1445 is merged, which will havewith_disable_background_throttling
onWebViewBuilder