Skip to content

Conversation

stefanosiano
Copy link
Member

📜 Description

SentryAndroid.init now sets strictMode to Lax and reset it after it finishes
Removed few useless IO calls

💡 Motivation and Context

Closes #4261

💚 How did you test it?

📝 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

@stefanosiano stefanosiano marked this pull request as ready for review September 12, 2025 14:59
directory.getAbsolutePath());

for (File file : listFiles) {
for (File file : filteredListFiles) {
Copy link
Member Author

Choose a reason for hiding this comment

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

I found we were filtering the files in the directory, but then looped over all the files anyway
Was it by design or by accident?
And is there any risk in changing this?

Copy link
Member

Choose a reason for hiding this comment

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

I'm pretty sure that was an oversight. IMHO the risk is low as all non-envelope files will fail to be parsed / sent anyway.

cursor[bot]

This comment was marked as outdated.

Copy link
Contributor

Performance metrics 🚀

  Plain With Sentry Diff
Startup time 456.84 ms 574.61 ms 117.76 ms
Size 1.58 MiB 2.10 MiB 532.33 KiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
ee747ae 405.43 ms 485.70 ms 80.28 ms
ee747ae 357.79 ms 421.84 ms 64.05 ms
85d7417 347.21 ms 394.35 ms 47.15 ms
b750b96 408.98 ms 480.32 ms 71.34 ms
ee747ae 358.21 ms 389.41 ms 31.20 ms
ee747ae 415.92 ms 470.15 ms 54.23 ms
b750b96 421.25 ms 444.09 ms 22.84 ms
c8125f3 383.82 ms 441.66 ms 57.84 ms
ee747ae 554.98 ms 611.50 ms 56.52 ms
7314dbe 437.83 ms 505.64 ms 67.81 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
85d7417 1.58 MiB 2.10 MiB 533.44 KiB
b750b96 1.58 MiB 2.10 MiB 533.19 KiB
ee747ae 1.58 MiB 2.10 MiB 530.95 KiB
ee747ae 1.58 MiB 2.10 MiB 530.95 KiB
b750b96 1.58 MiB 2.10 MiB 533.20 KiB
c8125f3 1.58 MiB 2.10 MiB 532.32 KiB
ee747ae 1.58 MiB 2.10 MiB 530.95 KiB
7314dbe 1.58 MiB 2.10 MiB 533.45 KiB

directory.getAbsolutePath());

for (File file : listFiles) {
for (File file : filteredListFiles) {
Copy link
Member

Choose a reason for hiding this comment

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

I'm pretty sure that was an oversight. IMHO the risk is low as all non-envelope files will fail to be parsed / sent anyway.

@NotNull Sentry.OptionsConfiguration<SentryAndroidOptions> configuration) {
final @NotNull StrictMode.ThreadPolicy oldPolicy = StrictMode.getThreadPolicy();
final @NotNull StrictMode.VmPolicy oldVmPolicy = StrictMode.getVmPolicy();
StrictMode.setThreadPolicy(StrictMode.ThreadPolicy.LAX);
Copy link
Member

Choose a reason for hiding this comment

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

So I'm thinking this is too relaxing - e.g. the user init config (line 142) will also be under the LAX policy now, which is not what we want probably (e.g. if the user does I/O inside the init { } block this would not be flagged anymore). Can we be more specific and only wrap the actual offending calls into LAX?

Copy link
Member Author

Choose a reason for hiding this comment

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

i was also thinking about resetting the policies before the config init (user callback) and then set it back to lax until the end of init()
Wdyt?

Copy link
Member

Choose a reason for hiding this comment

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

that probably could do, but we're risking suppressing any new issues that might will have been introduced in the future outside the current ones. I'd really prefer to only target specific issues and set LAX as tight as possible, if it's not a big lift.

Copy link
Member

@romtsn romtsn left a comment

Choose a reason for hiding this comment

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

blocking so you don't accidentally merge since there's one approval already

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.

Ten DiskReadViolation's for single SentryAndroid.init
3 participants