Skip to content

Commit

Permalink
Remove unused bundle status reporting from inspector infra (#41975)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #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
  • Loading branch information
motiz88 authored and facebook-github-bot committed Dec 20, 2023
1 parent dae4a11 commit cfa02ee
Show file tree
Hide file tree
Showing 7 changed files with 4 additions and 81 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,13 @@

#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;

- (bool)isConnected;
- (void)connect;
- (void)closeQuietly;
- (void)sendEventToAllConnections:(NSString *)event;
- (void)setBundleStatusProvider:(RCTBundleStatusProvider)bundleStatusProvider;
@end

@interface RCTInspectorRemoteConnection : NSObject
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -60,11 +56,6 @@ - (instancetype)initWithURL:(NSURL *)url
return self;
}

- (void)setBundleStatusProvider:(RCTBundleStatusProvider)bundleStatusProvider
{
_bundleStatusProvider = bundleStatusProvider;
}

- (void)handleProxyMessage:(NSDictionary<NSString *, id> *)message
{
NSString *event = message[@"event"];
Expand Down Expand Up @@ -148,19 +139,12 @@ - (NSArray *)pages
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];
}
Expand Down
15 changes: 2 additions & 13 deletions packages/react-native/ReactAndroid/api/ReactAndroid.api
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,16 +108,13 @@ public String typeID() {

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)
Expand Down Expand Up @@ -214,8 +211,7 @@ public void openInspectorConnection() {
@Override
protected Void doInBackground(Void... params) {
mInspectorPackagerConnection =
new InspectorPackagerConnection(
getInspectorDeviceUrl(), mPackageName, mBundlerStatusProvider);
new InspectorPackagerConnection(getInspectorDeviceUrl(), mPackageName);
mInspectorPackagerConnection.connect();
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,6 @@ public interface CallbackWithBundleLoader {
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;
Expand All @@ -135,12 +133,10 @@ public DevSupportManagerBase(
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;

Expand Down Expand Up @@ -887,10 +883,6 @@ public void reloadJSFromServer(final String bundleURL, final BundleLoadCallback
@Override
public void onSuccess() {
hideDevLoadingView();
synchronized (DevSupportManagerBase.this) {
mBundleStatus.isLastDownloadSuccess = true;
mBundleStatus.updateTimestamp = System.currentTimeMillis();
}
if (mBundleDownloadListener != null) {
mBundleDownloadListener.onSuccess();
}
Expand All @@ -912,9 +904,6 @@ public void onProgress(
@Override
public void onFailure(final Exception cause) {
hideDevLoadingView();
synchronized (DevSupportManagerBase.this) {
mBundleStatus.isLastDownloadSuccess = false;
}
if (mBundleDownloadListener != null) {
mBundleDownloadListener.onFailure(cause);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -150,15 +147,12 @@ private void handleWrappedEvent(JSONObject payload) throws JSONException {
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;
Expand Down Expand Up @@ -317,22 +311,4 @@ private void closeWebSocketQuietly() {
}
}
}

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();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
public final class PerftestDevSupportManager extends DisabledDevSupportManager {
private final DevServerHelper mDevServerHelper;
private final DevInternalSettings mDevSettings;
private final InspectorPackagerConnection.BundleStatus mBundleStatus;

public PerftestDevSupportManager(Context applicationContext) {
mDevSettings =
Expand All @@ -26,12 +25,10 @@ public PerftestDevSupportManager(Context applicationContext) {
@Override
public void onInternalSettingsChanged() {}
});
mBundleStatus = new InspectorPackagerConnection.BundleStatus();
mDevServerHelper =
new DevServerHelper(
mDevSettings,
applicationContext.getPackageName(),
(InspectorPackagerConnection.BundleStatusProvider) () -> mBundleStatus,
mDevSettings.getPackagerConnectionSettings());
}

Expand Down

0 comments on commit cfa02ee

Please sign in to comment.