dd-sdk-flutter
dd-sdk-flutter copied to clipboard
Persistent unexplained logs
Describe the bug
W/Datadog ( 3009): [_dd.sdk_core.default]: A RUM event was detected, but no view is active. To track views automatically, try calling the RumConfiguration.Builder.useViewTrackingStrategy() method.
W/Datadog ( 3009): You can also track views manually using the RumMonitor.startView() and RumMonitor.stopView() methods.
Reproduction steps
final originalOnError = FlutterError.onError;
FlutterError.onError = (details) {
DatadogSdk.instance.rum?.handleFlutterError(details);
originalOnError?.call(details);
};
final platformOriginalOnError = PlatformDispatcher.instance.onError;
PlatformDispatcher.instance.onError = (e, st) {
DatadogSdk.instance.rum?.addErrorInfo(
e.toString(),
RumErrorSource.source,
stackTrace: st,
);
return platformOriginalOnError?.call(e, st) ?? false;
};
final configuration = DatadogConfiguration(
clientToken: datadogClientToken,
env: Config.instance.env,
site: DatadogSite.us1,
nativeCrashReportEnabled: true,
loggingConfiguration: DatadogLoggingConfiguration(),
rumConfiguration: DatadogRumConfiguration(
applicationId: datadogApplicationId,
sessionSamplingRate: 100.0,
reportFlutterPerformance: true,
),
firstPartyHosts: ['domain.com'],
)..enableHttpTracking();
await DatadogSdk.runApp(configuration, TrackingConsent.granted, () async {
runApp(
GetMaterialApp.router(
builder: (context, child) {
return MediaQuery(
data: MediaQuery.of(context).copyWith(
textScaler: const TextScaler.linear(1.0),
),
child: Overlay(
initialEntries: [
if (child != null) ...[
OverlayEntry(
builder: (context) => RumUserActionDetector(
rum: DatadogSdk.instance.rum,
child: child,
),
),
],
],
),
);
},
theme: ThemeData(
useMaterial3: true,
colorSchemeSeed: TWColor.lightBlue500,
),
title: "myApp",
themeMode: ThemeMode.light,
routeInformationParser: AppPages.router.routeInformationParser,
routeInformationProvider: AppPages.router.routeInformationProvider,
routerDelegate: AppPages.router.routerDelegate,
debugShowCheckedModeBanner: false,
localizationsDelegates: const [
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
GlobalCupertinoLocalizations.delegate,
],
supportedLocales: const [
Locale('ko', 'KR'),
],
locale: const Locale('ko'),
),
);
});
I don't know why, but I keep getting the above log periodically.
SDK logs
No response
Expected behavior
No response
Affected SDK versions
2.3.0
Latest working SDK version
No response
Did you confirm if the latest SDK version fixes the bug?
Yes
Flutter Version
3.22.0
Setup Type
No response
Device Information
No response
Other relevant information
No response
Hi @ChanghyeonYoon ,
This occurs when we're trying to report RUM events with no active view, though the error is coming from the Android native SDK (hence the reference to functions that don't exist in the Flutter SDK).
One major culprit of this warning I realized recently is reportFlutterPerformance, which attempts to report performance metrics even when no view is active, which can get noisy on Android.
However, the best way to avoid it is to try to make sure you always have an active view, usually by having your Router call startView / stopView whenever your view changes.
Performance metric events no longer produce log spam in Datadog iOS SDK version 2.22.0 and Datadog Android SDK version 2.17.0. It should be fixed in the next release.
I get this even if I have the observer, like:
return MaterialApp(
....
navigatorObservers: [
DatadogNavigationObserver(datadogSdk: DatadogSdk.instance),
],
);
Is that the expected behavior? it seems to me that if we attach this, DD should automatically track the active view
It should yes, but there are some situations where either the observer could miss a view, by mistake or by design. There are also situations where there can be a few frames where Flutter is reporting performance metrics but we haven't recorded a new view being active (this is very common for web views for example).
Either way, the performance metric isn't an event you're triggering, so the warning wasn't very useful. The warning will still come up in situations where you attempt to add events (such as by calling addAction) but now view is active.
Minor update on this issue - a partial fix has been implemented in 2.11.0 but something is still causing these logs specifically when transitioning to WebView tracking.
So the general case for this should be solved, but I'm going to leave it open to track fixing the specific case of when a WebView tracking.