Fix: 通用规范告警

Signed-off-by: yangziyong <nsyangziyong@huawei.com>
This commit is contained in:
yangziyong 2024-06-27 09:34:59 +08:00
parent 37e956bc20
commit 2d6a6a2ef7
10 changed files with 377 additions and 293 deletions

View File

@ -245,25 +245,29 @@ void DataDetectorAdapter::InitTextDetect(int32_t startPos, std::string detectTex
auto context = host->GetContext();
CHECK_NULL_VOID(context);
auto uiTaskExecutor = SingleTaskExecutor::Make(context->GetTaskExecutor(), TaskExecutor::TaskType::UI);
uiTaskExecutor.PostTask([result, weak, instanceID, startPos, info] {
ContainerScope scope(instanceID);
auto dataDetectorAdapter = weak.Upgrade();
CHECK_NULL_VOID(dataDetectorAdapter);
if (info.module != dataDetectorAdapter->textDetectTypes_) {
return;
}
dataDetectorAdapter->ParseAIResult(result, startPos);
auto host = dataDetectorAdapter->GetHost();
CHECK_NULL_VOID(host);
host->MarkDirtyNode(NG::PROPERTY_UPDATE_MEASURE);
}, "ArkUITextParseAIResult");
uiTaskExecutor.PostTask(
[result, weak, instanceID, startPos, info] {
ContainerScope scope(instanceID);
auto dataDetectorAdapter = weak.Upgrade();
CHECK_NULL_VOID(dataDetectorAdapter);
if (info.module != dataDetectorAdapter->textDetectTypes_) {
return;
}
dataDetectorAdapter->ParseAIResult(result, startPos);
auto host = dataDetectorAdapter->GetHost();
CHECK_NULL_VOID(host);
host->MarkDirtyNode(NG::PROPERTY_UPDATE_MEASURE);
},
"ArkUITextParseAIResult");
};
auto uiTaskExecutor = SingleTaskExecutor::Make(context->GetTaskExecutor(), TaskExecutor::TaskType::BACKGROUND);
uiTaskExecutor.PostTask([info, textFunc] {
TAG_LOGI(AceLogTag::ACE_TEXT, "Start entity detect using AI");
DataDetectorMgr::GetInstance().DataDetect(info, textFunc);
}, "ArkUITextInitDataDetect");
uiTaskExecutor.PostTask(
[info, textFunc] {
TAG_LOGI(AceLogTag::ACE_TEXT, "Start entity detect using AI");
DataDetectorMgr::GetInstance().DataDetect(info, textFunc);
},
"ArkUITextInitDataDetect");
}
void DataDetectorAdapter::ParseAIResult(const TextDataDetectResult& result, int32_t startPos)

View File

