Skip to content

Prepare SDK for upcoming Session Replay API changes on Android #2977

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

Merged
merged 24 commits into from
Jul 22, 2025

Conversation

markushi
Copy link
Member

@markushi markushi commented Jun 4, 2025

📜 Description

As it may takes some time until the first frame is drawn, we're removing the replay configuration from the .start() call, instead the Android SDK expects onConfigurationChanged() to be called every time the top level widget size changes.

Example replay: https://sentry-sdks.sentry.io/replays/3f571c24990e4bb998b49eebef745313

The breaking changes were introduced in sentry-java 8.13.3

💚 How did you test it?

📝 Checklist

  • I reviewed submitted code
  • I added tests to verify changes
  • No new PII added or SDK only sends newly added PII if sendDefaultPii is enabled
  • I updated the docs if needed
  • All tests passing
  • No breaking changes

🔮 Next steps

Copy link
Contributor

github-actions bot commented Jun 4, 2025

🚨 Detected changes in high risk code 🚨

High-risk code has higher potential to break the SDK and may be hard to test. To prevent severe bugs, apply the rollout process for releasing such changes and be extra careful when changing and reviewing these files:

  • flutter/android/src/main/kotlin/io/sentry/flutter/SentryFlutterPlugin.kt
  • flutter/lib/src/native/java/android_replay_recorder.dart
  • flutter/lib/src/screenshot/recorder.dart

Copy link

codecov bot commented Jun 4, 2025

Codecov Report

Attention: Patch coverage is 89.58333% with 5 lines in your changes missing coverage. Please review.

Project coverage is 89.14%. Comparing base (4481076) to head (79502a8).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...r/lib/src/native/java/android_replay_recorder.dart 33.33% 2 Missing ⚠️
flutter/lib/src/screenshot/recorder.dart 60.00% 2 Missing ⚠️
...lutter/lib/src/native/java/sentry_native_java.dart 87.50% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2977      +/-   ##
==========================================
+ Coverage   87.91%   89.14%   +1.23%     
==========================================
  Files         287       97     -190     
  Lines        9766     3539    -6227     
==========================================
- Hits         8586     3155    -5431     
+ Misses       1180      384     -796     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@markushi markushi changed the title Prepare SDK for upcoming Android changes Prepare SDK for upcoming Session Replay API changes on Android Jun 4, 2025
Copy link
Contributor

github-actions bot commented Jun 4, 2025

iOS Performance metrics 🚀

  Plain With Sentry Diff
Startup time 1247.29 ms 1263.49 ms 16.20 ms
Size 7.86 MiB 9.44 MiB 1.58 MiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
b6c8720 1252.65 ms 1266.61 ms 13.96 ms
6f47800 1247.52 ms 1259.37 ms 11.85 ms
640ad0c 1241.04 ms 1253.96 ms 12.92 ms
73a3c38 1263.37 ms 1277.90 ms 14.53 ms
73dca78 1246.65 ms 1265.42 ms 18.76 ms
6ba4675 1223.12 ms 1238.17 ms 15.04 ms
93b7728 1247.23 ms 1264.87 ms 17.64 ms
2d34233 1258.19 ms 1268.92 ms 10.73 ms
ec78888 1251.37 ms 1269.40 ms 18.04 ms
dbd526b 1244.78 ms 1259.02 ms 14.24 ms

App size

Revision Plain With Sentry Diff
b6c8720 7.86 MiB 9.44 MiB 1.58 MiB
6f47800 7.86 MiB 9.44 MiB 1.58 MiB
640ad0c 7.86 MiB 9.44 MiB 1.58 MiB
73a3c38 7.86 MiB 9.44 MiB 1.58 MiB
73dca78 7.86 MiB 9.44 MiB 1.58 MiB
6ba4675 7.86 MiB 9.44 MiB 1.58 MiB
93b7728 7.86 MiB 9.44 MiB 1.58 MiB
2d34233 7.86 MiB 9.44 MiB 1.58 MiB
ec78888 7.86 MiB 9.44 MiB 1.58 MiB
dbd526b 7.86 MiB 9.44 MiB 1.58 MiB

Previous results on branch: markushi/feat/android-replay-api-changes

Startup times

Revision Plain With Sentry Diff
7267eb0 1249.64 ms 1270.31 ms 20.67 ms
935def9 1260.27 ms 1267.14 ms 6.87 ms
32ffe84 1265.10 ms 1278.28 ms 13.18 ms

App size

Revision Plain With Sentry Diff
7267eb0 7.86 MiB 9.44 MiB 1.58 MiB
935def9 7.86 MiB 9.44 MiB 1.58 MiB
32ffe84 7.86 MiB 9.44 MiB 1.58 MiB

@romtsn romtsn requested a review from vaind June 4, 2025 11:27
@buenaflor buenaflor changed the base branch from main to deps/flutter/scripts/update-android.sh/8.14.0 June 24, 2025 22:37
Copy link
Contributor

@buenaflor buenaflor left a comment

Choose a reason for hiding this comment

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

looks good to me, only thing is changelog is still missing

@bruno-garcia bruno-garcia force-pushed the deps/flutter/scripts/update-android.sh/8.14.0 branch 2 times, most recently from 07c0eb3 to 94ca61e Compare June 25, 2025 10:37
@buenaflor buenaflor changed the base branch from deps/flutter/scripts/update-android.sh/8.14.0 to deps/flutter/scripts/update-android.sh/8.16.0 June 27, 2025 12:58
@bruno-garcia bruno-garcia force-pushed the deps/flutter/scripts/update-android.sh/8.16.0 branch 13 times, most recently from 6fcd250 to 7d97873 Compare July 4, 2025 08:32
@buenaflor
Copy link
Contributor

Tested locally in release mode, works well

@buenaflor
Copy link
Contributor

bugbot run

cursor[bot]

This comment was marked as outdated.

@buenaflor buenaflor marked this pull request as ready for review July 22, 2025 10:57
@buenaflor
Copy link
Contributor

@sentry review

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Bug: Scheduler Bugs: Division by Zero, Null Cast

The ScheduledScreenshotRecorder._restartScheduler method contains two bugs:

  1. Division by zero: Calculating frameDuration divides by config.frameRate. If config.frameRate is 0 (which the Android plugin can pass, is not validated, and the existing assert is disabled in release mode), a division by zero occurs.
  2. Null cast exception: After super.config is checked for null and the method returns early, subsequent code uses the config getter. This getter performs an unsafe cast (super.config as ScheduledScreenshotRecorderConfig), leading to a Null cast exception if super.config was null.

flutter/lib/src/replay/scheduled_recorder.dart#L73-L79

if (super.config == null) {
return;
}
assert(config.frameRate > 0);
var frameDuration = Duration(milliseconds: 1000 ~/ config.frameRate);

Fix in CursorFix in Web


Was this report helpful? Give feedback by reacting with 👍 or 👎

@buenaflor buenaflor merged commit 0fb45d0 into main Jul 22, 2025
70 checks passed
@buenaflor buenaflor deleted the markushi/feat/android-replay-api-changes branch July 22, 2025 12:48
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