Skip to content

enh: refactor init to use JNI/FFI#3324

Merged
buenaflor merged 99 commits into
mainfrom
enh/ffi-jni-init
Nov 17, 2025
Merged

enh: refactor init to use JNI/FFI#3324
buenaflor merged 99 commits into
mainfrom
enh/ffi-jni-init

Conversation

@buenaflor

@buenaflor buenaflor commented Nov 6, 2025

Copy link
Copy Markdown
Contributor

📜 Description

💡 Motivation and Context

💚 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

@github-actions

github-actions Bot commented Nov 6, 2025

Copy link
Copy Markdown
Contributor

🚨 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:

  • packages/flutter/android/src/main/kotlin/io/sentry/flutter/SentryFlutterPlugin.kt

@github-actions

github-actions Bot commented Nov 6, 2025

Copy link
Copy Markdown
Contributor

iOS Performance metrics 🚀

  Plain With Sentry Diff
Startup time 1260.88 ms 1266.24 ms 5.37 ms
Size 5.53 MiB 6.02 MiB 502.02 KiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
819c1e7 1250.59 ms 1249.08 ms -1.51 ms
765aa8b 1259.09 ms 1269.90 ms 10.82 ms
ad121c0 1275.04 ms 1280.59 ms 5.55 ms
de377fd 1252.28 ms 1254.76 ms 2.48 ms
192b44c 1269.08 ms 1275.52 ms 6.44 ms
e1ab497 1260.92 ms 1260.22 ms -0.69 ms
6ad8fc4 1263.70 ms 1266.06 ms 2.36 ms
5b9a0da 1249.69 ms 1250.71 ms 1.03 ms
c0dde50 1268.90 ms 1275.61 ms 6.71 ms
6bcdc99 1257.16 ms 1264.96 ms 7.79 ms

App size

Revision Plain With Sentry Diff
819c1e7 5.53 MiB 6.00 MiB 479.96 KiB
765aa8b 7.86 MiB 9.44 MiB 1.58 MiB
ad121c0 5.53 MiB 6.01 MiB 488.11 KiB
de377fd 20.71 MiB 22.43 MiB 1.73 MiB
192b44c 5.53 MiB 5.96 MiB 444.33 KiB
e1ab497 5.53 MiB 6.01 MiB 487.96 KiB
6ad8fc4 5.53 MiB 6.01 MiB 487.65 KiB
5b9a0da 5.53 MiB 5.96 MiB 444.32 KiB
c0dde50 5.53 MiB 6.01 MiB 488.14 KiB
6bcdc99 5.53 MiB 6.00 MiB 479.95 KiB

Previous results on branch: enh/ffi-jni-init

Startup times

Revision Plain With Sentry Diff
1f506d7 1255.16 ms 1253.69 ms -1.48 ms
48149f1 1240.53 ms 1252.12 ms 11.59 ms
89fb6c2 1250.77 ms 1255.64 ms 4.87 ms
37f0c51 1250.10 ms 1248.25 ms -1.85 ms
0f928f6 1247.59 ms 1255.63 ms 8.04 ms
21cac57 1259.12 ms 1269.06 ms 9.94 ms
ab4c77e 1267.45 ms 1275.17 ms 7.71 ms

App size

Revision Plain With Sentry Diff
1f506d7 5.53 MiB 6.02 MiB 501.99 KiB
48149f1 5.53 MiB 6.02 MiB 502.03 KiB
89fb6c2 5.53 MiB 6.02 MiB 502.04 KiB
37f0c51 5.53 MiB 6.02 MiB 502.02 KiB
0f928f6 5.53 MiB 6.02 MiB 502.02 KiB
21cac57 5.53 MiB 6.02 MiB 501.98 KiB
ab4c77e 5.53 MiB 6.02 MiB 502.31 KiB