@ -79,21 +79,25 @@ void MovingPhotoPattern::OnAttachToFrameNode()
CHECK_NULL_VOID(context);
auto uiTaskExecutor = SingleTaskExecutor::Make(context->GetTaskExecutor(), TaskExecutor::TaskType::UI);
controller_->SetStartPlaybackImpl([weak = WeakClaim(this), uiTaskExecutor]() {
uiTaskExecutor.PostTask([weak]() {
auto pattern = weak.Upgrade();
CHECK_NULL_VOID(pattern);
ContainerScope scope(pattern->instanceId_);
pattern->StartPlayback();
}, "ArkUIMovingPhotoStart");
uiTaskExecutor.PostTask(
[weak]() {
auto pattern = weak.Upgrade();
CHECK_NULL_VOID(pattern);
ContainerScope scope(pattern->instanceId_);
pattern->StartPlayback();
},
"ArkUIMovingPhotoStart");
});
controller_->SetStopPlaybackImpl([weak = WeakClaim(this), uiTaskExecutor]() {
uiTaskExecutor.PostTask([weak]() {
auto pattern = weak.Upgrade();
CHECK_NULL_VOID(pattern);
ContainerScope scope(pattern->instanceId_);
pattern->StopPlayback();
}, "ArkUIMovingPhotoStop");
uiTaskExecutor.PostTask(
[weak]() {
auto pattern = weak.Upgrade();
CHECK_NULL_VOID(pattern);
ContainerScope scope(pattern->instanceId_);
pattern->StopPlayback();
},
"ArkUIMovingPhotoStop");
});
RegisterVisibleAreaChange();
@ -239,14 +243,16 @@ void MovingPhotoPattern::UpdateVideoNode()
auto pipelineContext = PipelineContext::GetCurrentContext();
CHECK_NULL_VOID(pipelineContext);
auto uiTaskExecutor = SingleTaskExecutor::Make(pipelineContext->GetTaskExecutor(), TaskExecutor::TaskType::UI);
uiTaskExecutor.PostTask([weak = WeakClaim(this)]() {
auto movingPhotoPattern = weak.Upgrade();
CHECK_NULL_VOID(movingPhotoPattern);
ContainerScope scope(movingPhotoPattern->instanceId_);
movingPhotoPattern->PrepareMediaPlayer();
movingPhotoPattern->UpdateMediaPlayerSpeed();
movingPhotoPattern->UpdateMediaPlayerMuted();
}, "ArkUIMovingPhotoUpdateVideo");
uiTaskExecutor.PostTask(
[weak = WeakClaim(this)]() {
auto movingPhotoPattern = weak.Upgrade();
CHECK_NULL_VOID(movingPhotoPattern);
ContainerScope scope(movingPhotoPattern->instanceId_);
movingPhotoPattern->PrepareMediaPlayer();
movingPhotoPattern->UpdateMediaPlayerSpeed();
movingPhotoPattern->UpdateMediaPlayerMuted();
},
"ArkUIMovingPhotoUpdateVideo");
}
void MovingPhotoPattern::PrepareMediaPlayer()
@ -275,11 +281,13 @@ void MovingPhotoPattern::PrepareMediaPlayer()
auto context = PipelineContext::GetCurrentContext();
CHECK_NULL_VOID(context);
auto platformTask = SingleTaskExecutor::Make(context->GetTaskExecutor(), TaskExecutor::TaskType::BACKGROUND);
platformTask.PostTask([weak = WeakClaim(this)] {
auto movingPhotoPattern = weak.Upgrade();
CHECK_NULL_VOID(movingPhotoPattern);
movingPhotoPattern->ResetMediaPlayer();
}, "ArkUIMovingPhotoPrepare");
platformTask.PostTask(
[weak = WeakClaim(this)] {
auto movingPhotoPattern = weak.Upgrade();
CHECK_NULL_VOID(movingPhotoPattern);
movingPhotoPattern->ResetMediaPlayer();
},
"ArkUIMovingPhotoPrepare");
}
void MovingPhotoPattern::ResetMediaPlayer()
@ -294,12 +302,14 @@ void MovingPhotoPattern::ResetMediaPlayer()
CHECK_NULL_VOID(context);
auto uiTaskExecutor = SingleTaskExecutor::Make(context->GetTaskExecutor(), TaskExecutor::TaskType::UI);
uiTaskExecutor.PostTask([weak = WeakClaim(this)] {
auto pattern = weak.Upgrade();
CHECK_NULL_VOID(pattern);
ContainerScope scope(pattern->instanceId_);
pattern->FireMediaPlayerError();
}, "ArkUIMovingPhotoReset");
uiTaskExecutor.PostTask(
[weak = WeakClaim(this)] {
auto pattern = weak.Upgrade();
CHECK_NULL_VOID(pattern);
ContainerScope scope(pattern->instanceId_);
pattern->FireMediaPlayerError();
},
"ArkUIMovingPhotoReset");
return;
}
RegisterMediaPlayerEvent();
@ -565,7 +575,8 @@ SizeF MovingPhotoPattern::GetRawImageSize()
return imagePattern->GetRawImageSize();
}
SizeF MovingPhotoPattern::MeasureContentLayout(const SizeF& layoutSize, const RefPtr<MovingPhotoLayoutProperty>& layoutProperty)
SizeF MovingPhotoPattern::MeasureContentLayout(const SizeF& layoutSize,
const RefPtr<MovingPhotoLayoutProperty>& layoutProperty)
{
if (!layoutProperty || !layoutProperty->HasVideoSize()) {
return layoutSize;
@ -811,11 +822,13 @@ void MovingPhotoPattern::Start()
CHECK_NULL_VOID(context);
auto platformTask = SingleTaskExecutor::Make(context->GetTaskExecutor(), TaskExecutor::TaskType::BACKGROUND);
platformTask.PostTask([weak = WeakClaim(RawPtr(mediaPlayer_))] {
auto mediaPlayer = weak.Upgrade();
CHECK_NULL_VOID(mediaPlayer);
mediaPlayer->Play();
}, "ArkUIMovingPhotoStartPlay");
platformTask.PostTask(
[weak = WeakClaim(RawPtr(mediaPlayer_))] {
auto mediaPlayer = weak.Upgrade();
CHECK_NULL_VOID(mediaPlayer);
mediaPlayer->Play();
},
"ArkUIMovingPhotoStartPlay");
}
void MovingPhotoPattern::Pause()
@ -829,11 +842,13 @@ void MovingPhotoPattern::Pause()
CHECK_NULL_VOID(context);
auto platformTask = SingleTaskExecutor::Make(context->GetTaskExecutor(), TaskExecutor::TaskType::BACKGROUND);
platformTask.PostTask([weak = WeakClaim(RawPtr(mediaPlayer_))] {
auto mediaPlayer = weak.Upgrade();
CHECK_NULL_VOID(mediaPlayer);
mediaPlayer->Pause();
}, "ArkUIMovingPhotoPausePlay");
platformTask.PostTask(
[weak = WeakClaim(RawPtr(mediaPlayer_))] {
auto mediaPlayer = weak.Upgrade();
CHECK_NULL_VOID(mediaPlayer);
mediaPlayer->Pause();
},
"ArkUIMovingPhotoPausePlay");
}
void MovingPhotoPattern::Stop()
@ -847,11 +862,13 @@ void MovingPhotoPattern::Stop()
CHECK_NULL_VOID(context);
auto platformTask = SingleTaskExecutor::Make(context->GetTaskExecutor(), TaskExecutor::TaskType::BACKGROUND);
platformTask.PostTask([weak = WeakClaim(RawPtr(mediaPlayer_))] {
auto mediaPlayer = weak.Upgrade();
CHECK_NULL_VOID(mediaPlayer);
mediaPlayer->Stop();
}, "ArkUIMovingPhotoStopPlay");
platformTask.PostTask(
[weak = WeakClaim(RawPtr(mediaPlayer_))] {
auto mediaPlayer = weak.Upgrade();
CHECK_NULL_VOID(mediaPlayer);
mediaPlayer->Stop();
},
"ArkUIMovingPhotoStopPlay");
}
void MovingPhotoPattern::Seek(int32_t position)
@ -865,11 +882,13 @@ void MovingPhotoPattern::Seek(int32_t position)
CHECK_NULL_VOID(context);
auto platformTask = SingleTaskExecutor::Make(context->GetTaskExecutor(), TaskExecutor::TaskType::BACKGROUND);
platformTask.PostTask([weak = WeakClaim(RawPtr(mediaPlayer_)), pos = position] {
auto mediaPlayer = weak.Upgrade();
CHECK_NULL_VOID(mediaPlayer);
mediaPlayer->Seek(pos, SeekMode::SEEK_PREVIOUS_SYNC);
}, "ArkUIMovingPhotoSeek");
platformTask.PostTask(
[weak = WeakClaim(RawPtr(mediaPlayer_)), pos = position] {
auto mediaPlayer = weak.Upgrade();
CHECK_NULL_VOID(mediaPlayer);
mediaPlayer->Seek(pos, SeekMode::SEEK_PREVIOUS_SYNC);
},
"ArkUIMovingPhotoSeek");
}
void MovingPhotoPattern::UpdateMediaPlayerSpeed()
@ -882,11 +901,13 @@ void MovingPhotoPattern::UpdateMediaPlayerSpeed()
auto context = PipelineContext::GetCurrentContext();
CHECK_NULL_VOID(context);
auto platformTask = SingleTaskExecutor::Make(context->GetTaskExecutor(), TaskExecutor::TaskType::BACKGROUND);
platformTask.PostTask([weak = WeakClaim(RawPtr(mediaPlayer_))] {
auto mediaPlayer = weak.Upgrade();
CHECK_NULL_VOID(mediaPlayer);
mediaPlayer->SetPlaybackSpeed(static_cast<float>(NORMAL_PLAY_SPEED));
}, "ArkUIMovingPhotoUpdateSpeed");
platformTask.PostTask(
[weak = WeakClaim(RawPtr(mediaPlayer_))] {
auto mediaPlayer = weak.Upgrade();
CHECK_NULL_VOID(mediaPlayer);
mediaPlayer->SetPlaybackSpeed(static_cast<float>(NORMAL_PLAY_SPEED));
},
"ArkUIMovingPhotoUpdateSpeed");
}
void MovingPhotoPattern::UpdateMediaPlayerMuted()
@ -900,11 +921,13 @@ void MovingPhotoPattern::UpdateMediaPlayerMuted()
auto context = PipelineContext::GetCurrentContext();
CHECK_NULL_VOID(context);
auto platformTask = SingleTaskExecutor::Make(context->GetTaskExecutor(), TaskExecutor::TaskType::BACKGROUND);
platformTask.PostTask([weak = WeakClaim(RawPtr(mediaPlayer_)), videoVolume = volume] {
auto mediaPlayer = weak.Upgrade();
CHECK_NULL_VOID(mediaPlayer);
mediaPlayer->SetVolume(videoVolume, videoVolume);
}, "ArkUIMovingPhotoUpdateMuted");
platformTask.PostTask(
[weak = WeakClaim(RawPtr(mediaPlayer_)), videoVolume = volume] {
auto mediaPlayer = weak.Upgrade();
CHECK_NULL_VOID(mediaPlayer);
mediaPlayer->SetVolume(videoVolume, videoVolume);
},
"ArkUIMovingPhotoUpdateMuted");
}
void MovingPhotoPattern::OnAreaChangedInner()

