Skip to content

Conversation

@buenaflor
Copy link
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
Copy link
Contributor

github-actions bot commented Nov 6, 2025

Fails
🚫 Please consider adding a changelog entry for the next release.

Instructions and example for changelog

Please add an entry to CHANGELOG.md to the "Unreleased" section. Make sure the entry includes this PR's number.

Example:

## Unreleased

### Features

- refactor `init` to use JNI/FFI ([#3324](https://github.com/getsentry/sentry-dart/pull/3324))

If none of the above apply, you can opt out of this check by adding #skip-changelog to the PR description or adding a skip-changelog label.

Generated by 🚫 dangerJS against fde01d6

@github-actions
Copy link
Contributor

github-actions bot commented Nov 6, 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:

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

@github-actions
Copy link
Contributor

github-actions bot commented Nov 6, 2025

iOS Performance metrics 🚀

  Plain With Sentry Diff
Startup time 1259.23 ms 1254.90 ms -4.33 ms
Size 5.53 MiB 6.02 MiB 502.32 KiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
6f47800 1247.52 ms 1259.37 ms 11.85 ms
6bcdc99 1257.16 ms 1264.96 ms 7.79 ms
765aa8b 1259.09 ms 1269.90 ms 10.82 ms
73a3c38 1263.37 ms 1277.90 ms 14.53 ms
0fb45d0 1273.24 ms 1286.44 ms 13.19 ms
aeb02f2 1244.29 ms 1256.55 ms 12.26 ms
f761369 1261.69 ms 1277.82 ms 16.12 ms
0fb3800 1256.60 ms 1266.28 ms 9.68 ms
e04b24b 1230.22 ms 1233.90 ms 3.67 ms
1f639ee 1252.43 ms 1257.82 ms 5.38 ms

App size

Revision Plain With Sentry Diff
6f47800 7.86 MiB 9.44 MiB 1.58 MiB
6bcdc99 5.53 MiB 6.00 MiB 479.95 KiB
765aa8b 7.86 MiB 9.44 MiB 1.58 MiB
73a3c38 7.86 MiB 9.44 MiB 1.58 MiB
0fb45d0 7.86 MiB 9.44 MiB 1.58 MiB
aeb02f2 7.86 MiB 9.44 MiB 1.58 MiB
f761369 7.86 MiB 9.44 MiB 1.58 MiB
0fb3800 7.86 MiB 9.44 MiB 1.58 MiB
e04b24b 5.53 MiB 6.00 MiB 480.00 KiB
1f639ee 5.53 MiB 6.00 MiB 479.95 KiB

Comment on lines -200 to -203
if (!sentryFlutter.autoPerformanceTracingEnabled) {
return null
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

removing it here, we have this check in the Dart side

final ObjCObjectBase Function(Object) _defaultObjcConverter = (obj) {
return switch (obj) {
bool b => b ? 1.toNSNumber() : 0.toNSNumber(),
bool b => NSNumberCreation.numberWithBool(b),
Copy link
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
#endif
}

@objc(setBeforeSend:packages:integrations:)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Don't think we need different naming for objc, as this will never be called from Swift directly.

Copy link
Contributor Author

@buenaflor buenaflor Nov 11, 2025

Choose a reason for hiding this comment

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

This is so it's more explicit how the name is generated for objc

without it it's setBeforeSendWithOptions(...) by default

this took a lot of time away from me because I couldn't figure out why the app was crashing and it turns out I should've used setBeforeSendWithOptions in SentryFlutterPlugin.h when creating the bindings instead of only setBeforeSend.

In the end I decided to add this so it's explicit how it's converted

I don't mind reverting it, though I think it would be helpful for the future to be more specific

: e as Object
],
List<dynamic> l => _deepConvertListNonNull(l),
_ => value as Object,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Also here, toObjCObject not needed?

Copy link
Contributor Author

@buenaflor buenaflor Nov 11, 2025

Choose a reason for hiding this comment

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

same comment as above, this function doesn't do any objc conversions

- '-I./temp/Sentry.framework/Headers/'
- '-I./temp/Sentry.framework/PrivateHeaders/'
- '-I./ios/sentry_flutter/Sources/sentry_flutter_objc/'
- -DFFIGEN=1
Copy link
Collaborator

Choose a reason for hiding this comment

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

What does this compiler option do?

Copy link
Contributor Author

@buenaflor buenaflor Nov 11, 2025

Choose a reason for hiding this comment

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

See ffigen_objc_imports.h

#ifdef FFIGEN
// Only included while running ffigen (provide paths in compiler-opts).
#import "PrivateSentrySDKOnly.h"
#import "Sentry-Swift.h"
#import "SentryOptions.h"
#import "SentryScope.h"
#endif

if we dont have this it will complain when compiling the app. We only need these headers when we use ffigen

high(resolutionScalingFactor: 1.0),
medium(resolutionScalingFactor: 1.0),
low(resolutionScalingFactor: 0.8);
high(resolutionScalingFactor: 1.0, level: 2),
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why the addition of level?

Copy link
Contributor Author

@buenaflor buenaflor Nov 11, 2025

Choose a reason for hiding this comment

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

so we can map it directly to cocoa quality:

quality: options.replay.quality.level,

alternatively we could remove it and just do it on the call site

@buenaflor
Copy link
Contributor Author

I'm currently working on optimizing the JNI bindings so it only creates bindings for fields and methods we specify

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