Skip to content

Commit 3aff6fa

Browse files
misc(ttd): Add Android Logger when new frame event is not emitted (#4081)
1 parent d43a46b commit 3aff6fa

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
### Changes
2222

23+
- Add Android Logger when new frame event is not emitted ([#4081](https://github.com/getsentry/sentry-react-native/pull/4081))
2324
- React Native Tracing Deprecations ([#4073](https://github.com/getsentry/sentry-react-native/pull/4073))
2425
- `new ReactNativeTracing` to `reactNativeTracingIntegration()`
2526
- `new ReactNavigationInstrumentation` to `reactNativeTracingIntegration()`.

android/src/main/java/io/sentry/react/RNSentryOnDrawReporterManager.java

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,10 @@
1818

1919
import java.util.Map;
2020

21+
import io.sentry.ILogger;
2122
import io.sentry.SentryDate;
2223
import io.sentry.SentryDateProvider;
24+
import io.sentry.SentryLevel;
2325
import io.sentry.android.core.AndroidLogger;
2426
import io.sentry.android.core.BuildInfoProvider;
2527
import io.sentry.android.core.SentryAndroidDateProvider;
@@ -68,6 +70,8 @@ public Map getExportedCustomBubblingEventTypeConstants() {
6870

6971
public static class RNSentryOnDrawReporterView extends View {
7072

73+
private static final ILogger logger = new AndroidLogger("RNSentryOnDrawReporterView");
74+
7175
private final @Nullable ReactApplicationContext reactContext;
7276
private final @NotNull SentryDateProvider dateProvider = new SentryAndroidDateProvider();
7377
private final @Nullable Runnable emitInitialDisplayEvent;
@@ -96,6 +100,7 @@ public void setFullDisplay(boolean fullDisplay) {
96100
return;
97101
}
98102

103+
logger.log(SentryLevel.DEBUG, "[TimeToDisplay] Register full display event emitter.");
99104
registerForNextDraw(emitFullDisplayEvent);
100105
}
101106

@@ -104,16 +109,27 @@ public void setInitialDisplay(boolean initialDisplay) {
104109
return;
105110
}
106111

112+
logger.log(SentryLevel.DEBUG, "[TimeToDisplay] Register initial display event emitter.");
107113
registerForNextDraw(emitInitialDisplayEvent);
108114
}
109115

110116
private void registerForNextDraw(@Nullable Runnable emitter) {
117+
if (emitter == null) {
118+
logger.log(SentryLevel.ERROR, "[TimeToDisplay] Won't emit next frame drawn event, emitter is null.");
119+
return;
120+
}
121+
if (buildInfo == null) {
122+
logger.log(SentryLevel.ERROR, "[TimeToDisplay] Won't emit next frame drawn event, buildInfo is null.");
123+
return;
124+
}
111125
if (reactContext == null) {
126+
logger.log(SentryLevel.ERROR, "[TimeToDisplay] Won't emit next frame drawn event, reactContext is null.");
112127
return;
113128
}
114129

115130
@Nullable Activity activity = reactContext.getCurrentActivity();
116-
if (activity == null || emitter == null || buildInfo == null) {
131+
if (activity == null) {
132+
logger.log(SentryLevel.ERROR, "[TimeToDisplay] Won't emit next frame drawn event, reactContext is null.");
117133
return;
118134
}
119135

@@ -129,6 +145,7 @@ private void emitDisplayEvent(String type) {
129145
event.putDouble("newFrameTimestampInSeconds", endDate.nanoTimestamp() / 1e9);
130146

131147
if (reactContext == null) {
148+
logger.log(SentryLevel.ERROR, "[TimeToDisplay] Recorded next frame draw but can't emit the event, reactContext is null.");
132149
return;
133150
}
134151
reactContext

0 commit comments

Comments
 (0)