Skip to content

Commit

Permalink
Remove unused bundle status reporting from inspector infra (facebook#…
Browse files Browse the repository at this point in the history
…41975)

Summary:

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: [Internal]

Reviewed By: huntie

Differential Revision: D52258567
  • Loading branch information
motiz88 authored and facebook-github-bot committed Dec 19, 2023
1 parent 3ea2f9a commit e5b9586
Show file tree
Hide file tree
Showing 6 changed files with 3 additions and 68 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
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,9 +114,7 @@ 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 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,12 @@ 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) {
String url, String packageName) {
mConnection = new Connection(url);
mInspectorConnections = new HashMap<>();
mPackageName = packageName;
mBundleStatusProvider = bundleStatusProvider;
}

public void connect() {
Expand Down Expand Up @@ -150,15 +148,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 +312,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 e5b9586

Please sign in to comment.