View File

@ -63,12 +63,14 @@ shared_ptr<JsValue> AppTerminate(const shared_ptr<JsRuntime>& runtime, const sha
}
auto uiTaskExecutor = delegate->GetUiTask();
WeakPtr<PipelineBase> pipelineContextWeak(pipelineContext);
uiTaskExecutor.PostTask([pipelineContextWeak]() mutable {
auto pipelineContext = pipelineContextWeak.Upgrade();
if (pipelineContext) {
pipelineContext->Finish();
}
}, "ArkUIAppTerminate");
uiTaskExecutor.PostTask(
[pipelineContextWeak]() mutable {
auto pipelineContext = pipelineContextWeak.Upgrade();
if (pipelineContext) {
pipelineContext->Finish();
}
},
"ArkUIAppTerminate");
return runtime->NewNull();
}
@ -95,15 +97,17 @@ shared_ptr<JsValue> AppSetImageCacheCount(const shared_ptr<JsRuntime>& runtime,
return runtime->NewNull();
}
WeakPtr<PipelineBase> pipelineContextWeak(pipelineContext);
taskExecutor->PostTask([ pipelineContextWeak, size ]() mutable {
auto pipelineContext = pipelineContextWeak.Upgrade();
if (pipelineContext) {
auto imageCache = pipelineContext->GetImageCache();
if (imageCache) {
imageCache->SetCapacity(size);
taskExecutor->PostTask(
[pipelineContextWeak, size]() mutable {
auto pipelineContext = pipelineContextWeak.Upgrade();
if (pipelineContext) {
auto imageCache = pipelineContext->GetImageCache();
if (imageCache) {
imageCache->SetCapacity(size);
}
}
}
}, TaskExecutor::TaskType::UI, "ArkUISetImageCacheCount");
},
TaskExecutor::TaskType::UI, "ArkUISetImageCacheCount");
return runtime->NewNull();
}
@ -132,15 +136,17 @@ shared_ptr<JsValue> AppSetImageRawDataCacheSize(
return runtime->NewNull();
}
WeakPtr<PipelineBase> pipelineContextWeak(pipelineContext);
taskExecutor->PostTask([ pipelineContextWeak, size ]() mutable {
auto pipelineContext = pipelineContextWeak.Upgrade();
if (pipelineContext) {
auto imageCache = pipelineContext->GetImageCache();
if (imageCache) {
imageCache->SetDataCacheLimit(size);
taskExecutor->PostTask(
[pipelineContextWeak, size]() mutable {
auto pipelineContext = pipelineContextWeak.Upgrade();
if (pipelineContext) {
auto imageCache = pipelineContext->GetImageCache();
if (imageCache) {
imageCache->SetDataCacheLimit(size);
}
}
}
}, TaskExecutor::TaskType::UI, "ArkUISetImageDataCacheSize");
},
TaskExecutor::TaskType::UI, "ArkUISetImageDataCacheSize");
return runtime->NewNull();
}

View File

