Reduce RTC Polling#77058
Conversation
…d on network conditions and adding network-aware polling functionality.
…mproved real-time collaboration
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
|
👋 Thanks for your first Pull Request and for helping build the future of Gutenberg and WordPress, @the-hercules! In case you missed it, we'd love to have you join us in our Slack community. If you want to learn more about WordPress development in general, check out the Core Handbook full of helpful information. |
|
Hello @the-hercules, thank you for this contribution! I'd like to review this, but could you please rebase or merge We merged a PR for a disconnect timing issue in #76966, roughly the same time this PR was opened. Note that #76966 changed the way disconnect backoff timing worked because the results were counter intuitive and multiplying caused disconnect dialogs to be more easily triggered. From the Why? section in #76966:
This PR is more focused on successful connecting timing, but I just wanted to note that we changed disconnects from a exponential back-off system. I'm not sure if that will affect your work here. I'm open to changing the implementation in #76966 as long as we fix the "difficult to reason about" part. |
Closes #76631
Why?
High-level implementation overview
This update adds adaptive RTC polling for the HTTP polling transport using two signals:
navigator.connection.effectiveType)The goal is to reduce unnecessary polling on slower networks without changing the existing polling model or interfering with error backoff / background-tab behavior.
1. Network Information API path
For browsers that expose
navigator.connection.effectiveType, we use it as an immediate hint for active-tab polling.Implemented in:
packages/sync/src/providers/http-polling/network-info.tspackages/sync/src/providers/http-polling/polling-manager.tsWhat changed:
navigator.connection?.effectiveType4g->1x3g->4x2g/slow-2g->10x25000msso awareness stays below the server timeoutchangeevent so pending polling can be rescheduled if the browser reports a new connection type mid-session2. Cross-browser RTT fallback
For browsers that do not expose
effectiveType, polling now adapts based on recent successful poll latency.Implemented in:
packages/sync/src/providers/http-polling/latency-info.tspackages/sync/src/providers/http-polling/polling-manager.tsWhat changed:
postSyncUpdate()in the polling loop< 500ms->1x>= 500msand< 1500ms->4x>= 1500ms->10x1000ms4000msPolling behavior preserved
This change intentionally does not alter the rest of the transport model:
25000msretryNow()continues to affect retry timing only, not latency historyResult
With this change:
effectiveTypeUse of AI Tools
Codex was used to strategize and plan and also for testing. Functionality is properly tested by human.