fix(llc): replace live location polling with one-shot expiry timers - #2863
Open
VelikovPetar wants to merge 2 commits into
Open
fix(llc): replace live location polling with one-shot expiry timers#2863VelikovPetar wants to merge 2 commits into
VelikovPetar wants to merge 2 commits into
Conversation
Contributor
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (7)
📝 WalkthroughWalkthroughChangesLive location expiration
Estimated code review effort: 3 (Moderate) | ~30 minutes Sequence Diagram(s)sequenceDiagram
participant ClientState
participant LiveLocationExpirationScheduler
participant EventDispatcher
ClientState->>LiveLocationExpirationScheduler: schedule active locations
LiveLocationExpirationScheduler->>ClientState: onExpired(location)
ClientState->>EventDispatcher: dispatch synthetic location.expired
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
VelikovPetar
force-pushed
the
fix/FLU-488_live_location_one_shot_timers
branch
from
August 3, 2026 11:34
be022b0 to
71fd215
Compare
…cation_one_shot_timers # Conflicts: # packages/stream_chat/CHANGELOG.md
VelikovPetar
marked this pull request as ready for review
August 3, 2026 11:43
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #2863 +/- ##
==========================================
+ Coverage 72.86% 72.97% +0.10%
==========================================
Files 429 430 +1
Lines 27698 27733 +35
==========================================
+ Hits 20183 20237 +54
+ Misses 7515 7496 -19 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
Submit a pull request
Linear: FLU-488
Github Issue: #
CLA
Description of the pull request
Live-location expiry was detected by a
Timer.periodic(seconds: 1)scan in bothClientState(current user's own locations) andChannelClientState(other users' locations). Every second it re-scanned all active live locations and synthesized alocation.expiredevent for any that were pastendAt— which could emit the same expiry event repeatedly, and always wastes a per-second wakeup per client/channel.This replaces that polling with a one-shot
Timerper active live location, scheduled to fire exactly once at the location'sendAt.What changed
LiveLocationExpirationScheduler(packages/stream_chat/lib/src/client/live_location_expiration_scheduler.dart,@internal, not exported). It keeps one timer per location keyed by message id and reconciles on each change to the active set:endAt→ reuse the timer (only refresh coordinates) — a moving location doesn't churn its timer;endAt(extend / stop-early) → cancel and re-arm at the new time;isExpiredand re-arms (rather than emitting) if the clock moved back /endAtwas extended.ClientStatedrives it from theactiveLiveLocationssetter;ChannelClientStatedrives it offactiveLiveLocationsStream. The channel keeps the current-user skip (its own locations are handled by the client layer) at emit time. Both cancel all timers ondispose().Effect
location.expirednow fires once, atendAt, instead of repeating on the 1-second scan.Breaking-change verdict: internal/behavioral only — no public API changes (all touched members are private /
@internal), non-breaking.Cross-SDK: matches the one-shot-per-location approach used by iOS (
ActiveLiveLocationsEndTimeTracker) and the JS/RN client (LiveLocationManager). Reschedule-on-endAt-change is handled here (the server supports extendingendAtand emits nothing at the natural expiry moment, so expiry is client-inferred).Test instructions
endAt; ignores static/expired/no-id; reuses timer + refreshes coordinates on same-endAtupdate; reschedules onendAtchange; cancels on removal/cancel()).client_test.dartandchannel_test.dart(own location auto-expires once; other user's location auto-expires once; current user's own location is skipped on the channel layer).endAt, no per-second churn, coordinate updates reuse the timer, stop-early cancels, correct owner/other split.Screenshots / Videos
No UI changes.
Summary by CodeRabbit
location.expirednotifications.