@ -303,10 +303,12 @@ void AddFrameListener(const WeakPtr<JsiAnimatorBridge>& bridgeWeak, const RefPtr
return;
}
auto jsTaskExecutor = delegate->GetAnimationJsTask();
jsTaskExecutor.PostTask([bridgeWeak, weakRuntime, value]() mutable {
LOGI("call animation onframe event");
CallAnimationFrameJs(bridgeWeak, weakRuntime.lock(), value);
}, "ArkUIAnimationFrame");
jsTaskExecutor.PostTask(
[bridgeWeak, weakRuntime, value]() mutable {
LOGI("call animation onframe event");
CallAnimationFrameJs(bridgeWeak, weakRuntime.lock(), value);
},
"ArkUIAnimationFrame");
});
}
@ -589,12 +591,14 @@ void JsiAnimatorTaskCreate::AnimatorBridgeTaskFunc(const RefPtr<JsAcePage>& page
auto jsTaskExecutor = delegate->GetAnimationJsTask();
if (bridgeFree) {
auto weakBridge = AceType::WeakClaim(AceType::RawPtr(bridgeFree));
jsTaskExecutor.PostTask([weakBridge]() mutable {
auto bridgeFree = weakBridge.Upgrade();
if (bridgeFree != nullptr) {
bridgeFree.Reset();
}
}, "ArkUIAnimatorBridgeRelease");
jsTaskExecutor.PostTask(
[weakBridge]() mutable {
auto bridgeFree = weakBridge.Upgrade();
if (bridgeFree != nullptr) {
bridgeFree.Reset();
}
},
"ArkUIAnimatorBridgeRelease");
}
page->RemoveAnimatorBridge(bridgeId);
bridge_->JsCreateAnimation(param_);

View File

@ -298,12 +298,14 @@ void FrontendDelegateImpl::TransferComponentResponseData(int32_t callbackId, int
void FrontendDelegateImpl::TransferJsResponseData(int32_t callbackId, int32_t code, std::vector<uint8_t>&& data) const
{
auto weak = AceType::WeakClaim(AceType::RawPtr(groupJsBridge_));
taskExecutor_->PostTask([callbackId, code, data = std::move(data), weak]() mutable {
auto groupJsBridge = weak.Upgrade();
if (groupJsBridge) {
groupJsBridge->TriggerModuleJsCallback(callbackId, code, std::move(data));
}
}, TaskExecutor::TaskType::JS, "ArkUITransferJsResponseData");
taskExecutor_->PostTask(
[callbackId, code, data = std::move(data), weak]() mutable {
auto groupJsBridge = weak.Upgrade();
if (groupJsBridge) {
groupJsBridge->TriggerModuleJsCallback(callbackId, code, std::move(data));
}
},
TaskExecutor::TaskType::JS, "ArkUITransferJsResponseData");
}
#if defined(PREVIEW)
@ -312,12 +314,14 @@ void FrontendDelegateImpl::TransferJsResponseDataPreview(
{
LOGI("JsFrontend TransferJsResponseDataPreview");
auto weak = AceType::WeakClaim(AceType::RawPtr(groupJsBridge_));
taskExecutor_->PostTask([callbackId, code, responseData, weak]() mutable {
auto groupJsBridge = weak.Upgrade();
if (groupJsBridge) {
groupJsBridge->TriggerModuleJsCallbackPreview(callbackId, code, responseData);
}
}, TaskExecutor::TaskType::JS, "ArkUITransferJsResponseData");
taskExecutor_->PostTask(
[callbackId, code, responseData, weak]() mutable {
auto groupJsBridge = weak.Upgrade();
if (groupJsBridge) {
groupJsBridge->TriggerModuleJsCallbackPreview(callbackId, code, responseData);
}
},
TaskExecutor::TaskType::JS, "ArkUITransferJsResponseData");
}
#endif
@ -325,45 +329,53 @@ void FrontendDelegateImpl::TransferJsPluginGetError(
int32_t callbackId, int32_t errorCode, std::string&& errorMessage) const
{
auto weak = AceType::WeakClaim(AceType::RawPtr(groupJsBridge_));
taskExecutor_->PostTask([callbackId, errorCode, errorMessage = std::move(errorMessage), weak]() mutable {
auto groupJsBridge = weak.Upgrade();
if (groupJsBridge) {
groupJsBridge->TriggerModulePluginGetErrorCallback(callbackId, errorCode, std::move(errorMessage));
}
}, TaskExecutor::TaskType::JS, "ArkUITransferJsPluginGetError");
taskExecutor_->PostTask(
[callbackId, errorCode, errorMessage = std::move(errorMessage), weak]() mutable {
auto groupJsBridge = weak.Upgrade();
if (groupJsBridge) {
groupJsBridge->TriggerModulePluginGetErrorCallback(callbackId, errorCode, std::move(errorMessage));
}
},
TaskExecutor::TaskType::JS, "ArkUITransferJsPluginGetError");
}
void FrontendDelegateImpl::TransferJsEventData(int32_t callbackId, int32_t code, std::vector<uint8_t>&& data) const
{
auto weak = AceType::WeakClaim(AceType::RawPtr(groupJsBridge_));
taskExecutor_->PostTask([callbackId, code, data = std::move(data), weak]() mutable {
auto groupJsBridge = weak.Upgrade();
if (groupJsBridge) {
groupJsBridge->TriggerEventJsCallback(callbackId, code, std::move(data));
}
}, TaskExecutor::TaskType::JS, "ArkUITransferJsEventData");
taskExecutor_->PostTask(
[callbackId, code, data = std::move(data), weak]() mutable {
auto groupJsBridge = weak.Upgrade();
if (groupJsBridge) {
groupJsBridge->TriggerEventJsCallback(callbackId, code, std::move(data));
}
},
TaskExecutor::TaskType::JS, "ArkUITransferJsEventData");
}
void FrontendDelegateImpl::LoadPluginJsCode(std::string&& jsCode) const
{
auto weak = AceType::WeakClaim(AceType::RawPtr(groupJsBridge_));
taskExecutor_->PostTask([jsCode = std::move(jsCode), weak]() mutable {
auto groupJsBridge = weak.Upgrade();
if (groupJsBridge) {
groupJsBridge->LoadPluginJsCode(std::move(jsCode));
}
}, TaskExecutor::TaskType::JS, "ArkUILoadPluginJsCode");
taskExecutor_->PostTask(
[jsCode = std::move(jsCode), weak]() mutable {
auto groupJsBridge = weak.Upgrade();
if (groupJsBridge) {
groupJsBridge->LoadPluginJsCode(std::move(jsCode));
}
},
TaskExecutor::TaskType::JS, "ArkUILoadPluginJsCode");
}
void FrontendDelegateImpl::LoadPluginJsByteCode(std::vector<uint8_t>&& jsCode, std::vector<int32_t>&& jsCodeLen) const
{
auto weak = AceType::WeakClaim(AceType::RawPtr(groupJsBridge_));
taskExecutor_->PostTask([jsCode = std::move(jsCode), jsCodeLen = std::move(jsCodeLen), weak]() mutable {
auto groupJsBridge = weak.Upgrade();
if (groupJsBridge) {
groupJsBridge->LoadPluginJsByteCode(std::move(jsCode), std::move(jsCodeLen));
}
}, TaskExecutor::TaskType::JS, "ArkUILoadPluginJsByteCode");
taskExecutor_->PostTask(
[jsCode = std::move(jsCode), jsCodeLen = std::move(jsCodeLen), weak]() mutable {
auto groupJsBridge = weak.Upgrade();
if (groupJsBridge) {
groupJsBridge->LoadPluginJsByteCode(std::move(jsCode), std::move(jsCodeLen));
}
},
TaskExecutor::TaskType::JS, "ArkUILoadPluginJsByteCode");
}
bool FrontendDelegateImpl::OnPageBackPress()
@ -400,12 +412,14 @@ void FrontendDelegateImpl::OnForeground()
bool FrontendDelegateImpl::OnStartContinuation()
{
bool ret = false;
taskExecutor_->PostSyncTask([weak = AceType::WeakClaim(this), &ret] {
auto delegate = weak.Upgrade();
if (delegate && delegate->onStartContinuationCallBack_) {
ret = delegate->onStartContinuationCallBack_();
}
}, TaskExecutor::TaskType::JS, "ArkUIStartContinuationCallback");
taskExecutor_->PostSyncTask(
[weak = AceType::WeakClaim(this), &ret] {
auto delegate = weak.Upgrade();
if (delegate && delegate->onStartContinuationCallBack_) {
ret = delegate->onStartContinuationCallBack_();
}
},
TaskExecutor::TaskType::JS, "ArkUIStartContinuationCallback");
if (!ret) {
ret = FireSyncEvent("_root", std::string("\"onStartContinuation\","), std::string(""));
}
@ -414,34 +428,40 @@ bool FrontendDelegateImpl::OnStartContinuation()
void FrontendDelegateImpl::OnCompleteContinuation(int32_t code)
{
taskExecutor_->PostSyncTask([weak = AceType::WeakClaim(this), code] {
auto delegate = weak.Upgrade();
if (delegate && delegate->onCompleteContinuationCallBack_) {
delegate->onCompleteContinuationCallBack_(code);
}
}, TaskExecutor::TaskType::JS, "ArkUICompleteContinuationCallback");
taskExecutor_->PostSyncTask(
[weak = AceType::WeakClaim(this), code] {
auto delegate = weak.Upgrade();
if (delegate && delegate->onCompleteContinuationCallBack_) {
delegate->onCompleteContinuationCallBack_(code);
}
},
TaskExecutor::TaskType::JS, "ArkUICompleteContinuationCallback");
FireSyncEvent("_root", std::string("\"onCompleteContinuation\","), std::to_string(code));
}
void FrontendDelegateImpl::OnRemoteTerminated()
{
taskExecutor_->PostSyncTask([weak = AceType::WeakClaim(this)] {
auto delegate = weak.Upgrade();
if (delegate && delegate->onRemoteTerminatedCallBack_) {
delegate->onRemoteTerminatedCallBack_();
}
}, TaskExecutor::TaskType::JS, "ArkUIRemoteTerminatedCallback");
taskExecutor_->PostSyncTask(
[weak = AceType::WeakClaim(this)] {
auto delegate = weak.Upgrade();
if (delegate && delegate->onRemoteTerminatedCallBack_) {
delegate->onRemoteTerminatedCallBack_();
}
},
TaskExecutor::TaskType::JS, "ArkUIRemoteTerminatedCallback");
}
void FrontendDelegateImpl::OnSaveData(std::string& data)
{
std::string savedData;
taskExecutor_->PostSyncTask([weak = AceType::WeakClaim(this), &savedData] {
auto delegate = weak.Upgrade();
if (delegate && delegate->onSaveDataCallBack_) {
delegate->onSaveDataCallBack_(savedData);
}
}, TaskExecutor::TaskType::JS, "ArkUISaveDataCallback");
taskExecutor_->PostSyncTask(
[weak = AceType::WeakClaim(this), &savedData] {
auto delegate = weak.Upgrade();
if (delegate && delegate->onSaveDataCallBack_) {
delegate->onSaveDataCallBack_(savedData);
}
},
TaskExecutor::TaskType::JS, "ArkUISaveDataCallback");
if (savedData.empty()) {
FireSyncEvent("_root", std::string("\"onSaveData\","), std::string(""), savedData);
}
@ -452,12 +472,14 @@ void FrontendDelegateImpl::OnSaveData(std::string& data)
bool FrontendDelegateImpl::OnRestoreData(const std::string& data)
{
bool ret = false;
taskExecutor_->PostSyncTask([weak = AceType::WeakClaim(this), &data, &ret] {
auto delegate = weak.Upgrade();
if (delegate && delegate->onRestoreDataCallBack_) {
ret = delegate->onRestoreDataCallBack_(data);
}
}, TaskExecutor::TaskType::JS, "ArkUIRestoreDataCallback");
taskExecutor_->PostSyncTask(
[weak = AceType::WeakClaim(this), &data, &ret] {
auto delegate = weak.Upgrade();
if (delegate && delegate->onRestoreDataCallBack_) {
ret = delegate->onRestoreDataCallBack_(data);
}
},
TaskExecutor::TaskType::JS, "ArkUIRestoreDataCallback");
FireSyncEvent("_root", std::string("\"onSaveData\","), data);
return ret;
}
@ -853,12 +875,14 @@ void FrontendDelegateImpl::TriggerPageUpdate(int32_t pageId, bool directExecute)
}
};
auto weakContext = AceType::WeakClaim(AceType::RawPtr(pipelineContext));
taskExecutor_->PostTask([updateTask, weakContext, directExecute]() {
auto pipelineContext = weakContext.Upgrade();
if (pipelineContext) {
pipelineContext->AddPageUpdateTask(std::move(updateTask), directExecute);
}
}, TaskExecutor::TaskType::UI, "ArkUIAddPageUpdateTask");
taskExecutor_->PostTask(
[updateTask, weakContext, directExecute]() {
auto pipelineContext = weakContext.Upgrade();
if (pipelineContext) {
pipelineContext->AddPageUpdateTask(std::move(updateTask), directExecute);
}
},
TaskExecutor::TaskType::UI, "ArkUIAddPageUpdateTask");
}
void FrontendDelegateImpl::PostJsTask(std::function<void()>&& task, const std::string& name)
@ -932,9 +956,11 @@ void FrontendDelegateImpl::ShowToast(const std::string& message, int32_t duratio
auto pipelineContext = AceType::DynamicCast<PipelineContext>(pipelineContextHolder_.Get());
bool isRightToLeft = AceApplicationInfo::GetInstance().IsRightToLeft();
auto weak = AceType::WeakClaim(AceType::RawPtr(pipelineContext));
taskExecutor_->PostTask([durationTime, message, bottom, isRightToLeft, weak] {
ToastComponent::GetInstance().Show(weak.Upgrade(), message, durationTime, bottom, isRightToLeft);
}, TaskExecutor::TaskType::UI, "ArkUIShowToast");
taskExecutor_->PostTask(
[durationTime, message, bottom, isRightToLeft, weak] {
ToastComponent::GetInstance().Show(weak.Upgrade(), message, durationTime, bottom, isRightToLeft);
},
TaskExecutor::TaskType::UI, "ArkUIShowToast");
}
Rect FrontendDelegateImpl::GetBoundingRectData(NodeId nodeId)
@ -2025,12 +2051,14 @@ void FrontendDelegateImpl::LoadResourceConfiguration(std::map<std::string, std::
void FrontendDelegateImpl::PushJsCallbackToRenderNode(NodeId id, double ratio,
std::function<void(bool, double)>&& callback)
{
auto visibleCallback = [jsCallback = std::move(callback), executor = taskExecutor_] (bool visible, double ratio) {
executor->PostTask([task = std::move(jsCallback), visible, ratio] {
if (task) {
task(visible, ratio);
}
}, TaskExecutor::TaskType::JS, "ArkUIJsVisibleCallback");
auto visibleCallback = [jsCallback = std::move(callback), executor = taskExecutor_](bool visible, double ratio) {
executor->PostTask(
[task = std::move(jsCallback), visible, ratio] {
if (task) {
task(visible, ratio);
}
},
TaskExecutor::TaskType::JS, "ArkUIJsVisibleCallback");
};
auto uiPushTask = [id, ratio, visibleCallback,
pipeline = AceType::DynamicCast<PipelineContext>(pipelineContextHolder_.Get())]() {

View File

@ -628,11 +628,13 @@ void DragEventActuator::OnCollectTouchTarget(const OffsetF& coordinateOffset, co
auto customPixelMap = PixelMap::CreatePixelMap(reinterpret_cast<void*>(&pixelMap));
auto taskScheduler = pipeline->GetTaskExecutor();
CHECK_NULL_VOID(taskScheduler);
taskScheduler->PostTask([gestureHub, customPixelMap]() {
CHECK_NULL_VOID(gestureHub);
gestureHub->SetPixelMap(customPixelMap);
gestureHub->SetDragPreviewPixelMap(customPixelMap);
}, TaskExecutor::TaskType::UI, "ArkUIDragSetCustomPixelMap");
taskScheduler->PostTask(
[gestureHub, customPixelMap]() {
CHECK_NULL_VOID(gestureHub);
gestureHub->SetPixelMap(customPixelMap);
gestureHub->SetDragPreviewPixelMap(customPixelMap);
},
TaskExecutor::TaskType::UI, "ArkUIDragSetCustomPixelMap");
}
};

View File

@ -1098,9 +1098,8 @@ int32_t GestureEventHub::RegisterCoordinationListener(const RefPtr<PipelineBase>
CHECK_NULL_VOID(dragDropManager);
auto taskScheduler = context->GetTaskExecutor();
CHECK_NULL_VOID(taskScheduler);
taskScheduler->PostTask([dragDropManager]() {
dragDropManager->HideDragPreviewOverlay();
}, TaskExecutor::TaskType::UI, "ArkUIGestureHideDragPreviewOverlay");
taskScheduler->PostTask([dragDropManager]() { dragDropManager->HideDragPreviewOverlay(); },
TaskExecutor::TaskType::UI, "ArkUIGestureHideDragPreviewOverlay");
};
return InteractionInterface::GetInstance()->RegisterCoordinationListener(callback);
}

View File

@ -138,12 +138,14 @@ void PluginPattern::InitPluginManagerDelegate()
CHECK_NULL_VOID(host);
auto uiTaskExecutor =
SingleTaskExecutor::Make(host->GetContext()->GetTaskExecutor(), TaskExecutor::TaskType::UI);
uiTaskExecutor.PostTask([weak, instanceID] {
ContainerScope scope(instanceID);
auto plugin = weak.Upgrade();
CHECK_NULL_VOID(plugin);
plugin->FireOnCompleteEvent();
}, "ArkUIPluginCompleteEvent");
uiTaskExecutor.PostTask(
[weak, instanceID] {
ContainerScope scope(instanceID);
auto plugin = weak.Upgrade();
CHECK_NULL_VOID(plugin);
plugin->FireOnCompleteEvent();
},
"ArkUIPluginCompleteEvent");
});
pluginManagerBridge_->AddPluginUpdateCallback([weak = WeakClaim(this), instanceID](int64_t id, std::string data) {
ContainerScope scope(instanceID);
@ -153,11 +155,13 @@ void PluginPattern::InitPluginManagerDelegate()
CHECK_NULL_VOID(host);
auto uiTaskExecutor =
SingleTaskExecutor::Make(host->GetContext()->GetTaskExecutor(), TaskExecutor::TaskType::UI);
uiTaskExecutor.PostTask([id, data, weak] {
auto plugin = weak.Upgrade();
CHECK_NULL_VOID(plugin);
plugin->GetPluginSubContainer()->UpdatePlugin(data);
}, "ArkUIPluginUpdate");
uiTaskExecutor.PostTask(
[id, data, weak] {
auto plugin = weak.Upgrade();
CHECK_NULL_VOID(plugin);
plugin->GetPluginSubContainer()->UpdatePlugin(data);
},
"ArkUIPluginUpdate");
});
pluginManagerBridge_->AddPluginErrorCallback(
[weak = WeakClaim(this), instanceID](std::string code, std::string msg) {
@ -168,12 +172,14 @@ void PluginPattern::InitPluginManagerDelegate()
CHECK_NULL_VOID(host);
auto uiTaskExecutor =
SingleTaskExecutor::Make(host->GetContext()->GetTaskExecutor(), TaskExecutor::TaskType::UI);
uiTaskExecutor.PostTask([code, msg, weak, instanceID] {
ContainerScope scope(instanceID);
auto plugin = weak.Upgrade();
CHECK_NULL_VOID(plugin);
plugin->FireOnErrorEvent(code, msg);
}, "ArkUIPluginErrorEvent");
uiTaskExecutor.PostTask(
[code, msg, weak, instanceID] {
ContainerScope scope(instanceID);
auto plugin = weak.Upgrade();
CHECK_NULL_VOID(plugin);
plugin->FireOnErrorEvent(code, msg);
},
"ArkUIPluginErrorEvent");
});
}
@ -216,32 +222,34 @@ void PluginPattern::CreatePluginSubContainer()
auto uiTaskExecutor = SingleTaskExecutor::Make(host_->GetContext()->GetTaskExecutor(), TaskExecutor::TaskType::UI);
int32_t instanceID = context->GetInstanceId();
uiTaskExecutor.PostTask([weak, instanceID] {
ContainerScope scope(instanceID);
auto pluginPattern = weak.Upgrade();
CHECK_NULL_VOID(pluginPattern);
auto pluginSubContainer = pluginPattern->GetPluginSubContainer();
RequestPluginInfo info = pluginPattern->GetPluginRequestInfo();
CHECK_NULL_VOID(pluginSubContainer);
auto packagePathStr = pluginPattern->GetPackagePath(weak, info);
if (packagePathStr.empty()) {
pluginPattern->FireOnErrorEvent("1", "package path is empty.");
return;
}
if (!info.bundleName.empty() && !info.moduleName.empty()) {
pluginPattern->pluginSubContainer_->SetPluginBundleName(info.bundleName);
pluginPattern->pluginSubContainer_->SetPluginModuleName(info.moduleName);
}
if (packagePathStr.rfind(".hap") != std::string::npos) {
std::string sub = packagePathStr.substr(1, packagePathStr.size() - 5) + "/";
pluginPattern->ReplaceAll(info.source, sub, "");
pluginPattern->pluginSubContainer_->RunDecompressedPlugin(
packagePathStr, info.abilityName, info.source, info.moduleResPath, pluginPattern->GetData());
} else {
pluginPattern->pluginSubContainer_->RunPlugin(
packagePathStr, info.abilityName, info.source, info.moduleResPath, pluginPattern->GetData());
}
}, "ArkUIPluginRun");
uiTaskExecutor.PostTask(
[weak, instanceID] {
ContainerScope scope(instanceID);
auto pluginPattern = weak.Upgrade();
CHECK_NULL_VOID(pluginPattern);
auto pluginSubContainer = pluginPattern->GetPluginSubContainer();
RequestPluginInfo info = pluginPattern->GetPluginRequestInfo();
CHECK_NULL_VOID(pluginSubContainer);
auto packagePathStr = pluginPattern->GetPackagePath(weak, info);
if (packagePathStr.empty()) {
pluginPattern->FireOnErrorEvent("1", "package path is empty.");
return;
}
if (!info.bundleName.empty() && !info.moduleName.empty()) {
pluginPattern->pluginSubContainer_->SetPluginBundleName(info.bundleName);
pluginPattern->pluginSubContainer_->SetPluginModuleName(info.moduleName);
}
if (packagePathStr.rfind(".hap") != std::string::npos) {
std::string sub = packagePathStr.substr(1, packagePathStr.size() - 5) + "/";
pluginPattern->ReplaceAll(info.source, sub, "");
pluginPattern->pluginSubContainer_->RunDecompressedPlugin(
packagePathStr, info.abilityName, info.source, info.moduleResPath, pluginPattern->GetData());
} else {
pluginPattern->pluginSubContainer_->RunPlugin(
packagePathStr, info.abilityName, info.source, info.moduleResPath, pluginPattern->GetData());
}
},
"ArkUIPluginRun");
}
void PluginPattern::ReplaceAll(std::string& str, const std::string& pattern, const std::string& newPattern)

