@onekeyfe/react-native-background-thread 1.1.52 → 1.1.53
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -120,13 +120,22 @@ class BackgroundThreadManager private constructor() {
|
|
|
120
120
|
): JSBundleLoader {
|
|
121
121
|
return object : JSBundleLoader() {
|
|
122
122
|
override fun loadScript(delegate: com.facebook.react.bridge.JSBundleLoaderDelegate): String {
|
|
123
|
+
val totalStart = System.nanoTime()
|
|
124
|
+
|
|
123
125
|
// Step 1: Load common bundle (polyfills + shared modules)
|
|
126
|
+
val commonStart = System.nanoTime()
|
|
124
127
|
delegate.loadScriptFromAssets(appContext.assets, "assets://$commonAssetName", false)
|
|
125
|
-
|
|
128
|
+
val commonMs = (System.nanoTime() - commonStart) / 1_000_000.0
|
|
129
|
+
BTLogger.info("[SplitBundle] common bundle loaded from assets in ${String.format("%.1f", commonMs)}ms: $commonAssetName")
|
|
126
130
|
|
|
127
131
|
// Step 2: Load entry-specific bundle
|
|
132
|
+
val entryStart = System.nanoTime()
|
|
128
133
|
delegate.loadScriptFromAssets(appContext.assets, "assets://$entryAssetName", false)
|
|
129
|
-
|
|
134
|
+
val entryMs = (System.nanoTime() - entryStart) / 1_000_000.0
|
|
135
|
+
BTLogger.info("[SplitBundle] entry bundle loaded from assets in ${String.format("%.1f", entryMs)}ms: $entryAssetName")
|
|
136
|
+
|
|
137
|
+
val totalMs = (System.nanoTime() - totalStart) / 1_000_000.0
|
|
138
|
+
BTLogger.info("[SplitBundle] sequential asset load total: ${String.format("%.1f", totalMs)}ms (common=${String.format("%.1f", commonMs)}ms + entry=${String.format("%.1f", entryMs)}ms)")
|
|
130
139
|
|
|
131
140
|
return "assets://$entryAssetName"
|
|
132
141
|
}
|
|
@@ -144,14 +153,19 @@ class BackgroundThreadManager private constructor() {
|
|
|
144
153
|
): JSBundleLoader {
|
|
145
154
|
return object : JSBundleLoader() {
|
|
146
155
|
override fun loadScript(delegate: com.facebook.react.bridge.JSBundleLoaderDelegate): String {
|
|
156
|
+
val totalStart = System.nanoTime()
|
|
157
|
+
|
|
147
158
|
// Step 1: Load common bundle (polyfills + shared modules)
|
|
148
159
|
val commonFile = File(commonPath)
|
|
149
160
|
if (!commonFile.exists()) {
|
|
150
161
|
BTLogger.error("Common bundle file does not exist: $commonPath")
|
|
151
162
|
throw RuntimeException("Common bundle file does not exist: $commonPath")
|
|
152
163
|
}
|
|
164
|
+
BTLogger.info("[SplitBundle] common bundle file: ${commonFile.length() / 1024}KB")
|
|
165
|
+
val commonStart = System.nanoTime()
|
|
153
166
|
delegate.loadScriptFromFile(commonFile.absolutePath, "common.bundle", false)
|
|
154
|
-
|
|
167
|
+
val commonMs = (System.nanoTime() - commonStart) / 1_000_000.0
|
|
168
|
+
BTLogger.info("[SplitBundle] common bundle loaded from file in ${String.format("%.1f", commonMs)}ms: $commonPath")
|
|
155
169
|
|
|
156
170
|
// Step 2: Load entry-specific bundle
|
|
157
171
|
val entryFile = File(entryPath)
|
|
@@ -159,8 +173,14 @@ class BackgroundThreadManager private constructor() {
|
|
|
159
173
|
BTLogger.error("Entry bundle file does not exist: $entryPath")
|
|
160
174
|
throw RuntimeException("Entry bundle file does not exist: $entryPath")
|
|
161
175
|
}
|
|
176
|
+
BTLogger.info("[SplitBundle] entry bundle file: ${entryFile.length() / 1024}KB")
|
|
177
|
+
val entryStart = System.nanoTime()
|
|
162
178
|
delegate.loadScriptFromFile(entryFile.absolutePath, entrySourceURL, false)
|
|
163
|
-
|
|
179
|
+
val entryMs = (System.nanoTime() - entryStart) / 1_000_000.0
|
|
180
|
+
BTLogger.info("[SplitBundle] entry bundle loaded from file in ${String.format("%.1f", entryMs)}ms: $entryPath")
|
|
181
|
+
|
|
182
|
+
val totalMs = (System.nanoTime() - totalStart) / 1_000_000.0
|
|
183
|
+
BTLogger.info("[SplitBundle] sequential file load total: ${String.format("%.1f", totalMs)}ms (common=${String.format("%.1f", commonMs)}ms + entry=${String.format("%.1f", entryMs)}ms)")
|
|
164
184
|
|
|
165
185
|
return entrySourceURL
|
|
166
186
|
}
|
|
@@ -231,7 +251,8 @@ class BackgroundThreadManager private constructor() {
|
|
|
231
251
|
BTLogger.warn("Background runner already started")
|
|
232
252
|
return
|
|
233
253
|
}
|
|
234
|
-
|
|
254
|
+
val bgStartTime = System.nanoTime()
|
|
255
|
+
BTLogger.info("[SplitBundle] background runner starting with entryURL: $entryURL")
|
|
235
256
|
|
|
236
257
|
val appContext = context.applicationContext
|
|
237
258
|
val packages =
|
|
@@ -306,7 +327,8 @@ class BackgroundThreadManager private constructor() {
|
|
|
306
327
|
|
|
307
328
|
host.addReactInstanceEventListener(object : ReactInstanceEventListener {
|
|
308
329
|
override fun onReactContextInitialized(context: ReactContext) {
|
|
309
|
-
|
|
330
|
+
val initMs = (System.nanoTime() - bgStartTime) / 1_000_000.0
|
|
331
|
+
BTLogger.info("[SplitBundle] background ReactContext initialized in ${String.format("%.1f", initMs)}ms")
|
|
310
332
|
context.runOnJSQueueThread {
|
|
311
333
|
try {
|
|
312
334
|
val ptr = context.javaScriptContextHolder?.get() ?: 0L
|
|
@@ -233,6 +233,8 @@ static NSURL *resolveBundleSourceURL(NSString *jsBundleSourceNS)
|
|
|
233
233
|
}
|
|
234
234
|
}
|
|
235
235
|
|
|
236
|
+
CFAbsoluteTime bgStartTime = CFAbsoluteTimeGetCurrent();
|
|
237
|
+
|
|
236
238
|
[_rctInstance callFunctionOnBufferedRuntimeExecutor:[=](jsi::Runtime &runtime) {
|
|
237
239
|
[self setupErrorHandler:runtime];
|
|
238
240
|
|
|
@@ -253,12 +255,17 @@ static NSURL *resolveBundleSourceURL(NSString *jsBundleSourceNS)
|
|
|
253
255
|
// This must happen BEFORE invokeOptionalGlobalFunction since the entry
|
|
254
256
|
// bundle defines __setupBackgroundRPCHandler.
|
|
255
257
|
if (isSplitBundle && bgBundleData && bgBundleData.length > 0) {
|
|
258
|
+
CFAbsoluteTime bgEvalStart = CFAbsoluteTimeGetCurrent();
|
|
256
259
|
auto buffer = std::make_shared<jsi::StringBuffer>(
|
|
257
260
|
std::string(static_cast<const char *>(bgBundleData.bytes), bgBundleData.length));
|
|
258
261
|
runtime.evaluateJavaScript(std::move(buffer), [bgBundleSourceURL UTF8String]);
|
|
259
|
-
|
|
262
|
+
double bgEvalMs = (CFAbsoluteTimeGetCurrent() - bgEvalStart) * 1000.0;
|
|
263
|
+
[BTLogger info:[NSString stringWithFormat:@"[SplitBundle] bg entry evaluated in %.1fms", bgEvalMs]];
|
|
260
264
|
}
|
|
261
265
|
|
|
266
|
+
double bgTotalMs = (CFAbsoluteTimeGetCurrent() - bgStartTime) * 1000.0;
|
|
267
|
+
[BTLogger info:[NSString stringWithFormat:@"[SplitBundle] bg hostDidStart total setup in %.1fms", bgTotalMs]];
|
|
268
|
+
|
|
262
269
|
invokeOptionalGlobalFunction(runtime, "__setupBackgroundRPCHandler");
|
|
263
270
|
}];
|
|
264
271
|
}
|