mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Fix broken systrace marker in getViewManagerNames
Summary: Noticed this marker was not properly ended in the case where an early return happens. The fact that that early return is happening there is problematic too, so added a warning to follow-up on. Changelog: [Internal] Reviewed By: NickGerleman Differential Revision: D39271917 fbshipit-source-id: 86dd5b1a46978629584f7cb0d615f2ad99d5a2f8
This commit is contained in:
committed by
Facebook GitHub Bot
parent
052617611d
commit
a888f0c0a1
@@ -961,39 +961,43 @@ public class ReactInstanceManager {
|
||||
|
||||
public Collection<String> getViewManagerNames() {
|
||||
Systrace.beginSection(TRACE_TAG_REACT_JAVA_BRIDGE, "ReactInstanceManager.getViewManagerNames");
|
||||
Collection<String> viewManagerNames = mViewManagerNames;
|
||||
if (viewManagerNames != null) {
|
||||
return viewManagerNames;
|
||||
}
|
||||
ReactApplicationContext context;
|
||||
synchronized (mReactContextLock) {
|
||||
context = (ReactApplicationContext) getCurrentReactContext();
|
||||
if (context == null || !context.hasActiveReactInstance()) {
|
||||
return Collections.emptyList();
|
||||
try {
|
||||
Collection<String> viewManagerNames = mViewManagerNames;
|
||||
if (viewManagerNames != null) {
|
||||
return viewManagerNames;
|
||||
}
|
||||
}
|
||||
|
||||
synchronized (mPackages) {
|
||||
if (mViewManagerNames == null) {
|
||||
Set<String> uniqueNames = new HashSet<>();
|
||||
for (ReactPackage reactPackage : mPackages) {
|
||||
SystraceMessage.beginSection(
|
||||
TRACE_TAG_REACT_JAVA_BRIDGE, "ReactInstanceManager.getViewManagerName")
|
||||
.arg("Package", reactPackage.getClass().getSimpleName())
|
||||
.flush();
|
||||
if (reactPackage instanceof ViewManagerOnDemandReactPackage) {
|
||||
Collection<String> names =
|
||||
((ViewManagerOnDemandReactPackage) reactPackage).getViewManagerNames(context);
|
||||
if (names != null) {
|
||||
uniqueNames.addAll(names);
|
||||
}
|
||||
}
|
||||
SystraceMessage.endSection(TRACE_TAG_REACT_JAVA_BRIDGE).flush();
|
||||
ReactApplicationContext context;
|
||||
synchronized (mReactContextLock) {
|
||||
context = (ReactApplicationContext) getCurrentReactContext();
|
||||
if (context == null || !context.hasActiveReactInstance()) {
|
||||
FLog.w(ReactConstants.TAG, "Calling getViewManagerNames without active context");
|
||||
return Collections.emptyList();
|
||||
}
|
||||
Systrace.endSection(TRACE_TAG_REACT_JAVA_BRIDGE);
|
||||
mViewManagerNames = uniqueNames;
|
||||
}
|
||||
return mViewManagerNames;
|
||||
|
||||
synchronized (mPackages) {
|
||||
if (mViewManagerNames == null) {
|
||||
Set<String> uniqueNames = new HashSet<>();
|
||||
for (ReactPackage reactPackage : mPackages) {
|
||||
SystraceMessage.beginSection(
|
||||
TRACE_TAG_REACT_JAVA_BRIDGE, "ReactInstanceManager.getViewManagerName")
|
||||
.arg("Package", reactPackage.getClass().getSimpleName())
|
||||
.flush();
|
||||
if (reactPackage instanceof ViewManagerOnDemandReactPackage) {
|
||||
Collection<String> names =
|
||||
((ViewManagerOnDemandReactPackage) reactPackage).getViewManagerNames(context);
|
||||
if (names != null) {
|
||||
uniqueNames.addAll(names);
|
||||
}
|
||||
}
|
||||
Systrace.endSection(TRACE_TAG_REACT_JAVA_BRIDGE);
|
||||
}
|
||||
mViewManagerNames = uniqueNames;
|
||||
}
|
||||
return mViewManagerNames;
|
||||
}
|
||||
} finally {
|
||||
Systrace.endSection(TRACE_TAG_REACT_JAVA_BRIDGE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user