mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Fabric: Post RCTInstanceDidLoadBundle notification after bundle loaded (#48082)
Summary: Fixes https://github.com/facebook/react-native/issues/47949 ## Changelog: [IOS] [FIXED] - Fabric: Post RCTInstanceDidLoadBundle notification after bundle loaded Pull Request resolved: https://github.com/facebook/react-native/pull/48082 Test Plan: Post RCTInstanceDidLoadBundle notification after bundle loaded Reviewed By: philIip Differential Revision: D66754060 Pulled By: cipolleschi fbshipit-source-id: d30f0ed73e127936082e6f91e137b9b4013c6651
This commit is contained in:
committed by
Blake Friedman
parent
d1ce8fafb6
commit
e0374f2199
@@ -204,47 +204,51 @@ std::string simpleBasename(const std::string& path) {
|
||||
*/
|
||||
void ReactInstance::loadScript(
|
||||
std::unique_ptr<const JSBigString> script,
|
||||
const std::string& sourceURL) {
|
||||
const std::string& sourceURL,
|
||||
std::function<void(jsi::Runtime& runtime)>&& completion) {
|
||||
auto buffer = std::make_shared<BigStringBuffer>(std::move(script));
|
||||
std::string scriptName = simpleBasename(sourceURL);
|
||||
|
||||
runtimeScheduler_->scheduleWork(
|
||||
[this,
|
||||
scriptName,
|
||||
sourceURL,
|
||||
buffer = std::move(buffer),
|
||||
weakBufferedRuntimeExecuter = std::weak_ptr<BufferedRuntimeExecutor>(
|
||||
bufferedRuntimeExecutor_)](jsi::Runtime& runtime) {
|
||||
SystraceSection s("ReactInstance::loadScript");
|
||||
bool hasLogger(ReactMarker::logTaggedMarkerBridgelessImpl);
|
||||
if (hasLogger) {
|
||||
ReactMarker::logTaggedMarkerBridgeless(
|
||||
ReactMarker::RUN_JS_BUNDLE_START, scriptName.c_str());
|
||||
}
|
||||
runtimeScheduler_->scheduleWork([this,
|
||||
scriptName,
|
||||
sourceURL,
|
||||
buffer = std::move(buffer),
|
||||
weakBufferedRuntimeExecuter =
|
||||
std::weak_ptr<BufferedRuntimeExecutor>(
|
||||
bufferedRuntimeExecutor_),
|
||||
completion](jsi::Runtime& runtime) {
|
||||
SystraceSection s("ReactInstance::loadScript");
|
||||
bool hasLogger(ReactMarker::logTaggedMarkerBridgelessImpl);
|
||||
if (hasLogger) {
|
||||
ReactMarker::logTaggedMarkerBridgeless(
|
||||
ReactMarker::RUN_JS_BUNDLE_START, scriptName.c_str());
|
||||
}
|
||||
|
||||
runtime.evaluateJavaScript(buffer, sourceURL);
|
||||
runtime.evaluateJavaScript(buffer, sourceURL);
|
||||
|
||||
/**
|
||||
* TODO(T183610671): We need a safe/reliable way to enable the js
|
||||
* pipeline from javascript. Remove this after we figure that out, or
|
||||
* after we just remove the js pipeline.
|
||||
*/
|
||||
if (!jsErrorHandler_->hasHandledFatalError()) {
|
||||
jsErrorHandler_->setRuntimeReady();
|
||||
}
|
||||
/**
|
||||
* TODO(T183610671): We need a safe/reliable way to enable the js
|
||||
* pipeline from javascript. Remove this after we figure that out, or
|
||||
* after we just remove the js pipeline.
|
||||
*/
|
||||
if (!jsErrorHandler_->hasHandledFatalError()) {
|
||||
jsErrorHandler_->setRuntimeReady();
|
||||
}
|
||||
|
||||
if (hasLogger) {
|
||||
ReactMarker::logTaggedMarkerBridgeless(
|
||||
ReactMarker::RUN_JS_BUNDLE_STOP, scriptName.c_str());
|
||||
ReactMarker::logMarkerBridgeless(
|
||||
ReactMarker::INIT_REACT_RUNTIME_STOP);
|
||||
ReactMarker::logMarkerBridgeless(ReactMarker::APP_STARTUP_STOP);
|
||||
}
|
||||
if (auto strongBufferedRuntimeExecuter =
|
||||
weakBufferedRuntimeExecuter.lock()) {
|
||||
strongBufferedRuntimeExecuter->flush();
|
||||
}
|
||||
});
|
||||
if (hasLogger) {
|
||||
ReactMarker::logTaggedMarkerBridgeless(
|
||||
ReactMarker::RUN_JS_BUNDLE_STOP, scriptName.c_str());
|
||||
ReactMarker::logMarkerBridgeless(ReactMarker::INIT_REACT_RUNTIME_STOP);
|
||||
ReactMarker::logMarkerBridgeless(ReactMarker::APP_STARTUP_STOP);
|
||||
}
|
||||
if (auto strongBufferedRuntimeExecuter =
|
||||
weakBufferedRuntimeExecuter.lock()) {
|
||||
strongBufferedRuntimeExecuter->flush();
|
||||
}
|
||||
if (completion) {
|
||||
completion(runtime);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -48,7 +48,8 @@ class ReactInstance final : private jsinspector_modern::InstanceTargetDelegate {
|
||||
|
||||
void loadScript(
|
||||
std::unique_ptr<const JSBigString> script,
|
||||
const std::string& sourceURL);
|
||||
const std::string& sourceURL,
|
||||
std::function<void(jsi::Runtime& runtime)>&& completion = nullptr);
|
||||
|
||||
void registerSegment(uint32_t segmentId, const std::string& segmentPath);
|
||||
|
||||
|
||||
+3
-2
@@ -470,8 +470,9 @@ void RCTInstanceSetRuntimeDiagnosticFlags(NSString *flags)
|
||||
|
||||
auto script = std::make_unique<NSDataBigString>(source.data);
|
||||
const auto *url = deriveSourceURL(source.url).UTF8String;
|
||||
_reactInstance->loadScript(std::move(script), url);
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:@"RCTInstanceDidLoadBundle" object:nil];
|
||||
_reactInstance->loadScript(std::move(script), url, [](jsi::Runtime &_) {
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:@"RCTInstanceDidLoadBundle" object:nil];
|
||||
});
|
||||
}
|
||||
|
||||
- (void)_handleJSError:(const JsErrorHandler::ParsedError &)error
|
||||
|
||||
Reference in New Issue
Block a user