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

Commit a30d197

Browse files
committed
Documentation
1 parent 5ad8d1b commit a30d197

File tree

7 files changed

+125
-11
lines changed

7 files changed

+125
-11
lines changed

runtime/runtime_controller.cc

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,6 @@ void RuntimeController::CompleteDartLoadLibrary(
439439
void* handle = nullptr;
440440
while (handle == nullptr && !searchPaths.empty()) {
441441
std::string path = searchPaths.back();
442-
FML_LOG(ERROR) << "Attempting to open " << path;
443442
handle = ::dlopen(path.c_str(), RTLD_NOW);
444443
searchPaths.pop_back();
445444
if (handle == nullptr) {
@@ -448,10 +447,6 @@ void RuntimeController::CompleteDartLoadLibrary(
448447
}
449448
}
450449
if (handle == nullptr) {
451-
// FML_LOG(ERROR) << "No libs Found for SearchPaths:";
452-
// for (std::string paths : searchPaths) {
453-
// FML_LOG(ERROR) << " " << paths;
454-
// }
455450
root_isolate_.lock()->LoadLoadingUnitFailure(
456451
loading_unit_id, "No lib .so found for provided search paths.", true);
457452
return;

runtime/runtime_controller.h

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -473,11 +473,39 @@ class RuntimeController : public PlatformConfigurationClient {
473473
///
474474
std::optional<uint32_t> GetRootIsolateReturnCode();
475475

476+
//--------------------------------------------------------------------------
477+
/// @brief Loads the dart shared library from disk and into the dart VM
478+
/// based off of the search parameters. When the dart library is
479+
/// loaded successfully, the dart future returned by the
480+
/// originating loadLibrary() call completes.
481+
///
482+
/// @param[in] loading_unit_id The unique id of the deferred library's
483+
/// loading unit.
484+
///
485+
/// @param[in] lib_name The file name of the .so shared library
486+
/// file.
487+
///
488+
/// @param[in] apkPaths The paths of the APKs that may or may not
489+
/// contain the lib_name file.
490+
///
491+
/// @param[in] abi The abi of the library, eg, arm64-v8a
492+
///
476493
void CompleteDartLoadLibrary(intptr_t loading_unit_id,
477494
std::string lib_name,
478495
std::vector<std::string>& apkPaths,
479496
std::string abi);
480497

498+
//--------------------------------------------------------------------------
499+
/// @brief Invoked when the dart VM requests that a deferred library
500+
/// be loaded. Notifies the engine that the requested loading
501+
/// unit should be downloaded and loaded.
502+
///
503+
/// @param[in] loading_unit_id The unique id of the deferred library's
504+
/// loading unit.
505+
///
506+
/// @return A Dart_Handle that is Dart_Null on success, and a dart error
507+
/// on failure.
508+
///
481509
Dart_Handle OnDartLoadLibrary(intptr_t loading_unit_id);
482510

483511
protected:

shell/common/engine.h

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,17 @@ class Engine final : public RuntimeDelegate,
262262
ComputePlatformResolvedLocale(
263263
const std::vector<std::string>& supported_locale_data) = 0;
264264

265+
//--------------------------------------------------------------------------
266+
/// @brief Invoked when the dart VM requests that a deferred library
267+
/// be loaded. Notifies the engine that the requested loading
268+
/// unit should be downloaded and loaded.
269+
///
270+
/// @param[in] loading_unit_id The unique id of the deferred library's
271+
/// loading unit.
272+
///
273+
/// @return A Dart_Handle that is Dart_Null on success, and a dart error
274+
/// on failure.
275+
///
265276
virtual Dart_Handle OnDartLoadLibrary(intptr_t loading_unit_id) = 0;
266277
};
267278

@@ -770,6 +781,23 @@ class Engine final : public RuntimeDelegate,
770781
///
771782
const std::string& InitialRoute() const { return initial_route_; }
772783

784+
//--------------------------------------------------------------------------
785+
/// @brief Loads the dart shared library from disk and into the dart VM
786+
/// based off of the search parameters. When the dart library is
787+
/// loaded successfully, the dart future returned by the
788+
/// originating loadLibrary() call completes.
789+
///
790+
/// @param[in] loading_unit_id The unique id of the deferred library's
791+
/// loading unit.
792+
///
793+
/// @param[in] lib_name The file name of the .so shared library
794+
/// file.
795+
///
796+
/// @param[in] apkPaths The paths of the APKs that may or may not
797+
/// contain the lib_name file.
798+
///
799+
/// @param[in] abi The abi of the library, eg, arm64-v8a
800+
///
773801
void CompleteDartLoadLibrary(intptr_t loading_unit_id,
774802
std::string lib_name,
775803
std::vector<std::string>& apkPaths,

shell/common/platform_view.h

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,14 +229,47 @@ class PlatformView {
229229
ComputePlatformViewResolvedLocale(
230230
const std::vector<std::string>& supported_locale_data) = 0;
231231

232+
//--------------------------------------------------------------------------
233+
/// @brief Invoked when the dart VM requests that a deferred library
234+
/// be loaded. Notifies the engine that the requested loading
235+
/// unit should be downloaded and loaded.
236+
///
237+
/// @param[in] loading_unit_id The unique id of the deferred library's
238+
/// loading unit.
239+
///
240+
/// @return A Dart_Handle that is Dart_Null on success, and a dart error
241+
/// on failure.
242+
///
232243
virtual Dart_Handle OnPlatformViewDartLoadLibrary(
233244
intptr_t loading_unit_id) = 0;
234245

246+
//--------------------------------------------------------------------------
247+
/// @brief Loads the dart shared library from disk and into the dart VM
248+
/// based off of the search parameters. When the dart library is
249+
/// loaded successfully, the dart future returned by the
250+
/// originating loadLibrary() call completes.
251+
///
252+
/// @param[in] loading_unit_id The unique id of the deferred library's
253+
/// loading unit.
254+
///
255+
/// @param[in] lib_name The file name of the .so shared library
256+
/// file.
257+
///
258+
/// @param[in] apkPaths The paths of the APKs that may or may not
259+
/// contain the lib_name file.
260+
///
261+
/// @param[in] abi The abi of the library, eg, arm64-v8a
262+
///
235263
virtual void CompleteDartLoadLibrary(intptr_t loading_unit_id,
236264
std::string lib_name,
237265
std::vector<std::string>& apkPaths,
238266
std::string abi) = 0;
239267

268+
//--------------------------------------------------------------------------
269+
/// @brief Sets the asset manager of the engine to asset_manager
270+
///
271+
/// @param[in] asset_manager The asset manager to use.
272+
///
240273
virtual void UpdateAssetManager(
241274
std::shared_ptr<AssetManager> asset_manager) = 0;
242275
};
@@ -592,8 +625,36 @@ class PlatformView {
592625
ComputePlatformResolvedLocales(
593626
const std::vector<std::string>& supported_locale_data);
594627

628+
//--------------------------------------------------------------------------
629+
/// @brief Invoked when the dart VM requests that a deferred library
630+
/// be loaded. Notifies the engine that the requested loading
631+
/// unit should be downloaded and loaded.
632+
///
633+
/// @param[in] loading_unit_id The unique id of the deferred library's
634+
/// loading unit.
635+
///
636+
/// @return A Dart_Handle that is Dart_Null on success, and a dart error
637+
/// on failure.
638+
///
595639
virtual Dart_Handle OnDartLoadLibrary(intptr_t loading_unit_id);
596640

641+
//--------------------------------------------------------------------------
642+
/// @brief Loads the dart shared library from disk and into the dart VM
643+
/// based off of the search parameters. When the dart library is
644+
/// loaded successfully, the dart future returned by the
645+
/// originating loadLibrary() call completes.
646+
///
647+
/// @param[in] loading_unit_id The unique id of the deferred library's
648+
/// loading unit.
649+
///
650+
/// @param[in] lib_name The file name of the .so shared library
651+
/// file.
652+
///
653+
/// @param[in] apkPaths The paths of the APKs that may or may not
654+
/// contain the lib_name file.
655+
///
656+
/// @param[in] abi The abi of the library, eg, arm64-v8a
657+
///
597658
virtual void CompleteDartLoadLibrary(intptr_t loading_unit_id,
598659
std::string lib_name,
599660
std::vector<std::string>& apkPaths,

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,6 @@ public FlutterEngine(
294294
this.localizationPlugin = new LocalizationPlugin(context, localizationChannel);
295295

296296
this.flutterJNI = flutterJNI;
297-
dynamicFeatureManager = new PlayStoreDynamicFeatureManager(context, flutterJNI);
298297
if (flutterLoader == null) {
299298
flutterLoader = FlutterInjector.instance().flutterLoader();
300299
}
@@ -304,8 +303,11 @@ public FlutterEngine(
304303
flutterJNI.addEngineLifecycleListener(engineLifecycleListener);
305304
flutterJNI.setPlatformViewsController(platformViewsController);
306305
flutterJNI.setLocalizationPlugin(localizationPlugin);
306+
307+
dynamicFeatureManager = new PlayStoreDynamicFeatureManager(context, flutterJNI);
307308
flutterJNI.setDynamicFeatureManager(dynamicFeatureManager);
308309
flutterJNI.setDynamicFeatureContext(context);
310+
309311
attachToJni();
310312

311313
// TODO(mattcarroll): FlutterRenderer is temporally coupled to attach(). Remove that coupling if

shell/platform/android/io/flutter/embedding/engine/dynamicfeatures/DynamicFeatureManager.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,19 @@
44

55
package io.flutter.embedding.engine.dynamicfeatures;
66

7-
// Flutter dynamic feature support is still in early developer preview, and should
7+
// Flutter dynamic feature support is still in early developer preview and should
88
// not be used in production apps yet.
99

1010
/**
11-
* Basic interface that may be implemented to provide custom handling of dynamic features.
11+
* Basic interface that handles downloading and loading of dynamic features.
1212
*
1313
* The Flutter default implementation is PlayStoreDynamicFeatureManager.
1414
*
1515
* The methods here may be called independently or in a sequence one after the other to perform
16-
* a full install cycle of download, extract, and load dart libs.
16+
* a full install cycle of download, load assets, and load dart libs.
1717
*
1818
* A dynamic feature module is uniquely identified by a module name. Each feature module may
19-
* also contain one or more loading units, uniquely identified by the loading unit ID.
19+
* contain one or more loading units, uniquely identified by the loading unit ID.
2020
*/
2121
public interface DynamicFeatureManager {
2222
/**

shell/platform/android/platform_view_android.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ Dart_Handle PlatformViewAndroid::OnDartLoadLibrary(intptr_t loading_unit_id) {
347347
if (jni_facade_->FlutterViewDownloadDynamicFeature(loading_unit_id)) {
348348
return Dart_Null();
349349
}
350-
return Dart_Null(); // TODO: RETURN ERROR
350+
return Dart_Null(); // TODO(garyq): RETURN ERROR
351351
}
352352

353353
// |PlatformView|

0 commit comments

Comments
 (0)