Signed-off-by: zhongjianfei <zhongjianfei@huawei.com>
Change-Id: I0def4bfc7a2d7c0e3369a02b6c43077ff0db135f
This commit is contained in:
zhongjianfei 2021-09-16 21:10:31 +08:00
parent 21d9600da4
commit 19567aa233
8 changed files with 26 additions and 6 deletions

View File

@ -40,6 +40,15 @@ FlutterWindow::FlutterWindow(int32_t instanceId) : instanceId_(instanceId) {}
FlutterWindow::~FlutterWindow() {}
void FlutterWindow::Destroy()
{
auto window = flutter::WindowManager::GetWindow(instanceId_);
if (window != nullptr) {
window->SetBeginFrameCallback(nullptr);
}
vsyncCallbacks_.clear();
}
void FlutterWindow::RequestFrame()
{
auto window = flutter::WindowManager::GetWindow(instanceId_);

View File

@ -28,6 +28,8 @@ public:
explicit FlutterWindow(int32_t instanceId);
~FlutterWindow() override;
void Destroy() override;
// Platform window interface
void RequestFrame() override;
void RegisterVsyncCallback(AceVsyncCallback&& callback) override;

View File

@ -61,7 +61,9 @@ void FlutterWindow::SetRootRenderNode(const RefPtr<RenderNode>& root) {}
void FlutterWindow::OnVsyncCallback(uint64_t timeStampNanos)
{
for (const auto& vsyncCallback : vsyncCallbacks_) {
vsyncCallback(timeStampNanos, 0);
if (vsyncCallback) {
vsyncCallback(timeStampNanos, 0);
}
}
}

View File

@ -37,7 +37,9 @@ QJSDeclarativeEngine::~QJSDeclarativeEngine()
delete nativeEngine_;
}
#endif
JS_RunGC(engineInstance_->GetQJSRuntime());
if (engineInstance_ && engineInstance_->GetQJSRuntime()) {
JS_RunGC(engineInstance_->GetQJSRuntime());
}
}
bool QJSDeclarativeEngine::Initialize(const RefPtr<FrontendDelegate>& delegate)

View File

@ -3062,8 +3062,9 @@ QjsEngine::~QjsEngine()
nativeEngine_->CancelCheckUVLoop();
delete nativeEngine_;
}
ACE_DCHECK(engineInstance_);
JS_RunGC(engineInstance_->GetQjsRuntime());
if (engineInstance_ && engineInstance_->GetQjsRuntime()) {
JS_RunGC(engineInstance_->GetQjsRuntime());
}
}
void QjsEngine::GetLoadOptions(std::string& optionStr, bool isMainPage, const RefPtr<JsAcePage>& page)

View File

@ -405,8 +405,9 @@ QjsPaEngine::~QjsPaEngine()
if (nativeEngine_ != nullptr) {
delete nativeEngine_;
}
ACE_DCHECK(engineInstance_);
JS_RunGC(engineInstance_->GetQjsRuntime());
if (engineInstance_ && engineInstance_->GetQjsRuntime()) {
JS_RunGC(engineInstance_->GetQjsRuntime());
}
}
inline int32_t GetJsInt32Val(JSContext* ctx, JSValueConst value)

View File

@ -36,6 +36,8 @@ public:
static std::unique_ptr<PlatformWindow> Create(AceView* aceView);
virtual void Destroy() {};
// Request next vsync.
virtual void RequestFrame() = 0;

View File

@ -34,6 +34,7 @@ public:
void Destroy()
{
platformWindow_->Destroy();
platformWindow_.reset();
}