Skip to content

fix(profiling): Cancel a pending stop when the profiler is started again - #6291

Open
alwx wants to merge 2 commits into
mainfrom
alwx/bugfix/continuous-profiler-restart
Open

alwx wants to merge 2 commits into
mainfrom
alwx/bugfix/continuous-profiler-restart

Conversation

@alwx

@alwx alwx commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

📜 Description

AndroidContinuousProfiler and PerfettoContinuousProfiler now reset shouldStop on every sampled startProfiler call. A start call that comes before a requested stop takes effect now cancels the stop, in both MANUAL and TRACE mode. A manual start while the profiler runs is now an expected call, so the Perfetto profiler logs it at DEBUG level, like the legacy profiler.

💡 Motivation and Context

stopProfiler only sets shouldStop, and the profiler stops when the current 60 second chunk ends. A start call before that was ignored because the profiler was still running, so the profile ended at the end of the chunk while sampled spans were still active. The legacy profiler also never reset shouldStop, so after the first stop every later profile ended after one chunk. React Native hit this in its UI profiling fix (getsentry/sentry-react-native#6916), where JS starts and stops the native profiler for back-to-back transactions.

💚 How did you test it?

Wrote tests + verified myself.

📝 Checklist

  • I added GH Issue ID & Linear ID
  • I added tests to verify the changes.
  • No new PII added or SDK only sends newly added PII if sendDefaultPII is enabled.
  • I updated the docs if needed.
  • I updated the wizard if needed.
  • Review from the native team if needed.
  • No breaking change or entry added to the changelog.
  • No breaking change for hybrid SDKs or communicated to hybrid SDKs.
  • Public API changes reviewed by another Mobile SDK team member or implemented according to the develop docs spec.

alwx added 2 commits October 20, 2026 14:45
A stop request only sets shouldStop, and the profiler stops when the
current chunk ends. A start call before that was ignored because the
profiler was still running, and shouldStop stayed set. So the profiler
stopped at the end of the chunk, even in TRACE mode while sampled spans
were active. The legacy profiler also never reset shouldStop, so after
the first stop every later profile ended after one chunk.

Reset shouldStop on every sampled start call in AndroidContinuousProfiler
and PerfettoContinuousProfiler. A manual start while the profiler runs
is now an expected call, so the Perfetto profiler logs it at DEBUG
level like the legacy profiler.
@sentry

sentry Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

📲 Install Builds

Android

🔗 App Name App ID Version Configuration
SDK Size io.sentry.tests.size 8.61.0 (1) release

⚙️ sentry-android Build Distribution Settings

@alwx
alwx marked this pull request as ready for review October 20, 2026 13:57

This branch has not been deployed

No deployments
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.

1 participant