Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

recording: create timers in the main thread since it requires a run loop #188

Merged
merged 2 commits into from
Sep 9, 2024

Conversation

marandaneto
Copy link
Member

@marandaneto marandaneto commented Sep 9, 2024

💡 Motivation and Context

https://posthog.slack.com/archives/C07JEE5CQF2/p1725894061542169?thread_ts=1724245423.990689&cid=C07JEE5CQF2

If you init the SDK from a background task (eg a Queue, or a Task), the timers won't fire.

Run Loop Requirement: Timer.scheduledTimer needs to be associated with a run loop in order to function. If you call Timer.scheduledTimer from a background thread, it will be scheduled on the run loop of that thread. However, background threads typically don’t have run loops running by default, so unless a run loop is manually created and running on that thread, the timer won’t fire.

💚 How did you test it?

Running from a task

📝 Checklist

  • I reviewed the submitted code.
  • I added tests to verify the changes.
  • I updated the docs if needed.
  • No breaking change or entry added to the changelog.

@marandaneto marandaneto requested a review from a team September 9, 2024 15:12
@marandaneto marandaneto marked this pull request as ready for review September 9, 2024 15:12
@marandaneto marandaneto merged commit 9ea4ecb into main Sep 9, 2024
8 checks passed
@marandaneto marandaneto deleted the fix/timer-ui-thread branch September 9, 2024 15:18
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.

2 participants