@react-native-firebase/perf 16.7.0 → 17.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,10 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [17.0.0](https://github.com/invertase/react-native-firebase/compare/v16.7.0...v17.0.0) (2023-02-02)
7
+
8
+ **Note:** Version bump only for package @react-native-firebase/perf
9
+
6
10
  ## [16.7.0](https://github.com/invertase/react-native-firebase/compare/v16.6.0...v16.7.0) (2023-01-28)
7
11
 
8
12
  ### Features
@@ -3,53 +3,48 @@ package io.invertase.firebase.perf;
3
3
  /**
4
4
  * Copyright 2021 Google Inc. All Rights Reserved.
5
5
  *
6
- * Licensed under the Apache License, Version 2.0 (the "License");
7
- * you may not use this file except in compliance with the License.
8
- * You may obtain a copy of the License at
6
+ * <p>Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
7
+ * except in compliance with the License. You may obtain a copy of the License at
9
8
  *
10
- * http://www.apache.org/licenses/LICENSE-2.0
9
+ * <p>http://www.apache.org/licenses/LICENSE-2.0
11
10
  *
12
- * Unless required by applicable law or agreed to in writing, software
13
- * distributed under the License is distributed on an "AS IS" BASIS,
14
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- * See the License for the specific language governing permissions and
11
+ * <p>Unless required by applicable law or agreed to in writing, software distributed under the
12
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing permissions and
16
14
  * limitations under the License.
17
15
  */
18
-
19
16
  import android.app.Activity;
20
17
  import android.os.Build;
21
18
  import android.util.Log;
22
19
  import android.util.SparseIntArray;
23
20
  import android.view.WindowManager;
24
-
25
21
  import androidx.core.app.FrameMetricsAggregator;
26
-
27
22
  import com.google.firebase.perf.FirebasePerformance;
28
23
  import com.google.firebase.perf.metrics.Trace;
29
24
  import com.google.firebase.perf.util.Constants;
30
25
 
31
26
  /**
32
- * Utility class to capture Screen rendering information (Slow/Frozen frames) for the
33
- * {@code Activity} passed to the constructor {@link io.invertase.firebase.perf.ScreenTrace#ScreenTrace(Activity, String)}.
34
- * <p>
35
- * Learn more at https://firebase.google.com/docs/perf-mon/screen-traces?platform=android.
36
- * <p>
37
- * A slow screen rendering often leads to a UI Jank which creates a bad user experience. Below are
38
- * some tips and references to understand and fix common UI Jank issues:
39
- * - https://developer.android.com/topic/performance/vitals/render.html#fixing_jank
40
- * - https://youtu.be/CaMTIgxCSqU (Why 60fps?)
41
- * - https://youtu.be/HXQhu6qfTVU (Rendering Performance)
42
- * - https://youtu.be/1iaHxmfZGGc (Understanding VSYNC)
43
- * - https://www.youtube.com/playlist?list=PLOU2XLYxmsIKEOXh5TwZEv89aofHzNCiu (Android Performance Patterns)
44
- * <p>
45
- * References:
46
- * - Fireperf Source Code
27
+ * Utility class to capture Screen rendering information (Slow/Frozen frames) for the {@code
28
+ * Activity} passed to the constructor {@link
29
+ * io.invertase.firebase.perf.ScreenTrace#ScreenTrace(Activity, String)}.
30
+ *
31
+ * <p>Learn more at https://firebase.google.com/docs/perf-mon/screen-traces?platform=android.
32
+ *
33
+ * <p>A slow screen rendering often leads to a UI Jank which creates a bad user experience. Below
34
+ * are some tips and references to understand and fix common UI Jank issues: -
35
+ * https://developer.android.com/topic/performance/vitals/render.html#fixing_jank -
36
+ * https://youtu.be/CaMTIgxCSqU (Why 60fps?) - https://youtu.be/HXQhu6qfTVU (Rendering Performance)
37
+ * - https://youtu.be/1iaHxmfZGGc (Understanding VSYNC) -
38
+ * https://www.youtube.com/playlist?list=PLOU2XLYxmsIKEOXh5TwZEv89aofHzNCiu (Android Performance
39
+ * Patterns)
40
+ *
41
+ * <p>References: - Fireperf Source Code
47
42
  */
48
43
  public class ScreenTrace {
49
44
 
50
45
  private static final String TAG = "RNFirebasePerf";
51
46
  private static final String FRAME_METRICS_AGGREGATOR_CLASSNAME =
52
- "androidx.core.app.FrameMetricsAggregator";
47
+ "androidx.core.app.FrameMetricsAggregator";
53
48
 
54
49
  private final Activity activity;
55
50
  private final String traceName;
@@ -61,8 +56,8 @@ public class ScreenTrace {
61
56
  * Default constructor for this class.
62
57
  *
63
58
  * @param activity for which the screen traces should be recorded.
64
- * @param tag used as an identifier for the name to be used to log screen rendering
65
- * information (like "MyFancyScreen").
59
+ * @param tag used as an identifier for the name to be used to log screen rendering information
60
+ * (like "MyFancyScreen").
66
61
  * @implNote It requires hardware acceleration to be on or it throws.
67
62
  */
68
63
  public ScreenTrace(Activity activity, String tag) throws IllegalStateException {
@@ -75,7 +70,9 @@ public class ScreenTrace {
75
70
  boolean isScreenTraceSupported = checkScreenTraceSupport(activity);
76
71
 
77
72
  if (!isScreenTraceSupported) {
78
- throw new IllegalStateException("Device does not support screen traces. Hardware acceleration must be enabled and Android must not be 8.0 or 8.1.");
73
+ throw new IllegalStateException(
74
+ "Device does not support screen traces. Hardware acceleration must be enabled and Android"
75
+ + " must not be 8.0 or 8.1.");
79
76
  }
80
77
 
81
78
  frameMetricsAggregator = new FrameMetricsAggregator();
@@ -83,9 +80,7 @@ public class ScreenTrace {
83
80
 
84
81
  // region Public APIs
85
82
 
86
- /**
87
- * Starts recording the frame metrics for the screen traces.
88
- */
83
+ /** Starts recording the frame metrics for the screen traces. */
89
84
  public void recordScreenTrace() {
90
85
  Log.d(TAG, "Recording screen trace " + traceName);
91
86
 
@@ -97,7 +92,7 @@ public class ScreenTrace {
97
92
  * Stops recording screen traces and dispatches the trace capturing information on %age of
98
93
  * Slow/Frozen frames.
99
94
  *
100
- * Inspired by fireperf source.
95
+ * <p>Inspired by fireperf source.
101
96
  */
102
97
  public void sendScreenTrace() {
103
98
  if (perfScreenTrace == null) return;
@@ -143,12 +138,20 @@ public class ScreenTrace {
143
138
  perfScreenTrace.putMetric(Constants.CounterNames.FRAMES_FROZEN.toString(), frozenFrames);
144
139
  }
145
140
 
146
- Log.d(TAG, new StringBuilder()
147
- .append("sendScreenTrace ").append(traceName)
148
- .append(", name: ").append(getScreenTraceName())
149
- .append(", total_frames: ").append(totalFrames)
150
- .append(", slow_frames: ").append(slowFrames)
151
- .append(", frozen_frames: ").append(frozenFrames).toString());
141
+ Log.d(
142
+ TAG,
143
+ new StringBuilder()
144
+ .append("sendScreenTrace ")
145
+ .append(traceName)
146
+ .append(", name: ")
147
+ .append(getScreenTraceName())
148
+ .append(", total_frames: ")
149
+ .append(totalFrames)
150
+ .append(", slow_frames: ")
151
+ .append(slowFrames)
152
+ .append(", frozen_frames: ")
153
+ .append(frozenFrames)
154
+ .toString());
152
155
 
153
156
  // Stop and record trace
154
157
  perfScreenTrace.stop();
@@ -161,17 +164,30 @@ public class ScreenTrace {
161
164
  private static boolean checkScreenTraceSupport(Activity activity) {
162
165
  boolean isValidSDKVersion = checkSDKVersion();
163
166
  boolean hasFrameMetricsAggregatorClass = checkFrameMetricsAggregatorClass();
164
- boolean isActivityHardwareAccelerated = activity.getWindow() != null
165
- && ((activity.getWindow().getAttributes().flags & WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED) != 0);
166
-
167
-
168
- boolean supported = isValidSDKVersion && hasFrameMetricsAggregatorClass && isActivityHardwareAccelerated;
169
-
170
- Log.d(TAG, new StringBuilder()
171
- .append("isValidSDKVersion: ").append(isValidSDKVersion)
172
- .append("isScreenTraceSupported(").append(activity).append("): ").append(supported)
173
- .append(" [hasFrameMetricsAggregatorClass: ").append(hasFrameMetricsAggregatorClass)
174
- .append(", isActivityHardwareAccelerated: ").append(isActivityHardwareAccelerated).append("]").toString());
167
+ boolean isActivityHardwareAccelerated =
168
+ activity.getWindow() != null
169
+ && ((activity.getWindow().getAttributes().flags
170
+ & WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED)
171
+ != 0);
172
+
173
+ boolean supported =
174
+ isValidSDKVersion && hasFrameMetricsAggregatorClass && isActivityHardwareAccelerated;
175
+
176
+ Log.d(
177
+ TAG,
178
+ new StringBuilder()
179
+ .append("isValidSDKVersion: ")
180
+ .append(isValidSDKVersion)
181
+ .append("isScreenTraceSupported(")
182
+ .append(activity)
183
+ .append("): ")
184
+ .append(supported)
185
+ .append(" [hasFrameMetricsAggregatorClass: ")
186
+ .append(hasFrameMetricsAggregatorClass)
187
+ .append(", isActivityHardwareAccelerated: ")
188
+ .append(isActivityHardwareAccelerated)
189
+ .append("]")
190
+ .toString());
175
191
 
176
192
  return supported;
177
193
  }
@@ -184,9 +200,7 @@ public class ScreenTrace {
184
200
  return true;
185
201
  }
186
202
 
187
- /**
188
- * Inspired by fireperf source.
189
- */
203
+ /** Inspired by fireperf source. */
190
204
  private static boolean checkFrameMetricsAggregatorClass() {
191
205
  try {
192
206
  Class<?> initializerClass = Class.forName(FRAME_METRICS_AGGREGATOR_CLASSNAME);
@@ -196,9 +210,7 @@ public class ScreenTrace {
196
210
  }
197
211
  }
198
212
 
199
- /**
200
- * Inspired by fireperf source.
201
- */
213
+ /** Inspired by fireperf source. */
202
214
  private String getScreenTraceName() {
203
215
  return Constants.SCREEN_TRACE_PREFIX + traceName;
204
216
  }
@@ -105,24 +105,24 @@ public class UniversalFirebasePerfModule extends UniversalFirebaseModule {
105
105
 
106
106
  Task<Void> startScreenTrace(Activity activity, int id, String identifier) {
107
107
  return Tasks.call(
108
- () -> {
109
- ScreenTrace screenTrace = new ScreenTrace(activity, identifier);
110
- screenTrace.recordScreenTrace();
111
- screenTraces.put(id, screenTrace);
108
+ () -> {
109
+ ScreenTrace screenTrace = new ScreenTrace(activity, identifier);
110
+ screenTrace.recordScreenTrace();
111
+ screenTraces.put(id, screenTrace);
112
112
 
113
- return null;
114
- });
113
+ return null;
114
+ });
115
115
  }
116
116
 
117
117
  Task<Void> stopScreenTrace(int id) {
118
118
  return Tasks.call(
119
- () -> {
120
- ScreenTrace trace = screenTraces.get(id);
121
- trace.sendScreenTrace();
122
- screenTraces.remove(id);
119
+ () -> {
120
+ ScreenTrace trace = screenTraces.get(id);
121
+ trace.sendScreenTrace();
122
+ screenTraces.remove(id);
123
123
 
124
- return null;
125
- });
124
+ return null;
125
+ });
126
126
  }
127
127
 
128
128
  Task<Void> startHttpMetric(int id, String url, String httpMethod) {
@@ -97,29 +97,29 @@ public class ReactNativeFirebasePerfModule extends ReactNativeFirebaseModule {
97
97
  }
98
98
 
99
99
  module
100
- .startScreenTrace(currentActivity, id, identifier)
101
- .addOnCompleteListener(
102
- task -> {
103
- if (task.isSuccessful()) {
104
- promise.resolve(task.getResult());
105
- } else {
106
- rejectPromiseWithExceptionMap(promise, task.getException());
107
- }
108
- });
100
+ .startScreenTrace(currentActivity, id, identifier)
101
+ .addOnCompleteListener(
102
+ task -> {
103
+ if (task.isSuccessful()) {
104
+ promise.resolve(task.getResult());
105
+ } else {
106
+ rejectPromiseWithExceptionMap(promise, task.getException());
107
+ }
108
+ });
109
109
  }
110
110
 
111
111
  @ReactMethod
112
112
  public void stopScreenTrace(int id, Promise promise) {
113
113
  module
114
- .stopScreenTrace(id)
115
- .addOnCompleteListener(
116
- task -> {
117
- if (task.isSuccessful()) {
118
- promise.resolve(task.getResult());
119
- } else {
120
- rejectPromiseWithExceptionMap(promise, task.getException());
121
- }
122
- });
114
+ .stopScreenTrace(id)
115
+ .addOnCompleteListener(
116
+ task -> {
117
+ if (task.isSuccessful()) {
118
+ promise.resolve(task.getResult());
119
+ } else {
120
+ rejectPromiseWithExceptionMap(promise, task.getException());
121
+ }
122
+ });
123
123
  }
124
124
 
125
125
  @ReactMethod
package/lib/version.js CHANGED
@@ -1,2 +1,2 @@
1
1
  // Generated by genversion.
2
- module.exports = '16.7.0';
2
+ module.exports = '17.0.0';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-native-firebase/perf",
3
- "version": "16.7.0",
3
+ "version": "17.0.0",
4
4
  "author": "Invertase <oss@invertase.io> (http://invertase.io)",
5
5
  "description": "React Native Firebase - React Native Firebase provides native integration with Performance Monitoring to gain insight into key performance characteristics within your React Native application.",
6
6
  "main": "lib/index.js",
@@ -29,7 +29,7 @@
29
29
  "performance monitoring"
30
30
  ],
31
31
  "peerDependencies": {
32
- "@react-native-firebase/app": "16.7.0"
32
+ "@react-native-firebase/app": "17.0.0"
33
33
  },
34
34
  "dependencies": {
35
35
  "@expo/config-plugins": "^5.0.4"
@@ -37,5 +37,5 @@
37
37
  "publishConfig": {
38
38
  "access": "public"
39
39
  },
40
- "gitHead": "a94f371da16f9bf873c18b09541cbeb19960978d"
40
+ "gitHead": "53a436278f3c4cb23e1ddb7d2c9f14a65ce4abc1"
41
41
  }