1818
1919import java .util .Map ;
2020
21+ import io .sentry .ILogger ;
2122import io .sentry .SentryDate ;
2223import io .sentry .SentryDateProvider ;
24+ import io .sentry .SentryLevel ;
2325import io .sentry .android .core .AndroidLogger ;
2426import io .sentry .android .core .BuildInfoProvider ;
2527import 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