-
Notifications
You must be signed in to change notification settings - Fork 303
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
Conversation
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]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
KrakenPage 好像换成 KrakenView 更合适些,不是所有的 kraken 都是 page
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pageContextPool -> contextPool 好像足够表达清楚了
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2021
foundation::UICommandBuffer 曾经的实现会按照每个 contextId 创建一个单例,即不线程安全,也不太方便释放,也会导致没创建一个页面,都会泄漏一个 UICommandBuffer 对象。
Fix: 从生命周期的角度来看,UICommandBuffer 和 ExecutionContext 一样,所以应当让 ExecutionContext 持有 UICommandBuffer