View File

@ -526,27 +526,31 @@ void SecurityComponentPattern::RegisterSecurityComponent()
CHECK_NULL_VOID(taskExecutor);
auto pipeline = PipelineContext::GetCurrentContext();
CHECK_NULL_VOID(pipeline);
taskExecutor->PostTask([weak = WeakClaim(this), weakContext = WeakPtr(pipeline)] {
if (!SecurityComponentHandler::LoadSecurityComponentService()) {
LOGW("load security component service failed.");
return;
}
auto context = weakContext.Upgrade();
CHECK_NULL_VOID(context);
auto taskExecutor = context->GetTaskExecutor();
CHECK_NULL_VOID(taskExecutor);
taskExecutor->PostTask([weak, instanceID = context->GetInstanceId()] {
ContainerScope scope(instanceID);
auto pattern = weak.Upgrade();
CHECK_NULL_VOID(pattern);
if (pattern->regStatus_ != SecurityComponentRegisterStatus::REGISTERING) {
LOGI("Register security component ASync droped.");
taskExecutor->PostTask(
[weak = WeakClaim(this), weakContext = WeakPtr(pipeline)] {
if (!SecurityComponentHandler::LoadSecurityComponentService()) {
LOGW("load security component service failed.");
return;
}
auto context = weakContext.Upgrade();
CHECK_NULL_VOID(context);
auto taskExecutor = context->GetTaskExecutor();
CHECK_NULL_VOID(taskExecutor);
taskExecutor->PostTask(
[weak, instanceID = context->GetInstanceId()] {
ContainerScope scope(instanceID);
auto pattern = weak.Upgrade();
CHECK_NULL_VOID(pattern);
if (pattern->regStatus_ != SecurityComponentRegisterStatus::REGISTERING) {
LOGI("Register security component ASync droped.");
return;
}
pattern->RegisterSecurityComponentRetry();
}, TaskExecutor::TaskType::UI, "ArkUISecurityComponentRegisterRetry");
}, TaskExecutor::TaskType::BACKGROUND, "ArkUISecurityComponentRegister");
pattern->RegisterSecurityComponentRetry();
},
TaskExecutor::TaskType::UI, "ArkUISecurityComponentRegisterRetry");
},
TaskExecutor::TaskType::BACKGROUND, "ArkUISecurityComponentRegister");
}
void SecurityComponentPattern::UnregisterSecurityComponent()
@ -606,12 +610,14 @@ int32_t SecurityComponentPattern::ReportSecurityComponentClickEvent(GestureEvent
CHECK_NULL_RETURN(context, -1);
auto taskExecutor = context->GetTaskExecutor();
CHECK_NULL_RETURN(taskExecutor, -1);
taskExecutor->PostTask([weak, instanceId = context->GetInstanceId(), result, nodeInner = node] {
ContainerScope scope(instanceId);
auto pattern = weak.Upgrade();
CHECK_NULL_VOID(pattern);
pattern->DoTriggerOnclick(result);
}, TaskExecutor::TaskType::UI, "ArkUISecurityComponentTriggerOnClick");
taskExecutor->PostTask(
[weak, instanceId = context->GetInstanceId(), result, nodeInner = node] {
ContainerScope scope(instanceId);
auto pattern = weak.Upgrade();
CHECK_NULL_VOID(pattern);
pattern->DoTriggerOnclick(result);
},
TaskExecutor::TaskType::UI, "ArkUISecurityComponentTriggerOnClick");
return 0;
};
}
@ -651,12 +657,14 @@ int32_t SecurityComponentPattern::ReportSecurityComponentClickEvent(const KeyEve
CHECK_NULL_RETURN(context, -1);
auto taskExecutor = context->GetTaskExecutor();
CHECK_NULL_RETURN(taskExecutor, -1);
taskExecutor->PostTask([weak, instanceId = context->GetInstanceId(), result, nodeInner = node] {
ContainerScope scope(instanceId);
auto pattern = weak.Upgrade();
CHECK_NULL_VOID(pattern);
pattern->DoTriggerOnclick(result);
}, TaskExecutor::TaskType::UI, "ArkUISecurityComponentTriggerOnClick");
taskExecutor->PostTask(
[weak, instanceId = context->GetInstanceId(), result, nodeInner = node] {
ContainerScope scope(instanceId);
auto pattern = weak.Upgrade();
CHECK_NULL_VOID(pattern);
pattern->DoTriggerOnclick(result);
},
TaskExecutor::TaskType::UI, "ArkUISecurityComponentTriggerOnClick");
return 0;
};
}

