Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix ui command buffer instance leak. #1014

Merged
merged 5 commits into from
Dec 31, 2021

Conversation

andycall
Copy link
Member

@andycall andycall commented Dec 23, 2021

foundation::UICommandBuffer 曾经的实现会按照每个 contextId 创建一个单例,即不线程安全,也不太方便释放,也会导致没创建一个页面,都会泄漏一个 UICommandBuffer 对象。

Fix: 从生命周期的角度来看,UICommandBuffer 和 ExecutionContext 一样,所以应当让 ExecutionContext 持有 UICommandBuffer

@andycall andycall requested a review from wssgcg1213 December 23, 2021 12:59
@wssgcg1213
Copy link
Member

CI Failed @andycall

@@ -91,7 +91,6 @@ void initJSPagePool(int poolSize) {
// When dart hot restarted, should dispose previous bridge and clear task message queue.
if (inited) {
disposeAllPages();
foundation::UICommandBuffer::instance(0)->clear();
};
pageContextPool = new kraken::KrakenPage*[poolSize];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

KrakenPage 好像换成 KrakenView 更合适些,不是所有的 kraken 都是 page

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// A Page roughly corresponds to a tab or popup window in a browser. It owns a
// tree of frames (a blink::FrameTree). The root frame is called the main frame.

Page 借鉴了 blink 里面的概念,等价于一个标签页。后面实现多个 kraken 嵌套的功能的时候,可以再里面扩展出 frames 就可以了。一个 Kraken 就等于一个 page,至少现在的设计就是这样。

// UnitTest will free page after test suit complete.

// In order to avoid accessing pageContextPool when the page is being released. We need to clear the value in pageContextPool before releasing.
pageContextPool[contextId] = nullptr;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pageContextPool -> contextPool 好像足够表达清楚了

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pageContextPool 里面都是持有 page,这样命名没问题,如果使用 contextPool,很难理解里面是个啥,是 page,还是 executionContext,还是 jscontext

@@ -0,0 +1,33 @@
/*
* Copyright (C) 2020 Alibaba Inc. All rights reserved.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2021

@answershuto answershuto merged commit 44dafbb into main Dec 31, 2021
@answershuto answershuto deleted the fix/ui_command_buffer_instance_leak branch December 31, 2021 04:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants