提交 1948fef8 编写于 作者: C Carlo Bernaschina 提交者: GitHub

Avoid race condition into NotifyNextFrameOnce (#3980)

If GPURasterizer::NotifyNextFrameOnce was rapidly invoked twice could
have lead to a null pointer exception.

Also ftp::WeakPtr are not thread safe and should not be dereferenced
from other threads.
上级 841cd667
......@@ -148,14 +148,11 @@ void GPURasterizer::AddNextFrameCallback(ftl::Closure nextFrameCallback) {
void GPURasterizer::NotifyNextFrameOnce() {
if (nextFrameCallback_) {
blink::Threads::Platform()->PostTask([weak_this = weak_factory_.GetWeakPtr()] {
blink::Threads::Platform()->PostTask([callback = nextFrameCallback_] {
TRACE_EVENT0("flutter", "GPURasterizer::NotifyNextFrameOnce");
if (weak_this) {
ftl::Closure callback = weak_this->nextFrameCallback_;
callback();
weak_this->nextFrameCallback_ = nullptr;
}
callback();
});
nextFrameCallback_ = nullptr;
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册