-
-
Notifications
You must be signed in to change notification settings - Fork 455
Fix flaky SdkInitTests #4661
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
base: main
Are you sure you want to change the base?
Fix flaky SdkInitTests #4661
Conversation
Instructions and example for changelogPlease add an entry to Example: ## Unreleased
- Fix flaky SdkInitTests ([#4661](https://github.com/getsentry/sentry-java/pull/4661)) If none of the above apply, you can opt out of this check by adding |
"SystemEventsBreadcrumbsIntegration was unable to unregister receiver.", | ||
e); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Receiver Cleanup Fails on RejectedExecutionException
When unregisterReceiver()
catches a RejectedExecutionException
, the essential cleanup logic (unregistering the receiver, nullifying its reference, and updating isStopped
) is skipped. This leaves the receiver registered with the Android system and the integration in an inconsistent state, potentially causing resource leaks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is legit - could you extract the logic into unregisterReceiverInternal
or something and then call it in the catch
block? In that case I think it's fine to still do it on the calling thread
Performance metrics 🚀
|
Revision | Plain | With Sentry | Diff |
---|---|---|---|
ee747ae | 386.94 ms | 431.43 ms | 44.49 ms |
ee747ae | 405.43 ms | 485.70 ms | 80.28 ms |
ee747ae | 415.92 ms | 470.15 ms | 54.23 ms |
ee747ae | 358.21 ms | 389.41 ms | 31.20 ms |
ee747ae | 374.71 ms | 455.18 ms | 80.47 ms |
ee747ae | 396.82 ms | 441.67 ms | 44.86 ms |
ee747ae | 554.98 ms | 611.50 ms | 56.52 ms |
ee747ae | 382.73 ms | 435.41 ms | 52.68 ms |
ee747ae | 400.46 ms | 423.61 ms | 23.15 ms |
ee747ae | 357.79 ms | 421.84 ms | 64.05 ms |
App size
Revision | Plain | With Sentry | Diff |
---|---|---|---|
ee747ae | 1.58 MiB | 2.10 MiB | 530.95 KiB |
ee747ae | 1.58 MiB | 2.10 MiB | 530.95 KiB |
ee747ae | 1.58 MiB | 2.10 MiB | 530.95 KiB |
ee747ae | 1.58 MiB | 2.10 MiB | 530.95 KiB |
ee747ae | 1.58 MiB | 2.10 MiB | 530.95 KiB |
ee747ae | 1.58 MiB | 2.10 MiB | 530.95 KiB |
ee747ae | 1.58 MiB | 2.10 MiB | 530.95 KiB |
ee747ae | 1.58 MiB | 2.10 MiB | 530.95 KiB |
ee747ae | 1.58 MiB | 2.10 MiB | 530.95 KiB |
ee747ae | 1.58 MiB | 2.10 MiB | 530.95 KiB |
@@ -23,19 +24,51 @@ import shark.AndroidReferenceMatchers | |||
import shark.IgnoredReferenceMatcher | |||
import shark.ReferencePattern | |||
|
|||
/** Test connection status provider that always reports connected. */ | |||
private class AlwaysOnlineStatusProvider : IConnectionStatusProvider { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hm, wondering if it's still going to fail because the device does not have internet connection, but we're saying here that it does? Shall we also try to enable it via e.g. executing adb shell svc wifi enable
or something like that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i don't think it's a problem, because it's sending to localhost anyway, except for a single test (EnvelopeTests.sendProfiledTransaction
) that we may even remove
But we block sending the envelopes if there's no connection, so this is good
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, nice finds!
not sure if these make any actual difference
The only case where we use the |
📜 Description
CONNECTED
connectionTimeoutMillis
andreadTimeoutMillis
(500ms)Also handle
RejectedExecutionException
inSystemEventsBreadcrumbIntegration
💡 Motivation and Context
Tests could make Sentry think it's offline due to NO_RESPONSE thus directly using offline disk cache and never decrementing
relayIdlingResource
. Or they would run into the default timeout of 30s whereas the test only waits for 10s.💚 How did you test it?
📝 Checklist
sendDefaultPII
is enabled.🔮 Next steps