Remove unused bundle status reporting from inspector infra (#41975)

Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/41975

The version of `inspector-proxy` included with React Native has not used the `isLastBundleDownloadSuccess` and `bundleUpdateTimestamp` properties in years. This diff removes the backend support for reporting them (in preparation for a C++ rewrite of this infrastructure). We can consider bringing a similar feature back in the future on top of the modern CDP infra (which we are currently building).

Changelog: [General][Breaking] Remove APIs for reporting bundle download status to inspector-proxy, which does not use this information.

Reviewed By: huntie

Differential Revision: D52258567

fbshipit-source-id: e810278f949d8ab7dbc660cdc036a0f8464727f6
This commit is contained in:
Moti Zilberman
2023-12-20 13:53:09 -08:00
committed by Facebook GitHub Bot
parent dae4a11e90
commit cfa02eec50
7 changed files with 4 additions and 81 deletions
@@ -10,13 +10,6 @@
#if RCT_DEV || RCT_REMOTE_PROFILE
@interface RCTBundleStatus : NSObject
@property (atomic, assign) BOOL isLastBundleDownloadSuccess;
@property (atomic, assign) NSTimeInterval bundleUpdateTimestamp;
@end
typedef RCTBundleStatus * (^RCTBundleStatusProvider)(void);
@interface RCTInspectorPackagerConnection : NSObject
- (instancetype)initWithURL:(NSURL *)url;
@@ -24,7 +17,6 @@ typedef RCTBundleStatus * (^RCTBundleStatusProvider)(void);
- (void)connect;
- (void)closeQuietly;
- (void)sendEventToAllConnections:(NSString *)event;
- (void)setBundleStatusProvider:(RCTBundleStatusProvider)bundleStatusProvider;
@end
@interface RCTInspectorRemoteConnection : NSObject
@@ -21,16 +21,12 @@
const int RECONNECT_DELAY_MS = 2000;
@implementation RCTBundleStatus
@end
@interface RCTInspectorPackagerConnection () <SRWebSocketDelegate> {
NSURL *_url;
NSMutableDictionary<NSString *, RCTInspectorLocalConnection *> *_inspectorConnections;
SRWebSocket *_webSocket;
BOOL _closed;
BOOL _suppressConnectionErrors;
RCTBundleStatusProvider _bundleStatusProvider;
}
@end
@@ -60,11 +56,6 @@ RCT_NOT_IMPLEMENTED(-(instancetype)init)
return self;
}
- (void)setBundleStatusProvider:(RCTBundleStatusProvider)bundleStatusProvider
{
_bundleStatusProvider = bundleStatusProvider;
}
- (void)handleProxyMessage:(NSDictionary<NSString *, id> *)message
{
NSString *event = message[@"event"];
@@ -148,19 +139,12 @@ RCT_NOT_IMPLEMENTED(-(instancetype)init)
NSArray<RCTInspectorPage *> *pages = [RCTInspector pages];
NSMutableArray *array = [NSMutableArray arrayWithCapacity:pages.count];
RCTBundleStatusProvider statusProvider = _bundleStatusProvider;
RCTBundleStatus *bundleStatus = statusProvider == nil ? nil : statusProvider();
for (RCTInspectorPage *page in pages) {
NSDictionary *jsonPage = @{
@"id" : [@(page.id) stringValue],
@"title" : page.title,
@"app" : [[NSBundle mainBundle] bundleIdentifier],
@"vm" : page.vm,
@"isLastBundleDownloadSuccess" : bundleStatus == nil ? [NSNull null]
: @(bundleStatus.isLastBundleDownloadSuccess),
@"bundleUpdateTimestamp" : bundleStatus == nil ? [NSNull null]
: @((long)bundleStatus.bundleUpdateTimestamp * 1000),
};
[array addObject:jsonPage];
}
@@ -2041,7 +2041,7 @@ public class com/facebook/react/devsupport/DefaultDevSupportManagerFactory : com
public class com/facebook/react/devsupport/DevServerHelper {
public static final field RELOAD_APP_EXTRA_JS_PROXY Ljava/lang/String;
public fun <init> (Lcom/facebook/react/modules/debug/interfaces/DeveloperSettings;Ljava/lang/String;Lcom/facebook/react/devsupport/InspectorPackagerConnection$BundleStatusProvider;Lcom/facebook/react/packagerconnection/PackagerConnectionSettings;)V
public fun <init> (Lcom/facebook/react/modules/debug/interfaces/DeveloperSettings;Ljava/lang/String;Lcom/facebook/react/packagerconnection/PackagerConnectionSettings;)V
public fun closeInspectorConnection ()V
public fun closePackagerConnection ()V
public fun disableDebugger ()V
@@ -2198,23 +2198,12 @@ public abstract interface class com/facebook/react/devsupport/HMRClient : com/fa
}
public class com/facebook/react/devsupport/InspectorPackagerConnection {
public fun <init> (Ljava/lang/String;Ljava/lang/String;Lcom/facebook/react/devsupport/InspectorPackagerConnection$BundleStatusProvider;)V
public fun <init> (Ljava/lang/String;Ljava/lang/String;)V
public fun closeQuietly ()V
public fun connect ()V
public fun sendEventToAllConnections (Ljava/lang/String;)V
}
public class com/facebook/react/devsupport/InspectorPackagerConnection$BundleStatus {
public field isLastDownloadSuccess Ljava/lang/Boolean;
public field updateTimestamp J
public fun <init> ()V
public fun <init> (Ljava/lang/Boolean;J)V
}
public abstract interface class com/facebook/react/devsupport/InspectorPackagerConnection$BundleStatusProvider {
public abstract fun getBundleStatus ()Lcom/facebook/react/devsupport/InspectorPackagerConnection$BundleStatus;
}
public class com/facebook/react/devsupport/JSCHeapCapture : com/facebook/fbreact/specs/NativeJSCHeapCaptureSpec {
public fun <init> (Lcom/facebook/react/bridge/ReactApplicationContext;)V
public fun captureComplete (Ljava/lang/String;Ljava/lang/String;)V
@@ -108,16 +108,13 @@ public class DevServerHelper {
private @Nullable JSPackagerClient mPackagerClient;
private @Nullable InspectorPackagerConnection mInspectorPackagerConnection;
private final InspectorPackagerConnection.BundleStatusProvider mBundlerStatusProvider;
public DevServerHelper(
DeveloperSettings developerSettings,
String packageName,
InspectorPackagerConnection.BundleStatusProvider bundleStatusProvider,
PackagerConnectionSettings packagerConnectionSettings) {
mSettings = developerSettings;
mPackagerConnectionSettings = packagerConnectionSettings;
mBundlerStatusProvider = bundleStatusProvider;
mClient =
new OkHttpClient.Builder()
.connectTimeout(HTTP_CONNECT_TIMEOUT_MS, TimeUnit.MILLISECONDS)
@@ -214,8 +211,7 @@ public class DevServerHelper {
@Override
protected Void doInBackground(Void... params) {
mInspectorPackagerConnection =
new InspectorPackagerConnection(
getInspectorDeviceUrl(), mPackageName, mBundlerStatusProvider);
new InspectorPackagerConnection(getInspectorDeviceUrl(), mPackageName);
mInspectorPackagerConnection.connect();
return null;
}
@@ -114,8 +114,6 @@ public abstract class DevSupportManagerBase implements DevSupportManager {
private @Nullable List<ErrorCustomizer> mErrorCustomizers;
private @Nullable PackagerLocationCustomizer mPackagerLocationCustomizer;
private final InspectorPackagerConnection.BundleStatus mBundleStatus;
private @Nullable final Map<String, RequestHandler> mCustomPackagerCommandHandlers;
private @Nullable final SurfaceDelegateFactory mSurfaceDelegateFactory;
@@ -135,12 +133,10 @@ public abstract class DevSupportManagerBase implements DevSupportManager {
mApplicationContext = applicationContext;
mJSAppBundleName = packagerPathForJSBundleName;
mDevSettings = new DevInternalSettings(applicationContext, this::reloadSettings);
mBundleStatus = new InspectorPackagerConnection.BundleStatus();
mDevServerHelper =
new DevServerHelper(
mDevSettings,
mApplicationContext.getPackageName(),
() -> mBundleStatus,
mDevSettings.getPackagerConnectionSettings());
mBundleDownloadListener = devBundleDownloadListener;
@@ -887,10 +883,6 @@ public abstract class DevSupportManagerBase implements DevSupportManager {
@Override
public void onSuccess() {
hideDevLoadingView();
synchronized (DevSupportManagerBase.this) {
mBundleStatus.isLastDownloadSuccess = true;
mBundleStatus.updateTimestamp = System.currentTimeMillis();
}
if (mBundleDownloadListener != null) {
mBundleDownloadListener.onSuccess();
}
@@ -912,9 +904,6 @@ public abstract class DevSupportManagerBase implements DevSupportManager {
@Override
public void onFailure(final Exception cause) {
hideDevLoadingView();
synchronized (DevSupportManagerBase.this) {
mBundleStatus.isLastDownloadSuccess = false;
}
if (mBundleDownloadListener != null) {
mBundleDownloadListener.onFailure(cause);
}
@@ -33,14 +33,11 @@ public class InspectorPackagerConnection {
private final Connection mConnection;
private final Map<String, Inspector.LocalConnection> mInspectorConnections;
private final String mPackageName;
private BundleStatusProvider mBundleStatusProvider;
public InspectorPackagerConnection(
String url, String packageName, BundleStatusProvider bundleStatusProvider) {
public InspectorPackagerConnection(String url, String packageName) {
mConnection = new Connection(url);
mInspectorConnections = new HashMap<>();
mPackageName = packageName;
mBundleStatusProvider = bundleStatusProvider;
}
public void connect() {
@@ -150,15 +147,12 @@ public class InspectorPackagerConnection {
private JSONArray getPages() throws JSONException {
List<Inspector.Page> pages = Inspector.getPages();
JSONArray array = new JSONArray();
BundleStatus bundleStatus = mBundleStatusProvider.getBundleStatus();
for (Inspector.Page page : pages) {
JSONObject jsonPage = new JSONObject();
jsonPage.put("id", String.valueOf(page.getId()));
jsonPage.put("title", page.getTitle());
jsonPage.put("app", mPackageName);
jsonPage.put("vm", page.getVM());
jsonPage.put("isLastBundleDownloadSuccess", bundleStatus.isLastDownloadSuccess);
jsonPage.put("bundleUpdateTimestamp", bundleStatus.updateTimestamp);
array.put(jsonPage);
}
return array;
@@ -317,22 +311,4 @@ public class InspectorPackagerConnection {
}
}
}
public static class BundleStatus {
public Boolean isLastDownloadSuccess;
public long updateTimestamp = -1;
public BundleStatus(Boolean isLastDownloadSuccess, long updateTimestamp) {
this.isLastDownloadSuccess = isLastDownloadSuccess;
this.updateTimestamp = updateTimestamp;
}
public BundleStatus() {
this(false, -1);
}
}
public interface BundleStatusProvider {
BundleStatus getBundleStatus();
}
}
@@ -16,7 +16,6 @@ import android.content.Context;
public final class PerftestDevSupportManager extends DisabledDevSupportManager {
private final DevServerHelper mDevServerHelper;
private final DevInternalSettings mDevSettings;
private final InspectorPackagerConnection.BundleStatus mBundleStatus;
public PerftestDevSupportManager(Context applicationContext) {
mDevSettings =
@@ -26,12 +25,10 @@ public final class PerftestDevSupportManager extends DisabledDevSupportManager {
@Override
public void onInternalSettingsChanged() {}
});
mBundleStatus = new InspectorPackagerConnection.BundleStatus();
mDevServerHelper =
new DevServerHelper(
mDevSettings,
applicationContext.getPackageName(),
(InspectorPackagerConnection.BundleStatusProvider) () -> mBundleStatus,
mDevSettings.getPackagerConnectionSettings());
}