Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 8dfbedb

Browse files
committed
Begin engine impl
1 parent 068a15b commit 8dfbedb

File tree

6 files changed

+24
-2
lines changed

6 files changed

+24
-2
lines changed

shell/common/engine.cc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,12 @@ bool Engine::Restart(RunConfiguration configuration) {
144144
return Run(std::move(configuration)) == Engine::RunStatus::Success;
145145
}
146146

147+
Dart_Handle DartDeferredLoadHandler(intptr_t loading_unit_id) {
148+
FML_LOG(ERROR) << "LOAD REQUEST CALLED FOR ID: " << loading_unit_id;
149+
// return delegate_.OnDartLoadLibrary(loading_unit_id);
150+
return Dart_Null();
151+
}
152+
147153
Engine::RunStatus Engine::Run(RunConfiguration configuration) {
148154
if (!configuration.IsValid()) {
149155
FML_LOG(ERROR) << "Engine run configuration was invalid.";
@@ -188,6 +194,8 @@ Engine::RunStatus Engine::Run(RunConfiguration configuration) {
188194
std::vector<uint8_t>(service_id.begin(), service_id.end()),
189195
nullptr);
190196
HandlePlatformMessage(service_id_message);
197+
198+
Dart_SetDeferredLoadHandler(&DartDeferredLoadHandler);
191199
}
192200

193201
return isolate_running ? Engine::RunStatus::Success

shell/common/engine.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include "flutter/shell/common/rasterizer.h"
3030
#include "flutter/shell/common/run_configuration.h"
3131
#include "flutter/shell/common/shell_io_manager.h"
32+
#include "third_party/dart/runtime/include/dart_api.h"
3233
#include "third_party/skia/include/core/SkPicture.h"
3334

3435
namespace flutter {
@@ -249,6 +250,8 @@ class Engine final : public RuntimeDelegate,
249250
virtual std::unique_ptr<std::vector<std::string>>
250251
ComputePlatformResolvedLocale(
251252
const std::vector<std::string>& supported_locale_data) = 0;
253+
254+
virtual Dart_Handle OnDartLoadLibrary(intptr_t loading_unit_id) = 0;
252255
};
253256

254257
//----------------------------------------------------------------------------
@@ -847,6 +850,8 @@ class Engine final : public RuntimeDelegate,
847850

848851
RunStatus PrepareAndLaunchIsolate(RunConfiguration configuration);
849852

853+
// Dart_Handle DartDeferredLoadHandler(intptr_t loading_unit_id);
854+
850855
friend class testing::ShellTest;
851856

852857
FML_DISALLOW_COPY_AND_ASSIGN(Engine);

shell/common/shell.cc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1158,6 +1158,11 @@ Shell::ComputePlatformViewResolvedLocale(
11581158
return platform_view_->ComputePlatformResolvedLocales(supported_locale_data);
11591159
}
11601160

1161+
// |Engine::Delegate|
1162+
Dart_Handle Shell::OnDartLoadLibrary(intptr_t loading_unit_id) {
1163+
return Dart_Null();
1164+
}
1165+
11611166
void Shell::ReportTimings() {
11621167
FML_DCHECK(is_setup_);
11631168
FML_DCHECK(task_runners_.GetRasterTaskRunner()->RunsTasksOnCurrentThread());

shell/common/shell.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
#include "flutter/shell/common/platform_view.h"
3535
#include "flutter/shell/common/rasterizer.h"
3636
#include "flutter/shell/common/shell_io_manager.h"
37+
#include "third_party/dart/runtime/include/dart_api.h"
3738

3839
namespace flutter {
3940

@@ -531,6 +532,9 @@ class Shell final : public PlatformView::Delegate,
531532
std::unique_ptr<std::vector<std::string>> ComputePlatformResolvedLocale(
532533
const std::vector<std::string>& supported_locale_data) override;
533534

535+
// |Engine::Delegate|
536+
Dart_Handle OnDartLoadLibrary(intptr_t loading_unit_id) override;
537+
534538
// |Rasterizer::Delegate|
535539
void OnFrameRasterized(const FrameTiming&) override;
536540

shell/platform/android/io/flutter/embedding/engine/FlutterJNI.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -958,6 +958,7 @@ public void downloadDynamicFeature(@NonNull String moduleName) {
958958
dynamicFeatureManager.downloadModule(moduleName);
959959
}
960960

961+
// This should be called for every loading unit to be loaded into the dart isolate.
961962
@UiThread
962963
public void loadDartLibrary(
963964
@NonNull String bundlePath,
@@ -969,7 +970,6 @@ public void loadDartLibrary(
969970
bundlePath,
970971
assetManager);
971972
}
972-
973973
private native void nativeLoadDartLibrary(
974974
long nativePlatformViewId,
975975
@NonNull String bundlePath,

shell/platform/android/platform_view_android_jni_impl.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,7 @@ static jboolean FlutterTextUtilsIsRegionalIndicator(JNIEnv* env,
514514
static void LoadDartLibrary(JNIEnv* env,
515515
jobject obj,
516516
jlong shell_holder,
517-
jobject jLibPath,
517+
jstring jLibPath,
518518
jobject jAssetManager) {
519519
// see RunBundleAndSnapshotFromLibrary above for dart loading code
520520
auto asset_manager = std::make_shared<flutter::AssetManager>();

0 commit comments

Comments
 (0)