Skip to content

Improve span timoeut handling in BugsnagNativeSpansPlugin #678

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

Conversation

yousif-bugsnag
Copy link
Contributor

Goal

Improves the handling of span timoeut timers in BugsnagNativeSpansPlugin

  • Ensure that span references and associated timers are removed when the tracked span is overwritten by a new span with the same name.
  • Fixes a memory leak related to the usage of NSTimer for handling span timeouts in BugsnagNativeSpansPlugin

Design

the NSTimer based span timeout timers were occasionally not firing for some tracked spans (network spans) that are not ended, due to run loop issues. This was causing memory leaks due to timeout timers not firing being removed. This PR switches to using GCD for span timeout timers, which avoids the issue and also has lower overheads

In addition, span timeout timers for a given span are now removed if a new span with the same name is started, avoiding holding references to untracked spans unnecessarily

Testing

Tested manually

@yousif-bugsnag yousif-bugsnag requested a review from lemnik August 4, 2025 13:23
@yousif-bugsnag yousif-bugsnag changed the title Replace NSTimer with dispatch_source_t for ios span timeouts Improve span timoeut handling in BugsnagNativeSpansPlugin Aug 4, 2025
Copy link

github-actions bot commented Aug 4, 2025

Browser bundle size

NPM build

Package
Before 233.49 kB
After 233.49 kB
± No change

CDN build

Unminified Minfied Minified + gzipped
Before 118.26 kB 45.69 kB 13.19 kB
After 118.26 kB 45.69 kB 13.19 kB
± No change No change No change

Code coverage

Coverage values did not change👌.

Total:

Lines Branches Functions Statements
84.45%(+0%) 62.23%(+0%) 75.18%(+0%) 81.35%(+0%)

Generated against faa96e5 on 4 August 2025 at 13:28:33 UTC

Copy link
Contributor

@lemnik lemnik left a comment

Choose a reason for hiding this comment

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

LGTM

@yousif-bugsnag yousif-bugsnag merged commit a71c058 into integration/javascript-span-access Aug 5, 2025
27 checks passed
@yousif-bugsnag yousif-bugsnag deleted the ya/ios-span-tracking-timeout-fix branch August 5, 2025 11:54
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