!366 Bugfix for rs_client crash when exiting.

Merge pull request !366 from xxfeng_hw/master
This commit is contained in:
openharmony_ci 2022-02-09 03:46:57 +00:00 committed by Gitee
commit f7d0739ccf
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
3 changed files with 23 additions and 13 deletions

View File

@ -20,7 +20,6 @@
namespace OHOS {
namespace Rosen {
RSNodeMap::RSNodeMap()
{
// add animation fallback node
@ -29,10 +28,17 @@ RSNodeMap::RSNodeMap()
nodeMap_.emplace(0, fallback_node);
}
RSNodeMap::~RSNodeMap() noexcept
{
for (auto &[id, node] : nodeMap_) {
node = nullptr;
}
}
RSNodeMap& RSNodeMap::MutableInstance()
{
static RSNodeMap renderThread;
return renderThread;
static RSNodeMap nodeMap;
return nodeMap;
}
const RSNodeMap& RSNodeMap::Instance()

View File

@ -46,7 +46,7 @@ public:
private:
explicit RSNodeMap();
~RSNodeMap() = default;
~RSNodeMap() noexcept;
RSNodeMap(const RSNodeMap&) = delete;
RSNodeMap(const RSNodeMap&&) = delete;
RSNodeMap& operator=(const RSNodeMap&) = delete;

View File

@ -58,9 +58,7 @@ RSRenderThread::RSRenderThread()
ROSEN_TRACE_BEGIN(BYTRACE_TAG_GRAPHIC_AGP, "RSRenderThread::DrawFrame");
{
prevTimestamp_ = timestamp_;
if (!cmds_.empty()) {
ProcessCommands();
}
ProcessCommands();
}
ROSEN_LOGD("RSRenderThread DrawFrame(%llu) in %s", prevTimestamp_, renderContext_ ? "GPU" : "CPU");
@ -85,6 +83,8 @@ RSRenderThread::RSRenderThread()
RSRenderThread::~RSRenderThread()
{
Stop();
if (renderContext_ != nullptr) {
ROSEN_LOGD("Destory renderContext!!");
delete renderContext_;
@ -222,13 +222,17 @@ void RSRenderThread::StopTimer()
void RSRenderThread::ProcessCommands()
{
ROSEN_LOGD("RSRenderThread ProcessCommands size: %lu\n", cmds_.size());
ROSEN_TRACE_BEGIN(BYTRACE_TAG_GRAPHIC_AGP, "ProcessCommands");
std::vector<std::unique_ptr<RSTransactionData>> cmds;
{
std::unique_lock<std::mutex> cmdLock(cmdMutex_);
std::swap(cmds, cmds_);
std::unique_lock<std::mutex> cmdLock(cmdMutex_);
if (cmds_.empty()) {
return;
}
ROSEN_LOGD("RSRenderThread ProcessCommands size: %lu\n", cmds_.size());
std::vector<std::unique_ptr<RSTransactionData>> cmds;
std::swap(cmds, cmds_);
cmdLock.unlock();
ROSEN_TRACE_BEGIN(BYTRACE_TAG_GRAPHIC_AGP, "ProcessCommands");
for (auto& cmdData : cmds) {
cmdData->Process(context_);
}