Skip to content

Improve performance of frames tracking #2854

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

Merged
merged 20 commits into from
Apr 15, 2025

Conversation

buenaflor
Copy link
Contributor

@buenaflor buenaflor commented Apr 11, 2025

📜 Description

Note: this will be merged into v8

We can update v9 afterwards

Current implementation

  • Every frame start and end create DateTime objects
  • Every frame will execute the FrameTimingCallback
  • The SentryDelayedFramesTracker receives the callback and then judges whether the frame is delayed or not
  • Leads to unnecessary overhead since every frame triggers the callback

New implementation

  • Only collect frame data if the tracking is enabled (guarded by isTrackingEnabled flag)
  • Use stopwatch instead of DateTime object
  • If we captured a delayed frame with the stopwatch, only then will we create datetime objects and execute the FrameTimingCallback

💡 Motivation and Context

There has been some reports of stutters or slowness when using the frames tracking.

💚 How did you test it?

📝 Checklist

  • I reviewed submitted code
  • I added tests to verify changes
  • No new PII added or SDK only sends newly added PII if sendDefaultPii is enabled
  • I updated the docs if needed
  • All tests passing
  • No breaking changes

🔮 Next steps

Copy link

codecov bot commented Apr 11, 2025

Codecov Report

Attention: Patch coverage is 95.55556% with 2 lines in your changes missing coverage. Please review.

Please upload report for BASE (temp/8.14.2@2a30a8a). Learn more about missing BASE report.

Files with missing lines Patch % Lines
flutter/lib/src/binding_wrapper.dart 93.10% 2 Missing ⚠️
Additional details and impacted files
@@              Coverage Diff               @@
##             temp/8.14.2    #2854   +/-   ##
==============================================
  Coverage               ?   92.10%           
==============================================
  Files                  ?       91           
  Lines                  ?     2963           
  Branches               ?        0           
==============================================
  Hits                   ?     2729           
  Misses                 ?      234           
  Partials               ?        0           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@buenaflor buenaflor requested a review from denrase April 14, 2025 12:14
@buenaflor buenaflor marked this pull request as ready for review April 14, 2025 13:49
@buenaflor buenaflor merged commit 5c63e2d into temp/8.14.2 Apr 15, 2025
60 checks passed
@buenaflor buenaflor deleted the improve-frame-tracking-perf-v8 branch April 15, 2025 11:14
buenaflor added a commit that referenced this pull request Apr 24, 2025
* Fix: Improve platform memory collection on windows/linux (#2798)

* deps: bump Android from `7.22.1` to `7.22.4` (#2810)

* update android deps

* Update CHANGELOG.md

* Fix adding runtime to contexts (#2813)

* Fix CHANGELOG formatting

* release: 8.14.1

* fix: `options.diagnosticLevel` not affecting logs (#2856)

* v9: Set log level to `warning` by default  (#2836)

* update

* update test

* update init native sdk test

* Update CHANGELOG

* Add additional test

* Update CHANGELOG

* Update CHANGELOG

* Update

* Update

* Fix test

* Fix test

* Fix analyze

* Remove prod scheme

* Update mocks

* Update mocks

* Improve performance of frames tracking (#2854)

* Improve performance

* Update tests

* Improve performance

* Formatting

* Separate function

* Remove separate function

* Update

* Improve frames tracking performance

* update naming

* Update

* update

* update

* Edge case

* Update mocks

* formatting

* Improvements

* Analyze

* Update mocks

* Update mocks

* Clean up `getSpan()` log (#2865)

* Remove unnecessary log and document the behaviour

* Typo

* Typo

* Add CHANGELOG entry

* release: 8.14.2

* Update

* Update

---------

Co-authored-by: Denis Andrašec <[email protected]>
Co-authored-by: getsentry-bot <[email protected]>
Co-authored-by: getsentry-bot <[email protected]>
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