Halt unnecessary polling requests when the page visibility is hidden
Proposal
In an effort to make our Merge Request pages be as efficient and less prone to hog resources unnecessarily, we should do an assessment of the requests currently being triggered when the user moves away from the tab and which ones should be kept going.
Goals
- Reduce unnecessary load on the servers
- Reduce possible side-effects of memory leaks of tabs left opened for a long time leading to overblown memory usage
Further context
A few milestones ago we looked into this in #210377 (closed)
We ended up calculating a hidden interval for smartInterval requests.
hiddenInterval: window.gon?.features?.widgetVisibilityPolling && 360 * 1000,
I believe it currently sits at 1x per 6min.
Now, do all requests currently actively polling the MR page use this smartInterval implementation?
Requests
Overview tab
Request | Frequency when Tab visible | Frequency when Tab hidden |
---|---|---|
widget.json | 10, 20, 40 seconds... | 0 |
notes | 6 seconds | 0 |
cached_widget.json | 10, 20, 40 seconds... | 0 |
test_reports.json | 1 every time page becomes visible | 0 |
sast_reports.json | 3 seconds (from sentry) | Seems to stop reporting completely and never come back? |
graphql: getState | *2 up to 4 minutes | *2 up to 6 minutes |
Changes tab
Request | Frequency when Tab visible | Frequency when Tab hidden |
---|---|---|
notes | 6 seconds | 0 |
sast_reports | ? | ? |
dependency_scanning_reports | ? | ? |
graphql: getState | ? | ? |
widget | ? | ? |
tp2 (sentry) | ? | ? |
Note
The big 3 are notes, dependency_scanning_reports, and sast_reports which are nearly constant.
The others may be triggered by some activity of me toggling back and forth between tabs to take notes and observer network traffic.