mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Add perftest dev support manager
Summary: Add a `DevSupportManager` that can be used for performance testing. This `DevSupportManager` allows the inspector connection to be established, but leaves everything else disabled. Previously, if Developer Support was enabled on a release build, the application would present an error as it unsuccessfully attempted to use the bridge dev support manager. With this change, if a developer opts into developer support in a release build (i.e. `enableOnCreate == true && ReactBuildConfig.DEBUG == false` in the `DevSupportManagerFactory`), the `PerfTestDevSupportManager` will be used, allowing use of things like heap size reporting and the sampling profiler. (`enableOnCrease` indicates the development mode setting: https://www.internalfb.com/code/fbsource/[6b8a941fdf2a0fd58d9db36f5a59fa5fb53ad2df]/xplat/js/react-native-github/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManager.java?lines=259) Changelog: [internal] Reviewed By: rubennorte Differential Revision: D39468561 fbshipit-source-id: cb3c82e7a8ee74316b23f57dc8d0cc6e5cdb18a7
This commit is contained in:
committed by
Facebook GitHub Bot
parent
f353119113
commit
4d1a56813c
+4
@@ -10,6 +10,7 @@ package com.facebook.react.devsupport;
|
||||
import android.content.Context;
|
||||
import androidx.annotation.Nullable;
|
||||
import com.facebook.react.common.SurfaceDelegateFactory;
|
||||
import com.facebook.react.common.build.ReactBuildConfig;
|
||||
import com.facebook.react.devsupport.interfaces.DevBundleDownloadListener;
|
||||
import com.facebook.react.devsupport.interfaces.DevSupportManager;
|
||||
import com.facebook.react.devsupport.interfaces.RedBoxHandler;
|
||||
@@ -61,6 +62,9 @@ public class DefaultDevSupportManagerFactory implements DevSupportManagerFactory
|
||||
if (!enableOnCreate) {
|
||||
return new DisabledDevSupportManager();
|
||||
}
|
||||
if (!ReactBuildConfig.DEBUG) {
|
||||
return new PerftestDevSupportManager(applicationContext);
|
||||
}
|
||||
try {
|
||||
// ProGuard is surprisingly smart in this case and will keep a class if it detects a call to
|
||||
// Class.forName() with a static string. So instead we generate a quasi-dynamic string to
|
||||
|
||||
+56
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
package com.facebook.react.devsupport;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
/**
|
||||
* Interface for accessing and interacting with development features related to performance testing.
|
||||
* Communication is enabled via the Inspector, but everything else is disabled.
|
||||
*/
|
||||
public final class PerftestDevSupportManager extends DisabledDevSupportManager {
|
||||
private final DevServerHelper mDevServerHelper;
|
||||
private final DevInternalSettings mDevSettings;
|
||||
private final InspectorPackagerConnection.BundleStatus mBundleStatus;
|
||||
|
||||
public PerftestDevSupportManager(Context applicationContext) {
|
||||
mDevSettings =
|
||||
new DevInternalSettings(
|
||||
applicationContext,
|
||||
new DevInternalSettings.Listener() {
|
||||
@Override
|
||||
public void onInternalSettingsChanged() {}
|
||||
});
|
||||
mBundleStatus = new InspectorPackagerConnection.BundleStatus();
|
||||
mDevServerHelper =
|
||||
new DevServerHelper(
|
||||
mDevSettings,
|
||||
applicationContext.getPackageName(),
|
||||
new InspectorPackagerConnection.BundleStatusProvider() {
|
||||
@Override
|
||||
public InspectorPackagerConnection.BundleStatus getBundleStatus() {
|
||||
return mBundleStatus;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public DevInternalSettings getDevSettings() {
|
||||
return mDevSettings;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startInspector() {
|
||||
mDevServerHelper.openInspectorConnection();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stopInspector() {
|
||||
mDevServerHelper.closeInspectorConnection();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user