Skip to content

refactor(lifecycle): Use single lifecycle observer #4567

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

Open
wants to merge 4 commits into
base: rz/perf/single-network-callback
Choose a base branch
from

Conversation

romtsn
Copy link
Member

@romtsn romtsn commented Jul 24, 2025

📜 Description

  • Refactors the integrations that subscribe for Lifecycle updates
    • There's only one callback registered in AppState now, upon initializing the SDK
    • The callback then is multi-casted to the internal listeners
    • It maintains the old behaviour where addObserver call would catch the new observer up to the current lifecycle state
  • Simplified SystemEventBreadcrumbsIntegration by removing a few unnecessary locks and calling unregisterReceiver from a background thread because it also does an IPC call

💡 Motivation and Context

easier to maintain SDK

💚 How did you test it?

manually + automated

📝 Checklist

  • 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.

🔮 Next steps

Use this new lifecycle approach to register/unregister NetworkCallback

Copy link
Contributor

github-actions bot commented Jul 24, 2025

Performance metrics 🚀

  Plain With Sentry Diff
Startup time 381.06 ms 407.08 ms 26.02 ms
Size 1.58 MiB 2.09 MiB 521.14 KiB

Baseline results on branch: rz/perf/single-network-callback

Startup times

Revision Plain With Sentry Diff
5993034 471.84 ms 493.10 ms 21.26 ms
c2f723e 382.31 ms 432.96 ms 50.65 ms

App size

Revision Plain With Sentry Diff
5993034 1.58 MiB 2.09 MiB 520.98 KiB
c2f723e 1.58 MiB 2.09 MiB 520.98 KiB

Previous results on branch: rz/perf/single-lifecycle-observer

Startup times

Revision Plain With Sentry Diff
6fd675a 403.43 ms 446.55 ms 43.13 ms

App size

Revision Plain With Sentry Diff
6fd675a 1.58 MiB 2.09 MiB 521.12 KiB

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