From cfa02eec50469059542ccbacbc51643b525ad461 Mon Sep 17 00:00:00 2001 From: Moti Zilberman Date: Wed, 20 Dec 2023 13:53:09 -0800 Subject: [PATCH] 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 --- .../RCTInspectorPackagerConnection.h | 8 ------ .../RCTInspectorPackagerConnection.m | 16 ------------ .../ReactAndroid/api/ReactAndroid.api | 15 ++--------- .../react/devsupport/DevServerHelper.java | 6 +---- .../devsupport/DevSupportManagerBase.java | 11 -------- .../InspectorPackagerConnection.java | 26 +------------------ .../devsupport/PerftestDevSupportManager.java | 3 --- 7 files changed, 4 insertions(+), 81 deletions(-) diff --git a/packages/react-native/React/Inspector/RCTInspectorPackagerConnection.h b/packages/react-native/React/Inspector/RCTInspectorPackagerConnection.h index 96bb8416b772e7..20c670015236ea 100644 --- a/packages/react-native/React/Inspector/RCTInspectorPackagerConnection.h +++ b/packages/react-native/React/Inspector/RCTInspectorPackagerConnection.h @@ -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 diff --git a/packages/react-native/React/Inspector/RCTInspectorPackagerConnection.m b/packages/react-native/React/Inspector/RCTInspectorPackagerConnection.m index 1c4f6b0725392a..7d934b43343261 100644 --- a/packages/react-native/React/Inspector/RCTInspectorPackagerConnection.m +++ b/packages/react-native/React/Inspector/RCTInspectorPackagerConnection.m @@ -21,16 +21,12 @@ const int RECONNECT_DELAY_MS = 2000; -@implementation RCTBundleStatus -@end - @interface RCTInspectorPackagerConnection () { NSURL *_url; NSMutableDictionary *_inspectorConnections; SRWebSocket *_webSocket; BOOL _closed; BOOL _suppressConnectionErrors; - RCTBundleStatusProvider _bundleStatusProvider; } @end @@ -60,11 +56,6 @@ - (instancetype)initWithURL:(NSURL *)url return self; } -- (void)setBundleStatusProvider:(RCTBundleStatusProvider)bundleStatusProvider -{ - _bundleStatusProvider = bundleStatusProvider; -} - - (void)handleProxyMessage:(NSDictionary *)message { NSString *event = message[@"event"]; @@ -148,19 +139,12 @@ - (NSArray *)pages NSArray *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]; } diff --git a/packages/react-native/ReactAndroid/api/ReactAndroid.api b/packages/react-native/ReactAndroid/api/ReactAndroid.api index 07e3998888fe8f..d5b04e79708062 100644 --- a/packages/react-native/ReactAndroid/api/ReactAndroid.api +++ b/packages/react-native/ReactAndroid/api/ReactAndroid.api @@ -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 (Lcom/facebook/react/modules/debug/interfaces/DeveloperSettings;Ljava/lang/String;Lcom/facebook/react/devsupport/InspectorPackagerConnection$BundleStatusProvider;Lcom/facebook/react/packagerconnection/PackagerConnectionSettings;)V + public fun (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 (Ljava/lang/String;Ljava/lang/String;Lcom/facebook/react/devsupport/InspectorPackagerConnection$BundleStatusProvider;)V + public fun (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 ()V - public fun (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 (Lcom/facebook/react/bridge/ReactApplicationContext;)V public fun captureComplete (Ljava/lang/String;Ljava/lang/String;)V diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevServerHelper.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevServerHelper.java index 4cef3eed690491..1419c7f169657c 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevServerHelper.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevServerHelper.java @@ -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) @@ -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; } diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevSupportManagerBase.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevSupportManagerBase.java index 0bf65cdaf43141..7a4828e3a518fc 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevSupportManagerBase.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevSupportManagerBase.java @@ -114,8 +114,6 @@ public interface CallbackWithBundleLoader { private @Nullable List mErrorCustomizers; private @Nullable PackagerLocationCustomizer mPackagerLocationCustomizer; - private final InspectorPackagerConnection.BundleStatus mBundleStatus; - private @Nullable final Map mCustomPackagerCommandHandlers; private @Nullable final SurfaceDelegateFactory mSurfaceDelegateFactory; @@ -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; @@ -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(); } @@ -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); } diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/InspectorPackagerConnection.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/InspectorPackagerConnection.java index 5f535b7044d6fa..298fc5ce17605c 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/InspectorPackagerConnection.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/InspectorPackagerConnection.java @@ -33,14 +33,11 @@ public class InspectorPackagerConnection { private final Connection mConnection; private final Map 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 @@ private void handleWrappedEvent(JSONObject payload) throws JSONException { private JSONArray getPages() throws JSONException { List 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 @@ 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(); - } } diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/PerftestDevSupportManager.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/PerftestDevSupportManager.java index d15eba912d99d8..44bfd45e2cdbcf 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/PerftestDevSupportManager.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/PerftestDevSupportManager.java @@ -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 = @@ -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()); }