回退 'Pull Request !17343 : 增加同步超时兜底'

This commit is contained in:
oh_ci 2024-11-22 07:05:15 +00:00 committed by Gitee
parent 2a52b4a38b
commit b6338fe77d
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
7 changed files with 13 additions and 61 deletions

View File

@ -1330,7 +1330,7 @@ void RSMainThread::ProcessSyncTransactionCount(std::unique_ptr<RSTransactionData
subSyncTransactionCounts_.erase(parentPid);
}
}
ROSEN_LOGI("RSMainThread::ProcessSyncTransactionCount isNeedCloseSync:%{public}d syncId:%{public}" PRIu64 ""
ROSEN_LOGD("RSMainThread::ProcessSyncTransactionCount isNeedCloseSync:%{public}d syncId:%{public}" PRIu64 ""
" parentPid:%{public}d syncNum:%{public}d subSyncTransactionCounts_.size:%{public}zd",
rsTransactionData->IsNeedCloseSync(), rsTransactionData->GetSyncId(), parentPid,
rsTransactionData->GetSyncTransactionNum(), subSyncTransactionCounts_.size());
@ -1364,7 +1364,7 @@ void RSMainThread::ProcessSyncRSTransactionData(std::unique_ptr<RSTransactionDat
ProcessSyncTransactionCount(rsTransactionData);
syncTransactionData_[pid].emplace_back(std::move(rsTransactionData));
if (subSyncTransactionCounts_.empty()) {
ROSEN_LOGI("SyncTransaction success");
ROSEN_LOGD("SyncTransaction sucess");
ProcessAllSyncTransactionData();
}
}

View File

@ -18,7 +18,6 @@
#include <memory>
#include <mutex>
#include <queue>
#include <stack>
#include "command/rs_command.h"
@ -73,8 +72,6 @@ public:
bool IsEmpty() const;
void StartCloseSyncTransactionFallbackTask(std::shared_ptr<AppExecFwk::EventHandler> handler, bool isOpen);
private:
RSTransactionProxy();
virtual ~RSTransactionProxy();
@ -110,7 +107,6 @@ private:
uint64_t syncId_ { 0 };
FlushEmptyCallback flushEmptyCallback_ = nullptr;
uint32_t transactionDataIndex_ = 0;
std::queue<std::string> taskNames_ {};
};
} // namespace Rosen
} // namespace OHOS

View File

