fix(android): Prevent Relay from rejecting single-sample ANR profiles - #5872
Merged
Conversation
0xadam-brown
force-pushed
the
fix/anr-single-stack-trace
branch
from
July 30, 2026 08:50
9f6dad9 to
c4436f7
Compare
📲 Install BuildsAndroid
|
Contributor
Performance metrics 🚀
|
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| 6b019b7 | 343.31 ms | 417.23 ms | 73.91 ms |
| d15471f | 342.08 ms | 415.44 ms | 73.35 ms |
| 8687935 | 332.52 ms | 362.23 ms | 29.71 ms |
| 5b1a06b | 352.27 ms | 413.70 ms | 61.43 ms |
| 91bb874 | 314.47 ms | 440.00 ms | 125.53 ms |
| 0ee65e9 | 321.06 ms | 361.24 ms | 40.18 ms |
| e63ad34 | 323.67 ms | 390.33 ms | 66.67 ms |
| 33a08cc | 267.08 ms | 340.45 ms | 73.37 ms |
| 27d7cf8 | 397.90 ms | 498.65 ms | 100.75 ms |
| ee747ae | 405.43 ms | 485.70 ms | 80.28 ms |
App size
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| 6b019b7 | 0 B | 0 B | 0 B |
| d15471f | 1.58 MiB | 2.13 MiB | 559.54 KiB |
| 8687935 | 1.58 MiB | 2.19 MiB | 619.17 KiB |
| 5b1a06b | 0 B | 0 B | 0 B |
| 91bb874 | 1.58 MiB | 2.13 MiB | 559.07 KiB |
| 0ee65e9 | 0 B | 0 B | 0 B |
| e63ad34 | 0 B | 0 B | 0 B |
| 33a08cc | 1.58 MiB | 2.12 MiB | 555.28 KiB |
| 27d7cf8 | 1.58 MiB | 2.12 MiB | 549.42 KiB |
| ee747ae | 1.58 MiB | 2.10 MiB | 530.95 KiB |
Previous results on branch: fix/anr-single-stack-trace
Startup times
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| a25e5f3 | 314.71 ms | 366.82 ms | 52.11 ms |
| b8ab5da | 314.16 ms | 358.29 ms | 44.13 ms |
| c8211a6 | 319.65 ms | 367.65 ms | 48.01 ms |
App size
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| a25e5f3 | 0 B | 0 B | 0 B |
| b8ab5da | 0 B | 0 B | 0 B |
| c8211a6 | 0 B | 0 B | 0 B |
… (JAVA-550) Relay currently rejects ANR profiles with a single sample, even though they're still useful to customers. (Relay's policy was developed with continuous profiles in mind, before ANR profiles were a thing.) Commit updates our StackTraceConverter to add a second, synthetic sample whenever an ANR profile would otherwise only contain one. The synthetic sample duplicates the original, save for a minor offset to its timestamp (to avoid misleading the user about the ANRs cause or duration). # Conflicts: # CHANGELOG.md
0xadam-brown
force-pushed
the
fix/anr-single-stack-trace
branch
from
July 30, 2026 09:53
c4436f7 to
f7f9f2a
Compare
0xadam-brown
marked this pull request as ready for review
July 30, 2026 10:10
0xadam-brown
requested review from
adinauer,
markushi,
romtsn and
runningcode
as code owners
July 30, 2026 10:10
Contributor
|
This seems to me like a server side problem, can we fix this in Relay or would that break other SDKs? |
Member
Author
Good callout, and agreed that'd be ideal. As mentioned in the PR description, it'd be a big lift implementation-wise and it'd require a lot of coordination with the Relay folks. We could certainly do it at some point, but this gets us 90% of the way there at super low cost 👍 |
markushi
approved these changes
Jul 30, 2026
0xadam-brown
enabled auto-merge (squash)
July 30, 2026 14:55
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📜 Description
Relay currently rejects ANR profiles with a single sample, even though they're still useful to customers. This PR updates our StackTraceConverter to add a second, synthetic sample whenever an ANR profile would otherwise only contain one.
The synthetic sample duplicates the original, save for a minor offset to its timestamp. (Lets us avoid misleading the user about the ANRs cause or duration.)
💡 Motivation and Context
Customers occasionally see ANR events with no attached profile despite having sufficient quota and ANR profiling enabled. That's because Relay drops any profile chunk with fewer than two samples, and an ANR chunk can have exactly one sample if the main thread is caught on the very first poll after the 1-second suspicion threshold.
Relay's policy was developed with continuous profiles in mind, where a one-point series has no meaningful time axis. But for ANR profiles a single sample is highly actionable, as it shows exactly where the main thread was stuck when the ANR began.
Resolves: JAVA-550
Options considered
[A] Make it more likely that the SDK satisfies Relay's requirements -> In particular, narrow the polling interval used with ANRs. Would only reduce the risk of single-sample ANRs but not eliminate it + requires more resources from host app.
[B] Guarantee the SDK satisfies Relay's requirements -> The approach this PR takes.
[C] Relax Relay's requirements -> Too big of a lift to implement and would require substantial input by the Relay folks.
💚 How did you test it?
Unit tests + integration test + had my LLM check E2E against Relay and entire backend pipeline.
📝 Checklist
sendDefaultPIIis enabled.🔮 Next steps