Comment thread packages/flutter/example/lib/main.dart
final ObjCObjectBase Function(Object) _defaultObjcConverter = (obj) {
return switch (obj) {
bool b => b ? 1.toNSNumber() : 0.toNSNumber(),
bool b => NSNumberCreation.numberWithBool(b),

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

previous convert was wrong, it should've been using NSNumberCreation

@buenaflor buenaflor changed the title (DRAFT) enh: refactor init to use JNI/FFI enh: refactor init to use JNI/FFI Nov 11, 2025
@buenaflor
buenaflor marked this pull request as ready for review November 14, 2025 11:57
Comment thread packages/flutter/lib/src/native/java/sentry_native_java_init.dart

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Bug: Performance Tracking Ignores Disabled State

The autoPerformanceTracingEnabled check was removed from fetchNativeAppStartAsBytes, meaning app start metrics are now returned even when auto performance tracing is disabled. This changes behavior from the previous implementation where the function would return null early when autoPerformanceTracingEnabled was false, potentially causing unwanted performance tracking.

packages/flutter/android/src/main/kotlin/io/sentry/flutter/SentryFlutterPlugin.kt#L185-L196

@JvmStatic
fun fetchNativeAppStartAsBytes(): ByteArray? {
val appStartMetrics = AppStartMetrics.getInstance()
if (!appStartMetrics.isAppLaunchedInForeground ||
appStartMetrics.appStartTimeSpan.durationMs > APP_START_MAX_DURATION_MS
) {
Log.w(
"Sentry",
"Invalid app start data: app not launched in foreground or app start took too long (>60s)",
)
return null

Fix in Cursor Fix in Web


Comment thread packages/flutter/example/lib/main.dart
Comment thread packages/flutter/example/integration_test/integration_test.dart
Comment thread packages/flutter/example/lib/main.dart
Comment thread packages/flutter/example/lib/main.dart
@buenaflor
buenaflor merged commit d0aa4b6 into main Nov 17, 2025
137 checks passed
@buenaflor
buenaflor deleted the enh/ffi-jni-init branch November 17, 2025 10:30
buenaflor added a commit that referenced this pull request Jul 6, 2026
The v10 feature work pushed the with-Sentry APK size diff to ~1409 KiB,
past the 1350 KiB budget, failing the SDK metrics job on v10-branch and
every PR based on it. Raise diffMax to 1450 KiB, following the same
pattern as #3324 and #3567.

Co-Authored-By: Claude Fable 5 <[email protected]>
buenaflor added a commit that referenced this pull request Jul 6, 2026
* ref!: Make clone() internal; drop protocol clones

clone() on Hub, Scope, NoOpHub, HubAdapter and Sentry is intended
for SDK-internal use only, so mark it @internal.

The protocol clone() methods (Contexts and its children) were already
@deprecated and formed a dead subtree with no remaining callers, so
remove them along with the alias-only clone context test.

BREAKING CHANGE: The deprecated clone() on protocol classes is removed,
and clone() on Hub/Scope is now @internal.

Fixes GH-3824
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>

* ref: Rename feature flag copy() to clone()

Align internal naming with Hub.clone() and Scope.clone(). The copy
name existed only to avoid clashing with the deprecated public clone()
API, which this branch removes.

Co-Authored-By: Claude Fable 5 <[email protected]>

* test(flutter): Fix OnProcessSpan calls missing Hint

PR #3847 added a required hint parameter to OnProcessSpan but missed
the five call sites in thread_info_integration_test.dart, which landed
in parallel. This breaks compilation of the flutter test suite and the
analyze gate on v10-branch, failing CI for every PR based on it.

Co-Authored-By: Claude Fable 5 <[email protected]>

* chore(metrics): Raise Android binary size budget

The v10 feature work pushed the with-Sentry APK size diff to ~1409 KiB,
past the 1350 KiB budget, failing the SDK metrics job on v10-branch and
every PR based on it. Raise diffMax to 1450 KiB, following the same
pattern as #3324 and #3567.

Co-Authored-By: Claude Fable 5 <[email protected]>

---------

Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
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.

2 participants