mirror of
https://github.com/openharmony/ace_engine_lite.git
synced 2026-07-18 18:34:29 -04:00
IssueNo:I3EFNR
Description: avoid process TE in case not in active state Sig:ace_engine_lite Feature or Bugfix:Feature Binary Source:No
This commit is contained in:
@@ -58,14 +58,14 @@ public:
|
||||
*
|
||||
* @brief Call this function to active the application UI
|
||||
*/
|
||||
void Show() const;
|
||||
void Show();
|
||||
|
||||
/**
|
||||
* @fn JSAbility::Hide()
|
||||
*
|
||||
* @brief Call this function to move the current JS application to background
|
||||
*/
|
||||
void Hide() const;
|
||||
void Hide();
|
||||
|
||||
/**
|
||||
* @fn JSAbility::TransferToDestroy()
|
||||
@@ -95,6 +95,13 @@ public:
|
||||
*/
|
||||
void ForceDestroy();
|
||||
|
||||
/**
|
||||
* @fn JSAbility::IsRecycled()
|
||||
*
|
||||
* @brief Used for checking if the current ability is already teardown
|
||||
*/
|
||||
bool IsRecycled();
|
||||
|
||||
/**
|
||||
* @fn JSAbility::HandleRenderTick()
|
||||
*
|
||||
@@ -111,7 +118,8 @@ public:
|
||||
|
||||
private:
|
||||
// the holder of JS runtime and user' JS related environment
|
||||
void *jsAbilityImpl_;
|
||||
void *jsAbilityImpl_ = nullptr;
|
||||
bool isActived_ = false;
|
||||
}; // class JSAbility
|
||||
} // namespace ACELite
|
||||
} // namespace OHOS
|
||||
|
||||
@@ -88,7 +88,7 @@ void JSAbility::Launch(const char * const abilityPath, const char * const bundle
|
||||
OUTPUT_TRACE();
|
||||
}
|
||||
|
||||
void JSAbility::Show() const
|
||||
void JSAbility::Show()
|
||||
{
|
||||
if (jsAbilityImpl_ == nullptr) {
|
||||
HILOG_ERROR(HILOG_MODULE_ACE, "Must trigger Launch first");
|
||||
@@ -99,9 +99,10 @@ void JSAbility::Show() const
|
||||
jsAbilityImpl->Show();
|
||||
AsyncTaskManager::GetInstance().SetFront(true);
|
||||
ProductAdapter::UpdateShowingState(true);
|
||||
isActived_ = true;
|
||||
}
|
||||
|
||||
void JSAbility::Hide() const
|
||||
void JSAbility::Hide()
|
||||
{
|
||||
if (jsAbilityImpl_ == nullptr) {
|
||||
HILOG_ERROR(HILOG_MODULE_ACE, "Must trigger Launch first");
|
||||
@@ -111,6 +112,8 @@ void JSAbility::Hide() const
|
||||
JSAbilityImpl *jsAbilityImpl = CastAbilityImpl(jsAbilityImpl_);
|
||||
jsAbilityImpl->Hide();
|
||||
AsyncTaskManager::GetInstance().SetFront(false);
|
||||
ProductAdapter::UpdateShowingState(false);
|
||||
isActived_ = false;
|
||||
}
|
||||
|
||||
void JSAbility::TransferToDestroy()
|
||||
@@ -122,8 +125,6 @@ void JSAbility::TransferToDestroy()
|
||||
|
||||
JSAbilityImpl *jsAbilityImpl = CastAbilityImpl(jsAbilityImpl_);
|
||||
jsAbilityImpl->CleanUp();
|
||||
delete reinterpret_cast<JSAbilityImpl *>(jsAbilityImpl_);
|
||||
jsAbilityImpl_ = nullptr;
|
||||
// Reset render flag or low layer task mutex in case we are during the rendering process,
|
||||
// this situation might happen if the destroy function is called outside of JS thread, such as AMS.
|
||||
ProductAdapter::UpdateShowingState(false);
|
||||
@@ -133,6 +134,8 @@ void JSAbility::TransferToDestroy()
|
||||
JsAsyncWork::SetAppQueueHandler(nullptr);
|
||||
DftImpl::GetInstance()->RegisterPageReplaced(nullptr);
|
||||
#endif // OHOS_ACELITE_PRODUCT_WATCH
|
||||
delete reinterpret_cast<JSAbilityImpl *>(jsAbilityImpl_);
|
||||
jsAbilityImpl_ = nullptr;
|
||||
DumpNativeMemoryUsage();
|
||||
}
|
||||
|
||||
@@ -158,6 +161,11 @@ void JSAbility::ForceDestroy()
|
||||
HILOG_ERROR(HILOG_MODULE_ACE, "ForceDestroy interface is deprecated as JS engine can not run on other task");
|
||||
}
|
||||
|
||||
bool JSAbility::IsRecycled()
|
||||
{
|
||||
return (jsAbilityImpl_ == nullptr);
|
||||
}
|
||||
|
||||
LazyLoadManager *GetLazyLoadManager()
|
||||
{
|
||||
JsAppContext *context = JsAppContext::GetInstance();
|
||||
@@ -184,6 +192,13 @@ void JSAbility::LazyLoadHandleRenderTick(void *data)
|
||||
|
||||
void JSAbility::HandleRenderTick()
|
||||
{
|
||||
if (!isActived_) {
|
||||
// skip the TE tick if we are not forground
|
||||
ProductAdapter::NotifyRenderEnd();
|
||||
HILOG_WARN(HILOG_MODULE_ACE, "skip one render tick process since not actived");
|
||||
return;
|
||||
}
|
||||
|
||||
#if defined(TARGET_SIMULATOR) && defined(FEATURE_LAZY_LOADING_MODULE)
|
||||
LazyLoadHandleRenderTick(nullptr);
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user