View File

@ -55,28 +55,30 @@ int32_t SecurityComponentProbe::GetComponentInfo(int32_t nodeId, std::string& co
return -1;
}
int taskRes;
taskExec_.value().PostSyncTask([nodeId, &compInfoStr, &taskRes] {
auto node = AceType::DynamicCast<FrameNode>(ElementRegister::GetInstance()->GetNodeById(nodeId));
if (!node) {
LOGW("node do not exist.");
taskRes = -1;
return;
}
taskExec_.value().PostSyncTask(
[nodeId, &compInfoStr, &taskRes] {
auto node = AceType::DynamicCast<FrameNode>(ElementRegister::GetInstance()->GetNodeById(nodeId));
if (!node) {
LOGW("node do not exist.");
taskRes = -1;
return;
}
if ((node->GetTag() != V2::LOCATION_BUTTON_ETS_TAG) && (node->GetTag() != V2::PASTE_BUTTON_ETS_TAG) &&
(node->GetTag() != V2::SAVE_BUTTON_ETS_TAG)) {
LOGW("node is not security component.");
taskRes = -1;
return;
}
Security::SecurityComponent::SecCompType scType;
if (!SecurityComponentHandler::InitButtonInfo(compInfoStr, node, scType)) {
LOGW("node init info failed.");
taskRes = -1;
return;
}
taskRes = 0;
}, "ArkUISecurityComponentInitButtonInfo");
if ((node->GetTag() != V2::LOCATION_BUTTON_ETS_TAG) && (node->GetTag() != V2::PASTE_BUTTON_ETS_TAG) &&
(node->GetTag() != V2::SAVE_BUTTON_ETS_TAG)) {
LOGW("node is not security component.");
taskRes = -1;
return;
}
Security::SecurityComponent::SecCompType scType;
if (!SecurityComponentHandler::InitButtonInfo(compInfoStr, node, scType)) {
LOGW("node init info failed.");
taskRes = -1;
return;
}
taskRes = 0;
},
"ArkUISecurityComponentInitButtonInfo");
tmux_.unlock();
return taskRes;
}