@ -17,7 +17,6 @@
#include <stdlib.h>
#include "platform/common/rs_log.h"
#include "rs_trace.h"
namespace OHOS {
namespace Rosen {
@ -194,42 +193,6 @@ void RSTransactionProxy::CloseSyncTransaction()
needSync_ = false;
}
void RSTransactionProxy::StartCloseSyncTransactionFallbackTask(
std::shared_ptr<AppExecFwk::EventHandler> handler, bool isOpen)
{
std::unique_lock<std::mutex> cmdLock(mutex_);
static uint32_t num = 0;
const std::string name = "CloseSyncTransactionFallbackTask";
const int timeOutDelay = 5000;
if (!handler) {
ROSEN_LOGD("StartCloseSyncTransactionFallbackTask handler is null");
return;
}
if (isOpen) {
num++;
auto taskName = name + std::to_string(num);
taskNames_.push(taskName);
auto task = [this]() {
RS_TRACE_NAME("CloseSyncTransaction timeout");
ROSEN_LOGE("CloseSyncTransaction timeout");
auto transactionProxy = RSTransactionProxy::GetInstance();
if (transactionProxy != nullptr) {
transactionProxy->CommitSyncTransaction();
transactionProxy->CloseSyncTransaction();
}
if (!taskNames_.empty()) {
taskNames_.pop();
}
};
handler->PostTask(task, taskName, timeOutDelay);
} else {
if (!taskNames_.empty()) {
handler->RemoveTask(taskNames_.front());
taskNames_.pop();
}
}
}
void RSTransactionProxy::Begin()
{
std::unique_lock<std::mutex> cmdLock(mutex_);

View File

@ -54,7 +54,7 @@ std::shared_ptr<RSTransaction> RSSyncTransactionController::GetRSTransaction()
return rsTransaction_;
}
void RSSyncTransactionController::OpenSyncTransaction(std::shared_ptr<AppExecFwk::EventHandler> handler)
void RSSyncTransactionController::OpenSyncTransaction()
{
if (!RSSystemProperties::GetSyncTransactionEnabled()) {
return;
@ -69,11 +69,11 @@ void RSSyncTransactionController::OpenSyncTransaction(std::shared_ptr<AppExecFwk
}
ROSEN_LOGD("RS sync transaction controller OpenSyncTransaction");
if (rsTransaction_) {
rsTransaction_->OpenSyncTransaction(handler);
rsTransaction_->OpenSyncTransaction();
}
}
void RSSyncTransactionController::CloseSyncTransaction(std::shared_ptr<AppExecFwk::EventHandler> handler)
void RSSyncTransactionController::CloseSyncTransaction()
{
if (!needCloseSync_) {
return;
@ -81,7 +81,7 @@ void RSSyncTransactionController::CloseSyncTransaction(std::shared_ptr<AppExecFw
ROSEN_LOGD("RS sync transaction controller CloseSyncTransaction");
if (rsTransaction_) {
rsTransaction_->CloseSyncTransaction(handler);
rsTransaction_->CloseSyncTransaction();
}
{
std::unique_lock<std::mutex> lock(mutex_);

View File

@ -30,8 +30,8 @@ class RSC_EXPORT RSSyncTransactionController {
public:
static RSSyncTransactionController* GetInstance();
void OpenSyncTransaction(std::shared_ptr<AppExecFwk::EventHandler> handler = nullptr);
void CloseSyncTransaction(std::shared_ptr<AppExecFwk::EventHandler> handler = nullptr);
void OpenSyncTransaction();
void CloseSyncTransaction();
std::shared_ptr<RSTransaction> GetRSTransaction();

View File

@ -31,36 +31,33 @@ void RSTransaction::FlushImplicitTransaction()
}
}
void RSTransaction::OpenSyncTransaction(std::shared_ptr<AppExecFwk::EventHandler> handler)
void RSTransaction::OpenSyncTransaction()
{
syncId_ = GenerateSyncId();
auto transactionProxy = RSTransactionProxy::GetInstance();
if (transactionProxy != nullptr) {
RS_TRACE_NAME("OpenSyncTransaction");
ROSEN_LOGI("OpenSyncTransaction");
transactionProxy->FlushImplicitTransaction();
transactionProxy->StartSyncTransaction();
transactionProxy->Begin();
isOpenSyncTransaction_ = true;
transactionCount_ = 0;
parentPid_ = GetRealPid();
transactionProxy->StartCloseSyncTransactionFallbackTask(handler, true);
}
}
void RSTransaction::CloseSyncTransaction(std::shared_ptr<AppExecFwk::EventHandler> handler)
void RSTransaction::CloseSyncTransaction()
{
auto transactionProxy = RSTransactionProxy::GetInstance();
if (transactionProxy != nullptr) {
RS_TRACE_NAME_FMT("CloseSyncTransaction syncId: %lu syncCount: %d", syncId_, transactionCount_);
ROSEN_LOGI(
ROSEN_LOGD(
"CloseSyncTransaction syncId: %{public}" PRIu64 " syncCount: %{public}d", syncId_, transactionCount_);
isOpenSyncTransaction_ = false;
transactionProxy->MarkTransactionNeedCloseSync(transactionCount_);
transactionProxy->SetSyncId(syncId_);
transactionProxy->CommitSyncTransaction();
transactionProxy->CloseSyncTransaction();
transactionProxy->StartCloseSyncTransactionFallbackTask(handler, false);
}
ResetSyncTransactionInfo();
}
@ -70,7 +67,6 @@ void RSTransaction::Begin()
auto transactionProxy = RSTransactionProxy::GetInstance();
if (transactionProxy != nullptr) {
RS_TRACE_NAME("BeginSyncTransaction");
ROSEN_LOGI("BeginSyncTransaction");
transactionProxy->StartSyncTransaction();
transactionProxy->Begin();
}
@ -82,8 +78,6 @@ void RSTransaction::Commit()
if (transactionProxy != nullptr) {
RS_TRACE_NAME_FMT(
"CommitSyncTransaction syncId: %lu syncCount: %d parentPid: %d", syncId_, transactionCount_, parentPid_);
ROSEN_LOGI("CloseSyncTransaction syncId: %{public}" PRIu64 " syncCount: %{public}d parentPid: %{public}d",
syncId_, transactionCount_, parentPid_);
transactionProxy->SetSyncTransactionNum(transactionCount_);
transactionProxy->SetSyncId(syncId_);
transactionProxy->SetParentPid(parentPid_);

View File

@ -16,7 +16,6 @@
#ifndef RENDER_SERVICE_CLIENT_CORE_UI_RS_TRANSACTION_H
#define RENDER_SERVICE_CLIENT_CORE_UI_RS_TRANSACTION_H
#include <event_handler.h>
#include <message_parcel.h>
#include <mutex>
#include <parcel.h>
@ -41,8 +40,8 @@ public:
bool Marshalling(Parcel& parcel) const override;
static void FlushImplicitTransaction();
void OpenSyncTransaction(std::shared_ptr<AppExecFwk::EventHandler> handler = nullptr);
void CloseSyncTransaction(std::shared_ptr<AppExecFwk::EventHandler> handler = nullptr);
void OpenSyncTransaction();
void CloseSyncTransaction();
void Begin();
void Commit();