Skip to content

Conversation

@ipavlidakis
Copy link
Contributor

@ipavlidakis ipavlidakis commented Jun 30, 2025

🎯 Goal

This revision attempts to improve performance by moving recurring Timers from the main thread to a background thread.

🛠 Implementation

We are extending the existing Timer control to:

  • provide a Combine publisher when requested
  • Cache TimerPublishers to avoid recreating them (that's optional)

🎨 Showcase

Add relevant screenshots and/or videos/gifs to easily see what this PR changes, if applicable.

Before After
Screenshot 2025-06-30 at 1 29 14 PM Screenshot 2025-06-30 at 1 28 57 PM

☑️ Contributor Checklist

  • I have signed the Stream CLA (required)
  • This change follows zero ⚠️ policy (required)
  • This change should receive manual QA
  • Changelog is updated with client-facing changes
  • New code is covered by unit tests
  • Comparison screenshots added for visual changes
  • Affected documentation updated (tutorial, CMS)

@ipavlidakis ipavlidakis self-assigned this Jun 30, 2025
@ipavlidakis ipavlidakis requested a review from a team as a code owner June 30, 2025 08:49
@ipavlidakis ipavlidakis added the enhancement New feature or request label Jun 30, 2025
@github-actions
Copy link

Public Interface

+ public struct DefaultTimer: Timer  
+ 
+   public static func publish(every interval: TimeInterval)-> AnyPublisher<Date, Never>



@github-actions
Copy link

1 Warning
⚠️ Big PR

Generated by 🚫 Danger

@Stream-SDK-Bot
Copy link
Collaborator

Stream-SDK-Bot commented Jun 30, 2025

SDK Size

title develop branch diff status
StreamVideo 8.06 MB 8.08 MB +17 KB 🟢
StreamVideoSwiftUI 2.27 MB 2.27 MB 0 KB 🟢
StreamVideoUIKit 2.4 MB 2.4 MB +1 KB 🟢
StreamWebRTC 9.85 MB 9.85 MB 0 KB 🟢

@github-actions
Copy link

Public Interface

+ public struct DefaultTimer: Timer  
+ 
+   public static func publish(every interval: TimeInterval,file: StaticString = #file,function: StaticString = #function,line: UInt = #line)-> AnyPublisher<Date, Never>



@ipavlidakis ipavlidakis force-pushed the performance/timer-storage-v2 branch from 8808152 to 76ddf7d Compare June 30, 2025 09:17
@github-actions
Copy link

Public Interface

+ public struct DefaultTimer: Timer  
+ 
+   public static func publish(every interval: TimeInterval,file: StaticString = #file,function: StaticString = #function,line: UInt = #line)-> AnyPublisher<Date, Never>



@ipavlidakis ipavlidakis changed the title [Performance]Timer storage v2 [Performance]Timers improvements Jun 30, 2025
@github-actions
Copy link

Public Interface

+ public struct DefaultTimer: Timer  
+ 
+   public static func publish(every interval: TimeInterval,file: StaticString = #file,function: StaticString = #function,line: UInt = #line)-> AnyPublisher<Date, Never>



@github-actions
Copy link

Public Interface

+ public struct DefaultTimer: Timer  
+ 
+   public static func publish(every interval: TimeInterval,file: StaticString = #file,function: StaticString = #function,line: UInt = #line)-> AnyPublisher<Date, Never>



/// cancels previous subscriptions when the coordinator changes.
///
/// - Parameter peerConnectionCoordinator: The coordinator to observe.
/// - Parameter peerConnectionCoordinator: The coordinator to observe.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what happened here?

///
/// All scheduled timers are executed on the provided dispatch queue, which
/// allows running timers off the main thread in background contexts.
protocol Timer {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this the same implementation we have on chat? Since both products should use the same implementation eventually, from StreamCore.

@github-actions
Copy link

Public Interface

+ public struct DefaultTimer: Timer  
+ 
+   public static func publish(every interval: TimeInterval,file: StaticString = #file,function: StaticString = #function,line: UInt = #line)-> AnyPublisher<Date, Never>



@sonarqubecloud
Copy link

@ipavlidakis ipavlidakis merged commit 1831493 into develop Jun 30, 2025
19 of 21 checks passed
@ipavlidakis ipavlidakis deleted the performance/timer-storage-v2 branch June 30, 2025 12:02
@Stream-SDK-Bot Stream-SDK-Bot mentioned this pull request Jul 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants