Skip to content

Commit 793f4dc

Browse files
authored
Remove unused native frames integration (#3053)
* Remove native frames * Update * Update * Fix android compilation * Update CHANGELOG * Update CHANGELOG
1 parent 3e83702 commit 793f4dc

File tree

15 files changed

+52
-372
lines changed

15 files changed

+52
-372
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
### Enhancements
1111

1212
- Remove `SentryTimingsCallback` and use Flutter's `TimingsCallback` instead ([#3054](https://github.com/getsentry/sentry-dart/pull/3054))
13+
- Remove unused native frames integration ([#3053](https://github.com/getsentry/sentry-dart/pull/3053))
1314

1415
## 9.4.0
1516

dart/lib/src/native/c/sentry_native.dart

Lines changed: 0 additions & 1 deletion
This file was deleted.

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

Lines changed: 0 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ import io.sentry.Breadcrumb
2323
import io.sentry.DateUtils
2424
import io.sentry.HubAdapter
2525
import io.sentry.Sentry
26-
import io.sentry.android.core.ActivityFramesTracker
2726
import io.sentry.android.core.InternalSentrySdk
2827
import io.sentry.android.core.LoadClass
2928
import io.sentry.android.core.SentryAndroid
@@ -63,7 +62,6 @@ class SentryFlutterPlugin :
6362
)
6463

6564
private var activity: WeakReference<Activity>? = null
66-
private var framesTracker: ActivityFramesTracker? = null
6765
private var pluginRegistrationTime: Long? = null
6866

6967
override fun onAttachedToEngine(flutterPluginBinding: FlutterPlugin.FlutterPluginBinding) {
@@ -87,8 +85,6 @@ class SentryFlutterPlugin :
8785
"loadImageList" -> loadImageList(call, result)
8886
"closeNativeSdk" -> closeNativeSdk(result)
8987
"fetchNativeAppStart" -> fetchNativeAppStart(result)
90-
"beginNativeFrames" -> beginNativeFrames(result)
91-
"endNativeFrames" -> endNativeFrames(call.argument("id"), result)
9288
"setContexts" -> setContexts(call.argument("key"), call.argument("value"), result)
9389
"removeContexts" -> removeContexts(call.argument("key"), result)
9490
"setUser" -> setUser(call.argument("user"), result)
@@ -121,7 +117,6 @@ class SentryFlutterPlugin :
121117

122118
override fun onDetachedFromActivity() {
123119
activity = null
124-
framesTracker = null
125120
}
126121

127122
override fun onReattachedToActivityForConfigChanges(binding: ActivityPluginBinding) {
@@ -150,10 +145,6 @@ class SentryFlutterPlugin :
150145
SentryAndroid.init(context) { options ->
151146
sentryFlutter.updateOptions(options, args)
152147

153-
if (sentryFlutter.autoPerformanceTracingEnabled) {
154-
framesTracker = ActivityFramesTracker(LoadClass(), options)
155-
}
156-
157148
setupReplay(options)
158149
}
159150
result.success("")
@@ -291,52 +282,6 @@ class SentryFlutterPlugin :
291282
)
292283
}
293284
}
294-
295-
private fun beginNativeFrames(result: Result) {
296-
if (!sentryFlutter.autoPerformanceTracingEnabled) {
297-
result.success(null)
298-
return
299-
}
300-
301-
activity?.get()?.let {
302-
framesTracker?.addActivity(it)
303-
}
304-
result.success(null)
305-
}
306-
307-
private fun endNativeFrames(
308-
id: String?,
309-
result: Result,
310-
) {
311-
val activity = activity?.get()
312-
if (!sentryFlutter.autoPerformanceTracingEnabled || activity == null || id == null) {
313-
if (id == null) {
314-
Log.w("Sentry", "Parameter id cannot be null when calling endNativeFrames.")
315-
}
316-
result.success(null)
317-
return
318-
}
319-
320-
val sentryId = SentryId(id)
321-
framesTracker?.setMetrics(activity, sentryId)
322-
val metrics = framesTracker?.takeMetrics(sentryId)
323-
val total = metrics?.get("frames_total")?.value?.toInt() ?: 0
324-
val slow = metrics?.get("frames_slow")?.value?.toInt() ?: 0
325-
val frozen = metrics?.get("frames_frozen")?.value?.toInt() ?: 0
326-
327-
if (total == 0 && slow == 0 && frozen == 0) {
328-
result.success(null)
329-
} else {
330-
val frames =
331-
mapOf<String, Any?>(
332-
"totalFrames" to total,
333-
"slowFrames" to slow,
334-
"frozenFrames" to frozen,
335-
)
336-
result.success(frames)
337-
}
338-
}
339-
340285
private fun setContexts(
341286
key: String?,
342287
value: Any?,
@@ -518,8 +463,6 @@ class SentryFlutterPlugin :
518463

519464
private fun closeNativeSdk(result: Result) {
520465
HubAdapter.getInstance().close()
521-
framesTracker?.stop()
522-
framesTracker = null
523466

524467
result.success("")
525468
}

flutter/ios/sentry_flutter/Sources/sentry_flutter/SentryFlutterPlugin.swift

Lines changed: 0 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -87,12 +87,6 @@ public class SentryFlutterPlugin: NSObject, FlutterPlugin {
8787
case "fetchNativeAppStart":
8888
fetchNativeAppStart(result: result)
8989

90-
case "beginNativeFrames":
91-
beginNativeFrames(result: result)
92-
93-
case "endNativeFrames":
94-
endNativeFrames(result: result)
95-
9690
case "setContexts":
9791
let arguments = call.arguments as? [String: Any?]
9892
let key = arguments?["key"] as? String
@@ -513,59 +507,6 @@ public class SentryFlutterPlugin: NSObject, FlutterPlugin {
513507
#endif
514508
}
515509

516-
private var totalFrames: UInt = 0
517-
private var frozenFrames: UInt = 0
518-
private var slowFrames: UInt = 0
519-
520-
private func beginNativeFrames(result: @escaping FlutterResult) {
521-
#if os(iOS) || targetEnvironment(macCatalyst)
522-
guard PrivateSentrySDKOnly.isFramesTrackingRunning else {
523-
print("Native frames tracking not running.")
524-
result(nil)
525-
return
526-
}
527-
528-
let currentFrames = PrivateSentrySDKOnly.currentScreenFrames
529-
totalFrames = currentFrames.total
530-
frozenFrames = currentFrames.frozen
531-
slowFrames = currentFrames.slow
532-
533-
result(nil)
534-
#else
535-
result(nil)
536-
#endif
537-
}
538-
539-
private func endNativeFrames(result: @escaping FlutterResult) {
540-
#if os(iOS) || targetEnvironment(macCatalyst)
541-
guard PrivateSentrySDKOnly.isFramesTrackingRunning else {
542-
print("Native frames tracking not running.")
543-
result(nil)
544-
return
545-
}
546-
547-
let currentFrames = PrivateSentrySDKOnly.currentScreenFrames
548-
let total = max(Int(currentFrames.total) - Int(totalFrames), 0)
549-
let frozen = max(Int(currentFrames.frozen) - Int(frozenFrames), 0)
550-
let slow = max(Int(currentFrames.slow) - Int(slowFrames), 0)
551-
552-
if total <= 0 && frozen <= 0 && slow <= 0 {
553-
result(nil)
554-
return
555-
}
556-
557-
let item: [String: Any] = [
558-
"totalFrames": total,
559-
"frozenFrames": frozen,
560-
"slowFrames": slow
561-
]
562-
563-
result(item)
564-
#else
565-
result(nil)
566-
#endif
567-
}
568-
569510
private func setContexts(key: String?, value: Any?, result: @escaping FlutterResult) {
570511
guard let key = key else {
571512
result("")

flutter/lib/src/native/c/sentry_native.dart

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import 'package:meta/meta.dart';
1010
import '../../../sentry_flutter.dart';
1111
import '../../replay/replay_config.dart';
1212
import '../native_app_start.dart';
13-
import '../native_frames.dart';
1413
import '../sentry_native_binding.dart';
1514
import '../sentry_native_invoker.dart';
1615
import 'binding.dart' as binding;
@@ -111,12 +110,6 @@ class SentryNative with SentryNativeSafeInvoker implements SentryNativeBinding {
111110
throw UnsupportedError("Not supported on this platform");
112111
}
113112

114-
@override
115-
FutureOr<void> beginNativeFrames() {}
116-
117-
@override
118-
FutureOr<NativeFrames?> endNativeFrames(SentryId id) => null;
119-
120113
@override
121114
FutureOr<void> setUser(SentryUser? user) {
122115
if (user == null) {

flutter/lib/src/native/native_frames.dart

Lines changed: 0 additions & 18 deletions
This file was deleted.

flutter/lib/src/native/sentry_native_binding.dart

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import 'package:meta/meta.dart';
66
import '../../sentry_flutter.dart';
77
import '../replay/replay_config.dart';
88
import 'native_app_start.dart';
9-
import 'native_frames.dart';
109

1110
/// Provide typed methods to access native layer.
1211
@internal
@@ -24,10 +23,6 @@ abstract class SentryNativeBinding {
2423

2524
FutureOr<void> captureStructuredEnvelope(SentryEnvelope envelope);
2625

27-
FutureOr<void> beginNativeFrames();
28-
29-
FutureOr<NativeFrames?> endNativeFrames(SentryId id);
30-
3126
FutureOr<void> setUser(SentryUser? user);
3227

3328
FutureOr<void> addBreadcrumb(Breadcrumb breadcrumb);

flutter/lib/src/native/sentry_native_channel.dart

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import '../../sentry_flutter.dart';
1010
import '../replay/replay_config.dart';
1111
import 'method_channel_helper.dart';
1212
import 'native_app_start.dart';
13-
import 'native_frames.dart';
1413
import 'sentry_native_binding.dart';
1514
import 'sentry_native_invoker.dart';
1615
import 'sentry_safe_method_channel.dart';
@@ -120,16 +119,6 @@ class SentryNativeChannel
120119
Future<Map<String, dynamic>?> loadContexts() =>
121120
channel.invokeMapMethod<String, dynamic>('loadContexts');
122121

123-
@override
124-
Future<void> beginNativeFrames() => channel.invokeMethod('beginNativeFrames');
125-
126-
@override
127-
Future<NativeFrames?> endNativeFrames(SentryId id) async {
128-
final json = await channel.invokeMapMethod<String, dynamic>(
129-
'endNativeFrames', {'id': id.toString()});
130-
return (json != null) ? NativeFrames.fromJson(json) : null;
131-
}
132-
133122
@override
134123
Future<void> setUser(SentryUser? user) async {
135124
if (user == null) {

flutter/lib/src/navigation/sentry_navigator_observer.dart

Lines changed: 6 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ import 'package:sentry/src/sentry_tracer.dart';
1212
import '../../sentry_flutter.dart';
1313
import '../event_processor/flutter_enricher_event_processor.dart';
1414
import '../integrations/web_session_integration.dart';
15-
import '../native/native_frames.dart';
16-
import '../native/sentry_native_binding.dart';
1715
import '../web/web_session_handler.dart';
1816
import 'time_to_display_tracker.dart';
1917

@@ -87,8 +85,7 @@ class SentryNavigatorObserver extends RouteObserver<PageRoute<dynamic>> {
8785
_setRouteNameAsTransaction = setRouteNameAsTransaction,
8886
_routeNameExtractor = routeNameExtractor,
8987
_additionalInfoProvider = additionalInfoProvider,
90-
_ignoreRoutes = ignoreRoutes ?? [],
91-
_native = SentryFlutter.native {
88+
_ignoreRoutes = ignoreRoutes ?? [] {
9289
_isCreated = true;
9390
if (enableAutoTransactions) {
9491
_hub.options.sdk.addIntegration('UINavigationTracing');
@@ -117,25 +114,26 @@ class SentryNavigatorObserver extends RouteObserver<PageRoute<dynamic>> {
117114
final bool _setRouteNameAsTransaction;
118115
final RouteNameExtractor? _routeNameExtractor;
119116
final AdditionalInfoExtractor? _additionalInfoProvider;
120-
final SentryNativeBinding? _native;
121117
final List<String> _ignoreRoutes;
122118
TimeToDisplayTracker? _timeToDisplayTracker;
119+
123120
WebSessionHandler? _webSessionHandler;
121+
124122
@visibleForTesting
125123
WebSessionHandler? get webSessionHandler => _webSessionHandler;
126124

127125
ISentrySpan? _transaction;
128126

129127
static String? _currentRouteName;
130128

129+
@internal
130+
static String? get currentRouteName => _currentRouteName;
131+
131132
static bool _isCreated = false;
132133

133134
@internal
134135
static bool get isCreated => _isCreated;
135136

136-
@internal
137-
static String? get currentRouteName => _currentRouteName;
138-
139137
@override
140138
void didPush(Route<dynamic> route, Route<dynamic>? previousRoute) {
141139
super.didPush(route, previousRoute);
@@ -295,19 +293,6 @@ class SentryNavigatorObserver extends RouteObserver<PageRoute<dynamic>> {
295293
trimEnd: true,
296294
onFinish: (transaction) async {
297295
_transaction = null;
298-
final nativeFrames =
299-
await _native?.endNativeFrames(transaction.context.traceId);
300-
if (nativeFrames != null) {
301-
final measurements = nativeFrames.toMeasurements();
302-
for (final item in measurements.entries) {
303-
final measurement = item.value;
304-
transaction.setMeasurement(
305-
item.key,
306-
measurement.value,
307-
unit: measurement.unit,
308-
);
309-
}
310-
}
311296
},
312297
);
313298
// if _enableAutoTransactions is enabled but there's no traces sample rate
@@ -326,8 +311,6 @@ class SentryNavigatorObserver extends RouteObserver<PageRoute<dynamic>> {
326311
scope.span ??= _transaction;
327312
});
328313

329-
await _native?.beginNativeFrames();
330-
331314
await _timeToDisplayTracker?.track(transaction);
332315
}
333316

@@ -434,16 +417,3 @@ class RouteObserverBreadcrumb extends Breadcrumb {
434417
return args.toString();
435418
}
436419
}
437-
438-
extension NativeFramesMeasurement on NativeFrames {
439-
Map<String, SentryMeasurement> toMeasurements() {
440-
final total = SentryMeasurement.totalFrames(totalFrames);
441-
final slow = SentryMeasurement.slowFrames(slowFrames);
442-
final frozen = SentryMeasurement.frozenFrames(frozenFrames);
443-
return {
444-
total.name: total,
445-
slow.name: slow,
446-
frozen.name: frozen,
447-
};
448-
}
449-
}

0 commit comments

Comments
 (0)