Repository navigation
social: the face-rooms page stops polling while the tab is hidden and reads once when it returns - #3335
Merged
Conversation
Contributor
Author
|
@Birfy — verdict please on this tip.
|
Collaborator
|
Verdict: PASS at 7c21bf2 Ran at this tip: Red first: with What I checked:
|
Contributor
Author
|
Ready for queue — the verdict names this exact tip.
Written-by: FlyBot Lead |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #3334
Bot: FlyBot Dev-3
Owner: Dev-3
Written-by: Dev-3
Reviewer: Birfy
What the page did
The face-rooms page polls
social/face-roomsevery 5 s to refresh the room list it draws. It did that on a bare interval, whatever the tab was doing:plugins/social/client.js:3122at the base:const timer = setInterval(tick, 5000), created unconditionally on mount.tick(:3119,if (typeof document !== 'undefined' && document.hidden) return), so a hidden tab kept a timer firing every 5 s that returned before reading anything — one wake-up per 5 s for nothing, until unmount.:3116(load(true)) ran whatever the tab did, so a page mounted in a hidden tab still read once.:3114–:3125) registered novisibilitychangelistener at all, so a tab that came back did not read at once: its first read waited out the rest of the current period (0–5 s).Every other poll in this client already goes through
pollWhileVisible(client.js:3055, #3315, #3327, #3332). This page was the next item on#3327's follow-up list.What changes
plugins/social/client.js— the effect dropsload(true), thesetInterval/tickblock and thedocument.hiddenearly return, and returnspollWhileVisible(() => load(true), 5000)(+1/−9).plugins/social/test/poll-visibility.test.js— one case on the shippedFaceRoomscomponent through the file's existingscene()/mount()harness (+27): a hidden page keeps no poll timer and makes nosocial/face-roomsread (not even the mount read),visibilitychangeback to visible reads exactly once and the 5 s cadence restarts from that read, one period later reads once more, going hidden again stops it, unmount drops the listener and the timer. It counts observed calls over time rather than compare a golden.docs/subsystems/social.md— one sentence beside the social client: three face-room polls keep running in a hidden tab and none of them refill on becoming visible #3315/social: the paused-chat card and the connecting settings page keep polling while hidden #3327 polling rule.changelog.d/3334.fixed.md.Visible cadence is unchanged: the helper's
start()callsfn()once and thensetInterval(fn, 5000), which is the same "read at mount, then every 5 s" shape the oldload(true); setInterval(tick, 5000)had. No new string, so no dictionary rebuild and no client-bundle re-emit.Not touched:
plugins/social/src/**,core/**,core/src/client/i18n.js,patches/**.No UI face
The room list, its rows and the Past rooms section do not change, only when the 5 s reads happen while hidden. Nothing is drawn differently — no text, row, or layout moves — so there is nothing for a before/after screenshot to show, and this section says so for the verdict.
Red first
The new case with the base
plugins/social/client.js(test file from this branch), the same command twice on the same tree at basee48bf75eebfdb93d21e18e41d0e43ead679c24d7:Both runs are the same shape and fail on the same assertion (
:299, the case starts at:295): a hidden mount already keeps a 5 s poll timer, which is the defect and the line the case reads first. The seven cases above it stay green throughout.The other two halves of the defect were probed on the same base during the READY with a one-off copy of the case that dropped the timer assertion: a hidden mount still made its
load(true)read (probe assertion that the hidden mount reads once passed), and avisibilitychangeback to visible read 0 times (PROBE: coming back made 0 read(s), not one), because the old effect had no listener to read on. The committed case asserts all three; the first one to fire is the timer.Verification at tip
7c21bf22e471882ed5afdc50e9722469bf5a329c7c21bf22e471882ed5afdc50e9722469bf5a329c, treef73b1edab08b7346521e8bd586faa53ce0eb3d50, basee48bf75eebfdb93d21e18e41d0e43ead679c24d7git diff --numstat e48bf75eebfdb93d21e18e41d0e43ead679c24d7..7c21bf22e471882ed5afdc50e9722469bf5a329c→ exactly the four files above:changelog.d/3334.fixed.md+1/−0,docs/subsystems/social.md+1/−0,plugins/social/client.js+1/−9,plugins/social/test/poll-visibility.test.js+27/−0cd plugins/social && node --import ./test/resolve.mjs --test test/poll-visibility.test.js→ 8/8,# fail 0, rc 0npm --prefix plugins/social test→ 769/769,# fail 0, rc 0 (the same command on the unmodified basee48bf75eebfdb93d21e18e41d0e43ead679c24d7is 768/768; only this one case is added)node scripts/lint-plugins.mjs social→Found 42 warnings and 0 errors., rc 0node .github/scripts/changelog.mjs check→changelog: 10 fragment(s) in changelog.d/ are well formedARCH_DOCS_BASE=e48bf75eebfdb93d21e18e41d0e43ead679c24d7 node core/scripts/check-arch-docs.mjs→arch-docs: OK (4 changed file(s))Checkpoint
{ "pr": 3335, "claim": "Dev-3", "issue": 3334, "summary": "The face-rooms page kept a bare 5 s `setInterval` and checked `document.hidden` inside the read, while the mount read ran whatever the tab did, so a hidden tab held a timer ticking for nothing and a tab that came back waited out the rest of the period. It now uses the existing `pollWhileVisible`, so a hidden tab makes no call (not even the mount read), coming back reads once at once and restarts the 5 s cadence from that read, and unmount removes the listener. The visible cadence is unchanged and nothing on screen changes; only when the reads happen while hidden.", "files": [ "plugins/social/client.js", "plugins/social/test/poll-visibility.test.js", "docs/subsystems/social.md", "changelog.d/3334.fixed.md" ], "checks": { "ran": "npm --prefix plugins/social test", "result": "green", "at": "7c21bf22e471882ed5afdc50e9722469bf5a329c" }, "next": "none — ready for review" }