Skip to content

perf(android): [Init Reflection 3] Gate Compose class probes behind their features#5637

Open
runningcode wants to merge 3 commits into
no/perf-init-reflection-cachefrom
no/perf-init-reflection-gate-compose
Open

perf(android): [Init Reflection 3] Gate Compose class probes behind their features#5637
runningcode wants to merge 3 commits into
no/perf-init-reflection-cachefrom
no/perf-init-reflection-gate-compose

Conversation

@runningcode

@runningcode runningcode commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

PR Stack (Init Reflection)


Part of JAVA-587

📜 Description

The Compose gesture and view-hierarchy class lookups ran during init regardless of configuration. Probing androidx.compose.ui.node.Owner is the most expensive lookup in the trace (it triggers Owner.<clinit> before [Init Reflection 1]).

This gates them behind the features that actually consume them:

  • gesture locators (and their Compose probes) → enableUserInteractionBreadcrumbs || enableUserInteractionTracing
  • Compose view-hierarchy exporter probe → attachViewHierarchy (default false)

Repeated COMPOSE_CLASS_NAME probes across the two blocks are deduplicated by the LoadClass cache from [Init Reflection 2].

💡 Motivation and Context

Third of three stacked PRs reducing reflection cost on the init path (customer-provided Perfetto trace, Reduce SDK init time [Android]).

💚 How did you test it?

New AndroidOptionsInitializerTest cases: no gesture locators when user interaction tracking is disabled; no Compose view-hierarchy exporter when attachViewHierarchy is off; exporter present when enabled and Compose is available. Full sentry-android-core unit tests pass.

📝 Checklist

  • I added tests to verify the changes.
  • No new PII added or SDK only sends newly added PII if sendDefaultPII is enabled.
  • No breaking change or entry added to the changelog.

🔮 Next steps

Top of the Init Reflection stack.

⏱️ Pixel 3 benchmark (ART method trace → Perfetto trace_processor)

With user interaction tracking and view hierarchy capture disabled, the Compose class probes init used to run unconditionally:

old (ungated) new (gated)
Compose class probes 3 0
resulting ClassNotFoundException constructions 9 0

⚠️ Merge this PR using a merge commit (not squash). Only the collection branch is squash-merged into main.

runningcode and others added 2 commits June 25, 2026 13:34
The Compose gesture and view hierarchy class lookups ran during init
regardless of configuration. Gate the gesture locators behind
enableUserInteractionBreadcrumbs/Tracing and the Compose view hierarchy
exporter behind attachViewHierarchy, so the Compose class probes only
run when a feature that consumes them is enabled. Repeated probes of the
Compose class across both blocks are deduplicated by LoadClass's cache.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@sentry

sentry Bot commented Jun 25, 2026

Copy link
Copy Markdown

📲 Install Builds

Android

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

⚙️ sentry-android Build Distribution Settings

@github-actions

Copy link
Copy Markdown
Contributor

Performance metrics 🚀

  Plain With Sentry Diff
Startup time 327.50 ms 391.60 ms 64.10 ms
Size 0 B 0 B 0 B

@linear-code

linear-code Bot commented Jun 25, 2026

Copy link
Copy Markdown

JAVA-587

@runningcode runningcode marked this pull request as ready for review June 25, 2026 12:03
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