Skip to content

Commit 2771618

Browse files
javachemeta-codesync[bot]
authored andcommitted
Remove split bundle loading logic (#58556)
Summary: Pull Request resolved: #58556 Remove the unused Android split-bundle development loading path. Its native module caller was removed previously, leaving the loader entry point and delegate API unreachable. Changelog: [Android][Removed] - Remove experimental split-bundle loading APIs Reviewed By: christophpurrer Differential Revision: D120323266 fbshipit-source-id: d575fa73548a3734f18640c95a517fa9f1b056bd
1 parent 0d47e12 commit 2771618

7 files changed

Lines changed: 0 additions & 116 deletions

File tree

packages/react-native/ReactAndroid/api/ReactAndroid.api

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -699,7 +699,6 @@ public abstract class com/facebook/react/bridge/JSBundleLoader {
699699
public fun <init> ()V
700700
public static final fun createAssetLoader (Landroid/content/Context;Ljava/lang/String;Z)Lcom/facebook/react/bridge/JSBundleLoader;
701701
public static final fun createCachedBundleFromNetworkLoader (Ljava/lang/String;Ljava/lang/String;)Lcom/facebook/react/bridge/JSBundleLoader;
702-
public static final fun createCachedSplitBundleFromNetworkLoader (Ljava/lang/String;Ljava/lang/String;)Lcom/facebook/react/bridge/JSBundleLoader;
703702
public static final fun createFileLoader (Ljava/lang/String;)Lcom/facebook/react/bridge/JSBundleLoader;
704703
public static final fun createFileLoader (Ljava/lang/String;Ljava/lang/String;Z)Lcom/facebook/react/bridge/JSBundleLoader;
705704
public abstract fun loadScript (Lcom/facebook/react/bridge/JSBundleLoaderDelegate;)Ljava/lang/String;
@@ -708,15 +707,13 @@ public abstract class com/facebook/react/bridge/JSBundleLoader {
708707
public final class com/facebook/react/bridge/JSBundleLoader$Companion {
709708
public final fun createAssetLoader (Landroid/content/Context;Ljava/lang/String;Z)Lcom/facebook/react/bridge/JSBundleLoader;
710709
public final fun createCachedBundleFromNetworkLoader (Ljava/lang/String;Ljava/lang/String;)Lcom/facebook/react/bridge/JSBundleLoader;
711-
public final fun createCachedSplitBundleFromNetworkLoader (Ljava/lang/String;Ljava/lang/String;)Lcom/facebook/react/bridge/JSBundleLoader;
712710
public final fun createFileLoader (Ljava/lang/String;)Lcom/facebook/react/bridge/JSBundleLoader;
713711
public final fun createFileLoader (Ljava/lang/String;Ljava/lang/String;Z)Lcom/facebook/react/bridge/JSBundleLoader;
714712
}
715713

716714
public abstract interface class com/facebook/react/bridge/JSBundleLoaderDelegate {
717715
public abstract fun loadScriptFromAssets (Landroid/content/res/AssetManager;Ljava/lang/String;Z)V
718716
public abstract fun loadScriptFromFile (Ljava/lang/String;Ljava/lang/String;Z)V
719-
public abstract fun loadSplitBundleFromFile (Ljava/lang/String;Ljava/lang/String;)V
720717
public abstract fun setSourceURLs (Ljava/lang/String;Ljava/lang/String;)V
721718
}
722719

@@ -1865,7 +1862,6 @@ public class com/facebook/react/devsupport/DevServerHelper {
18651862
public static synthetic fun downloadBundleFromURL$default (Lcom/facebook/react/devsupport/DevServerHelper;Lcom/facebook/react/devsupport/interfaces/DevBundleDownloadListener;Ljava/io/File;Ljava/lang/String;Lcom/facebook/react/devsupport/BundleDownloader$BundleInfo;Lokhttp3/Request$Builder;ILjava/lang/Object;)V
18661863
public final fun downloadBundleResourceFromUrlSync (Ljava/lang/String;Ljava/io/File;)Ljava/io/File;
18671864
public fun getDevServerBundleURL (Ljava/lang/String;)Ljava/lang/String;
1868-
public fun getDevServerSplitBundleURL (Ljava/lang/String;)Ljava/lang/String;
18691865
public fun getSourceMapUrl (Ljava/lang/String;)Ljava/lang/String;
18701866
public fun getSourceUrl (Ljava/lang/String;)Ljava/lang/String;
18711867
public fun isPackagerRunning (Lcom/facebook/react/devsupport/interfaces/PackagerStatusCallback;)V
@@ -1890,7 +1886,6 @@ public abstract class com/facebook/react/devsupport/DevSupportManagerBase : com/
18901886
public fun createSurfaceDelegate (Ljava/lang/String;)Lcom/facebook/react/common/SurfaceDelegate;
18911887
public fun destroyRootView (Landroid/view/View;)V
18921888
public fun downloadBundleResourceFromUrlSync (Ljava/lang/String;Ljava/io/File;)Ljava/io/File;
1893-
public final fun fetchSplitBundleAndCreateBundleLoader (Ljava/lang/String;Lcom/facebook/react/devsupport/DevSupportManagerBase$CallbackWithBundleLoader;)V
18941889
protected final fun getApplicationContext ()Landroid/content/Context;
18951890
public fun getBundleFilePath ()Ljava/lang/String;
18961891
public fun getCurrentActivity ()Landroid/app/Activity;
@@ -1951,11 +1946,6 @@ public abstract class com/facebook/react/devsupport/DevSupportManagerBase : com/
19511946
public fun toggleElementInspector ()V
19521947
}
19531948

1954-
public abstract interface class com/facebook/react/devsupport/DevSupportManagerBase$CallbackWithBundleLoader {
1955-
public abstract fun onError (Ljava/lang/String;Ljava/lang/Throwable;)V
1956-
public abstract fun onSuccess (Lcom/facebook/react/bridge/JSBundleLoader;)V
1957-
}
1958-
19591949
public final class com/facebook/react/devsupport/DevSupportManagerBase$Companion {
19601950
}
19611951

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/JSBundleLoader.kt

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -78,22 +78,5 @@ public abstract class JSBundleLoader {
7878
}
7979
}
8080
}
81-
82-
/** Same as [createCachedBundleFromNetworkLoader], but for split bundles in development. */
83-
@JvmStatic
84-
public fun createCachedSplitBundleFromNetworkLoader(
85-
sourceURL: String,
86-
cachedFileLocation: String,
87-
): JSBundleLoader =
88-
object : JSBundleLoader() {
89-
override fun loadScript(delegate: JSBundleLoaderDelegate): String {
90-
return try {
91-
delegate.loadSplitBundleFromFile(cachedFileLocation, sourceURL)
92-
sourceURL
93-
} catch (e: Exception) {
94-
throw DebugServerException.makeGeneric(sourceURL, e.message.orEmpty(), e)
95-
}
96-
}
97-
}
9881
}
9982
}

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/JSBundleLoaderDelegate.kt

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,6 @@ public interface JSBundleLoaderDelegate {
3434
*/
3535
public fun loadScriptFromFile(fileName: String, sourceURL: String, loadSynchronously: Boolean)
3636

37-
/**
38-
* Load a split JS bundle from the filesystem. See
39-
* [JSBundleLoader.createCachedSplitBundleFromNetworkLoader].
40-
*/
41-
public fun loadSplitBundleFromFile(fileName: String, sourceURL: String)
42-
4337
/**
4438
* This API is used in situations where the JS bundle is being executed not on the device, but on
4539
* a host machine. In that case, we must provide two source URLs for the JS bundle: One to be used

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevServerHelper.kt

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -259,9 +259,6 @@ public open class DevServerHelper(
259259
)
260260
}
261261

262-
private fun createSplitBundleURL(mainModuleID: String, host: String): String =
263-
createBundleURL(mainModuleID, BundleType.BUNDLE, host, true, false)
264-
265262
private fun createBundleURL(
266263
mainModuleID: String,
267264
type: BundleType,
@@ -302,9 +299,6 @@ public open class DevServerHelper(
302299
public open fun getDevServerBundleURL(jsModulePath: String): String =
303300
createBundleURL(jsModulePath, BundleType.BUNDLE, packagerConnectionSettings.debugServerHost)
304301

305-
public open fun getDevServerSplitBundleURL(jsModulePath: String): String =
306-
createSplitBundleURL(jsModulePath, packagerConnectionSettings.debugServerHost)
307-
308302
public open fun isPackagerRunning(callback: PackagerStatusCallback) {
309303
packagerStatusCheck.run(packagerConnectionSettings.debugServerHost, callback)
310304
}

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevSupportManagerBase.kt

Lines changed: 0 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ import androidx.core.util.Supplier
3535
import com.facebook.common.logging.FLog
3636
import com.facebook.react.R
3737
import com.facebook.react.bridge.DefaultJSExceptionHandler
38-
import com.facebook.react.bridge.JSBundleLoader
3938
import com.facebook.react.bridge.ReactContext
4039
import com.facebook.react.bridge.ReactMarker
4140
import com.facebook.react.bridge.ReactMarkerConstants
@@ -96,12 +95,6 @@ public abstract class DevSupportManagerBase(
9695
private var pausedInDebuggerOverlayManager: PausedInDebuggerOverlayManager?,
9796
) : DevSupportManager {
9897

99-
public interface CallbackWithBundleLoader {
100-
public fun onSuccess(bundleLoader: JSBundleLoader)
101-
102-
public fun onError(url: String, cause: Throwable)
103-
}
104-
10598
protected abstract val uniqueTag: String
10699

107100
public final override var currentReactContext: ReactContext? = null
@@ -187,13 +180,11 @@ public abstract class DevSupportManagerBase(
187180
}
188181
private val customDevOptions = LinkedHashMap<String, DevOptionHandler>()
189182
private val jsBundleDownloadedFile: File
190-
private val jsSplitBundlesDir: File
191183
private val defaultJSExceptionHandler: DefaultJSExceptionHandler = DefaultJSExceptionHandler()
192184
private var redBoxSurfaceDelegate: SurfaceDelegate? = null
193185
private var devOptionsDialog: AlertDialog? = null
194186
private var debugOverlayController: DebugOverlayController? = null
195187
private var devLoadingViewVisible = false
196-
private var pendingJSSplitBundleRequests = 0
197188
private var isReceiverRegistered = false
198189
private var isShakeDetectorStarted = false
199190
private var isDevSupportEnabled = false
@@ -224,8 +215,6 @@ public abstract class DevSupportManagerBase(
224215
val subclassTag = uniqueTag
225216
val bundleFile = subclassTag + "ReactNativeDevBundle.js"
226217
jsBundleDownloadedFile = File(applicationContext.filesDir, bundleFile)
227-
val splitBundlesDir = subclassTag.lowercase() + "_dev_js_split_bundles"
228-
jsSplitBundlesDir = applicationContext.getDir(splitBundlesDir, Context.MODE_PRIVATE)
229218
devSupportEnabled = enableOnCreate
230219
if (devLoadingViewManager == null) {
231220
devLoadingViewManager = DefaultDevLoadingViewImplementation(reactInstanceDevHelper)
@@ -762,64 +751,6 @@ public abstract class DevSupportManagerBase(
762751
devLoadingViewVisible = false
763752
}
764753

765-
public fun fetchSplitBundleAndCreateBundleLoader(
766-
bundlePath: String,
767-
callback: CallbackWithBundleLoader,
768-
) {
769-
val bundleUrl = devServerHelper.getDevServerSplitBundleURL(bundlePath)
770-
// The bundle path may contain the '/' character, which is not allowed in file names.
771-
val bundleFile = File(jsSplitBundlesDir, bundlePath.replace("/".toRegex(), "_") + ".jsbundle")
772-
UiThreadUtil.runOnUiThread {
773-
showSplitBundleDevLoadingView(bundleUrl)
774-
devServerHelper.downloadBundleFromURL(
775-
object : DevBundleDownloadListener {
776-
override fun onSuccess() {
777-
UiThreadUtil.runOnUiThread { hideSplitBundleDevLoadingView() }
778-
779-
val context: ReactContext? = this@DevSupportManagerBase.currentReactContext
780-
if (context == null || !context.hasActiveReactInstance()) {
781-
return
782-
}
783-
784-
val bundleLoader =
785-
JSBundleLoader.createCachedSplitBundleFromNetworkLoader(
786-
bundleUrl,
787-
bundleFile.absolutePath,
788-
)
789-
callback.onSuccess(bundleLoader)
790-
}
791-
792-
override fun onProgress(status: String?, done: Int?, total: Int?, percent: Int?) {
793-
devLoadingViewManager?.updateProgress(status, done, total, percent)
794-
}
795-
796-
override fun onFailure(cause: Exception) {
797-
UiThreadUtil.runOnUiThread {
798-
this@DevSupportManagerBase.hideSplitBundleDevLoadingView()
799-
}
800-
callback.onError(bundleUrl, cause)
801-
}
802-
},
803-
bundleFile,
804-
bundleUrl,
805-
null,
806-
)
807-
}
808-
}
809-
810-
@UiThread
811-
private fun showSplitBundleDevLoadingView(bundleUrl: String) {
812-
showDevLoadingViewForUrl(bundleUrl)
813-
pendingJSSplitBundleRequests++
814-
}
815-
816-
@UiThread
817-
private fun hideSplitBundleDevLoadingView() {
818-
if (--pendingJSSplitBundleRequests == 0) {
819-
hideDevLoadingView()
820-
}
821-
}
822-
823754
override fun isPackagerRunning(callback: PackagerStatusCallback) {
824755
val checkPackagerRunning = Runnable { devServerHelper.isPackagerRunning(callback) }
825756
packagerLocationCustomizer?.run(checkPackagerRunning) ?: checkPackagerRunning.run()

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/runtime/BridgelessCatalystInstance.kt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,6 @@ internal class BridgelessCatalystInstance(private val reactHost: ReactHostImpl)
5656
throw UnsupportedOperationException("Unimplemented method 'loadScriptFromFile'")
5757
}
5858

59-
override fun loadSplitBundleFromFile(fileName: String, sourceURL: String) {
60-
throw UnsupportedOperationException("Unimplemented method 'loadSplitBundleFromFile'")
61-
}
62-
6359
override fun setSourceURLs(deviceURL: String, remoteURL: String) {
6460
throw UnsupportedOperationException("Unimplemented method 'setSourceURLs'")
6561
}

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/runtime/ReactInstance.kt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -319,10 +319,6 @@ internal class ReactInstance(
319319
loadJSBundleFromFile(fileName, sourceURL)
320320
}
321321

322-
override fun loadSplitBundleFromFile(fileName: String, sourceURL: String) {
323-
loadJSBundleFromFile(fileName, sourceURL)
324-
}
325-
326322
override fun loadScriptFromAssets(
327323
assetManager: AssetManager,
328324
assetURL: String,

0 commit comments

Comments
 (0)