Skip to content
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

Reduce flush timeout to 4s on Android to avoid ANRs #2858

Merged
merged 3 commits into from
Jul 21, 2023

Conversation

markushi
Copy link
Member

@markushi markushi commented Jul 20, 2023

📜 Description

Reduce flush timeout to 4s on Android to avoid ANRs

💡 Motivation and Context

Fixes #2732

💚 How did you test it?

📝 Checklist

  • I reviewed the submitted code.
  • 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.
  • 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

@github-actions
Copy link
Contributor

github-actions bot commented Jul 20, 2023

Messages
📖 Do not forget to update Sentry-docs with your feature once the pull request gets approved.

Generated by 🚫 dangerJS against 69547e4

@github-actions
Copy link
Contributor

github-actions bot commented Jul 20, 2023

Performance metrics 🚀

  Plain With Sentry Diff
Startup time 269.20 ms 309.24 ms 40.04 ms
Size 1.72 MiB 2.29 MiB 575.29 KiB

Previous results on branch: feat/flush-timeout-android

Startup times

Revision Plain With Sentry Diff
9349bdf 286.84 ms 366.60 ms 79.76 ms

App size

Revision Plain With Sentry Diff
9349bdf 1.72 MiB 2.29 MiB 575.31 KiB

@codecov
Copy link

codecov bot commented Jul 20, 2023

Codecov Report

Patch coverage: 100.00% and project coverage change: +0.04 🎉

Comparison is base (9020d1b) 81.26% compared to head (69547e4) 81.31%.

Additional details and impacted files
@@               Coverage Diff                @@
##             feat/7.0.0    #2858      +/-   ##
================================================
+ Coverage         81.26%   81.31%   +0.04%     
- Complexity         4560     4564       +4     
================================================
  Files               350      351       +1     
  Lines             16866    16867       +1     
  Branches           2272     2272              
================================================
+ Hits              13706    13715       +9     
+ Misses             2219     2211       -8     
  Partials            941      941              
Impacted Files Coverage Δ
sentry/src/main/java/io/sentry/Hub.java 75.17% <ø> (ø)
sentry/src/main/java/io/sentry/SentryOptions.java 80.70% <ø> (+0.74%) ⬆️
sentry/src/main/java/io/sentry/SentryTracer.java 94.98% <100.00%> (+0.01%) ⬆️
...y/src/main/java/io/sentry/cache/EnvelopeCache.java 65.36% <100.00%> (ø)
...ry/src/main/java/io/sentry/util/LazyEvaluator.java 100.00% <100.00%> (ø)

... and 1 file with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@romtsn
Copy link
Member

romtsn commented Jul 20, 2023

@markushi there's one place where I'd like to keep the default 15s for flush timeout and it's this

public boolean waitPreviousSessionFlush() {
try {
return previousSessionLatch.await(options.getFlushTimeoutMillis(), TimeUnit.MILLISECONDS);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
options.getLogger().log(DEBUG, "Timed out waiting for previous session to flush.");
}
return false;
}

when we're waiting for the previous unfinished session to be flushed to disk. Would it be possible to keep the 15s value there (we could just have a constant actually)?

@@ -429,7 +431,9 @@ public void discard(final @NotNull SentryEnvelope envelope) {
/** Awaits until the previous session (if any) is flushed to its own file. */
public boolean waitPreviousSessionFlush() {
try {
return previousSessionLatch.await(options.getFlushTimeoutMillis(), TimeUnit.MILLISECONDS);
// use fixed timeout instead of configurable options.getFlushTimeoutMillis() to ensure there's
// enough time to flush the session to disk
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@romtsn if you've better reasoning here, please adapt the comment 😊

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, it's good!

@markushi markushi merged commit 3838091 into feat/7.0.0 Jul 21, 2023
@markushi markushi deleted the feat/flush-timeout-android branch July 21, 2023 08:39
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.

3 participants