Skip to content

refactor: introduce dedicated refresh queue - #90

Merged
polok merged 5 commits into
mainfrom
refactor_schedule_refresh
Aug 14, 2026
Merged

refactor: introduce dedicated refresh queue#90
polok merged 5 commits into
mainfrom
refactor_schedule_refresh

Conversation

@polok

@polok polok commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Background of that change:

  • Race condition in the timer setup — guard timer == nil is checked synchronously on the calling thread, while self?.timer = Timer... happens asynchronously on another thread. Two rapid calls to startRefreshing() can therefore both pass the guard and create two timers.
  • RunLoop.current.run() on DispatchQueue.global() — this blocks a thread from GCD’s shared global pool indefinitely. With repeated start/stop cycles, this can continuously consume threads from the pool, potentially leading to thread explosion and eventually a crash (EXC_RESOURCE / thread limit exceeded).
  • stopRefreshing() does not stop the run loop — invalidate() only invalidates the timer; it does not terminate RunLoop.current.run(). The run loop therefore continues running indefinitely even after the refresh is stopped. This leaves the thread blocked forever and results in a resource leak.

@polok
polok requested a review from a team as a code owner August 12, 2026 08:20
@polok
polok merged commit 342a20b into main Aug 14, 2026
1 check passed
@polok
polok deleted the refactor_schedule_refresh branch August 14, 2026 09:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants