diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/FlutterEngineGroup.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/FlutterEngineGroup.ets index 817cbd3faf0eda0b4cb2962baeb776ea06a5c87c..1ee3eae90f58b9ef536707d7c395be379d0a3c5a 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/FlutterEngineGroup.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/FlutterEngineGroup.ets @@ -22,6 +22,9 @@ import PlatformViewsController from '../../plugin/platform/PlatformViewsControll import ArrayList from '@ohos.util.ArrayList' import { FlutterPlugin } from './plugins/FlutterPlugin' import List from '@ohos.util.List'; +import Log from '../../util/Log'; + +const TAG = "FlutterEngineGroup" export default class FlutterEngineGroup { private activeEngines: ArrayList = new ArrayList(); @@ -57,6 +60,7 @@ export default class FlutterEngineGroup { platformViewsController = new PlatformViewsController(); } + Log.i(TAG, "shellHolder, this.activeEngines.length=" + this.activeEngines.length) if (this.activeEngines.length == 0) { engine = this.createEngine(context, platformViewsController); await engine.init(context, null, // String[]. The Dart VM has already started, this arguments will have no effect. diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/platform/RootDvModelManager.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/platform/RootDvModelManager.ets index 54ef775d0a1e2ef72d54913ca2540958dc0df6fe..a4d3da8a2393bd9f3da93d4e1578c2516046bf5a 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/platform/RootDvModelManager.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/platform/RootDvModelManager.ets @@ -18,6 +18,7 @@ import { DVModel, DVModelContainer, DVModelEvents, DVModelParameters } from '../../view/DynamicView/dynamicView'; +import Log from '../../util/Log'; export class RootDvModeManager { private static model: DVModel = new DVModel("Stack", new DVModelParameters(), new DVModelEvents(), new DVModelChildren(), null); @@ -30,5 +31,6 @@ export class RootDvModeManager { public static addDvModel(model: DVModel): void { RootDvModeManager.container.model.children.push(model); + Log.i("flutter RootDvModeManager", 'DVModel: %{public}s', JSON.stringify(RootDvModeManager.container.model.children) ?? ''); } } diff --git a/shell/platform/ohos/napi/platform_view_ohos_napi.cpp b/shell/platform/ohos/napi/platform_view_ohos_napi.cpp index 3da5999832a2295bb2342a6f3b9831a20847faa3..6b18f7ea5bd96142901f7ae8c819396de0dd8dbb 100644 --- a/shell/platform/ohos/napi/platform_view_ohos_napi.cpp +++ b/shell/platform/ohos/napi/platform_view_ohos_napi.cpp @@ -30,9 +30,7 @@ #define OHOS_SHELL_HOLDER (reinterpret_cast(shell_holder)) namespace flutter { -int64_t PlatformViewOHOSNapi::shell_holder_value; napi_env PlatformViewOHOSNapi::env_; -napi_ref PlatformViewOHOSNapi::ref_napi_obj_; std::vector PlatformViewOHOSNapi::system_languages; /** @@ -412,7 +410,7 @@ void PlatformViewOHOSNapi::DecodeImage(int64_t imageGeneratorAddress, FML_DLOG(INFO) << "start decodeImage"; platform_task_runner_->PostTask(fml::MakeCopyable( [imageGeneratorAddress_ = imageGeneratorAddress, - inputData_ = std::move(inputData), dataSize_ = dataSize]() mutable { + inputData_ = std::move(inputData), dataSize_ = dataSize, this]() mutable { napi_value callbackParam[2]; callbackParam[0] = @@ -446,10 +444,10 @@ napi_value PlatformViewOHOSNapi::nativeAttach(napi_env env, if (status != napi_ok) { FML_DLOG(ERROR) << "nativeAttach Failed to get napiObjec info"; } - napi_create_reference(env, argv[0], 1, &ref_napi_obj_); std::shared_ptr napi_facade = std::make_shared(env); + napi_create_reference(env, argv[0], 1, &(napi_facade->ref_napi_obj_)); uv_loop_t* platform_loop = nullptr; status = napi_get_uv_event_loop(env, &platform_loop); @@ -460,10 +458,10 @@ napi_value PlatformViewOHOSNapi::nativeAttach(napi_env env, auto shell_holder = std::make_unique( OhosMain::Get().GetSettings(), napi_facade, platform_loop); if (shell_holder->IsValid()) { - PlatformViewOHOSNapi::shell_holder_value = + int64_t shell_holder_value = reinterpret_cast(shell_holder.get()); FML_DLOG(INFO) << "PlatformViewOHOSNapi shell_holder:" - << PlatformViewOHOSNapi::shell_holder_value; + << shell_holder_value; napi_value id; napi_create_int64(env, reinterpret_cast(shell_holder.release()), &id); @@ -1418,10 +1416,6 @@ napi_value PlatformViewOHOSNapi::nativeGetSystemLanguages( return nullptr; } -int64_t PlatformViewOHOSNapi::GetShellHolder() { - return PlatformViewOHOSNapi::shell_holder_value; -} - void PlatformViewOHOSNapi::SurfaceCreated(int64_t shell_holder, void* window) { auto native_window = fml::MakeRefCounted( static_cast(window)); diff --git a/shell/platform/ohos/napi/platform_view_ohos_napi.h b/shell/platform/ohos/napi/platform_view_ohos_napi.h index d32a6fe996af7bfc8c75556cda66321e12f13f51..3ae1760151a3e03c6832eeae153665531b51c32c 100644 --- a/shell/platform/ohos/napi/platform_view_ohos_napi.h +++ b/shell/platform/ohos/napi/platform_view_ohos_napi.h @@ -153,8 +153,7 @@ class PlatformViewOHOSNapi { private: static napi_env env_; - static napi_ref ref_napi_obj_; - static int64_t shell_holder_value; + napi_ref ref_napi_obj_; static std::vector system_languages; fml::RefPtr platform_task_runner_; };