Skip to content

Commit dd7aed9

Browse files
authored
Merge branch 'master' into mateuuszzzzz/fix-memory-leaks
2 parents 762adbc + 78e2e83 commit dd7aed9

File tree

3 files changed

+25
-16
lines changed

3 files changed

+25
-16
lines changed

packages/react-native-performance/android/src/main/java/com/oblador/performance/PerformanceModule.java

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -136,14 +136,6 @@ public String getName() {
136136
return PERFORMANCE_MODULE;
137137
}
138138

139-
public void addListener(String eventName) {
140-
141-
}
142-
143-
public void removeListeners(double count) {
144-
145-
}
146-
147139
private void emitNativeStartupTime() {
148140
safelyEmitMark(new PerformanceMark("nativeLaunchStart", StartTimeProvider.getStartTime()));
149141
safelyEmitMark(new PerformanceMark("nativeLaunchEnd", StartTimeProvider.getEndTime()));
@@ -196,7 +188,7 @@ private void emit(PerformanceMetric metric) {
196188
WritableMap map = Arguments.fromBundle(metric.getDetail());
197189
params.putMap("detail", map);
198190
}
199-
if (getReactApplicationContext().hasActiveCatalystInstance()) {
191+
if (getReactApplicationContext().hasActiveReactInstance()) {
200192
getReactApplicationContext()
201193
.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
202194
.emit("metric", params);
@@ -211,9 +203,11 @@ private void emit(PerformanceMark mark) {
211203
WritableMap map = Arguments.fromBundle(mark.getDetail());
212204
params.putMap("detail", map);
213205
}
214-
getReactApplicationContext()
215-
.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
216-
.emit("mark", params);
206+
if (getReactApplicationContext().hasActiveReactInstance()) {
207+
getReactApplicationContext()
208+
.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
209+
.emit("mark", params);
210+
}
217211
}
218212

219213
@Override
@@ -229,4 +223,13 @@ public void invalidate() {
229223
RNPerformance.getInstance().removeListener(this);
230224
ReactMarker.removeListener(contentAppearedListener);
231225
}
226+
227+
// Fix new arch runtime error
228+
public void addListener(String eventName) {
229+
230+
}
231+
232+
public void removeListeners(double count) {
233+
234+
}
232235
}

packages/react-native-performance/src/index.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { NativeEventEmitter, NativeModules, Platform } from 'react-native';
2-
import { createPerformance } from './performance';
32
import {
43
PerformanceReactNativeMark,
54
PerformanceMetric,
@@ -8,11 +7,15 @@ import {
87
installResourceLogger,
98
uninstallResourceLogger,
109
} from './resource-logger';
11-
const { PerformanceObserver, addEntry, performance } = createPerformance();
10+
import { PerformanceObserver, addEntry, performance } from './instance';
1211

13-
declare const global: { __turboModuleProxy: null | {} };
12+
declare const global: {
13+
__turboModuleProxy: null | {};
14+
RN$Bridgeless?: boolean;
15+
};
1416

15-
const isTurboModuleEnabled = global.__turboModuleProxy != null;
17+
const isTurboModuleEnabled =
18+
global.RN$Bridgeless || global.__turboModuleProxy != null;
1619

1720
const RNPerformanceManager = isTurboModuleEnabled
1821
? require('./NativeRNPerformanceManager').default
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import { createPerformance } from './performance';
2+
export const { PerformanceObserver, addEntry, performance } =
3+
createPerformance();

0 commit comments

Comments
 (0)