[WRTjs][VD] Early loading of hosted app 39/290939/11
authorDongHyun Song <dh81.song@samsung.com>
Wed, 5 Apr 2023 08:48:08 +0000 (17:48 +0900)
committerBot Blink <blinkbot@samsung.com>
Tue, 25 Apr 2023 06:26:03 +0000 (06:26 +0000)
If hosted app is started with default launch, we don't need to
load URL until app-control event. Default src of config.xml can be
opened early when NativeRuntime creation time.

This logic is working for TV profile by below chromium-efl patch,
also, is not working inspector mode or deeplink case.

Related wrtjs patch:
https://review.tizen.org/gerrit/290937/

Change-Id: I017805c544a4980bbd97317a7e73568451db4369
Signed-off-by: DongHyun Song <dh81.song@samsung.com>
wrt/src/app/tv/wrt_main_delegate_tv.cc
wrt/src/app/tv/wrt_main_delegate_tv.h
wrt/src/app/wrt_content_main.cc
wrt/src/app/wrt_main_delegate.h
wrt/src/browser/api/tv/wrt_api_tv_extension.cc
wrt/src/browser/tv/native_web_runtime_delegate_tv.cc
wrt/src/browser/tv/native_web_runtime_delegate_tv.h

index d182b241b55e93a26508e48fd6d6ff5a006668e5..b9641c08cbd7894b11c63f941a4f2d16b48f5890 100644 (file)
@@ -65,7 +65,6 @@ class ZoneFramework {
 };
 
 const char* kEflWebProcess = "/usr/bin/efl_webprocess";
-const char* kLoaderMode = "-lite";
 const char* kZoneLibPath = LIB_PATH "/libzone.so.5";
 
 std::mutex prelaunch_mutex;
@@ -142,9 +141,18 @@ void InitializeBeforeRealLaunch() {
   native_runtime_tv.SetLocaleDir();
 }
 
+void CheckArguments(int argc, char** argv) {
+  for (int i = 1; i < argc; ++i) {
+    if (!strcmp(argv[i], "PayLoad") || !strcmp(argv[i], "PAYLOAD")) {
+      NativeWebRuntimeDelegateTV::GetInstance().SetPayloadData();
+      break;
+    }
+  }
+}
+
 }  // namespace
 
-WRTMainDelegateTV::WRTMainDelegateTV() : lazy_initialize_(false) {
+WRTMainDelegateTV::WRTMainDelegateTV() {
   SetExecutablePath(kEflWebProcess);
   SetNoZygote(false);
 }
@@ -155,19 +163,10 @@ bool WRTMainDelegateTV::BasicStartupComplete(int* exit_code) {
 }
 
 bool WRTMainDelegateTV::CheckPlatformReady(int argc, char** argv) {
-  for (int i = 1; i < argc; ++i) {
-    if (strcmp(argv[i], kLoaderMode) == 0) {
-      lazy_initialize_ = true;
-      break;
-    }
-  }
+  CheckArguments(argc, argv);
   return CheckWindowManagerReady();
 }
 
-bool WRTMainDelegateTV::SupportLazyInitialize() {
-  return lazy_initialize_;
-}
-
 // static
 void WRTMainDelegateTV::GroupZygoteProcess(bool is_oom) {
 #if defined(ENABLE_PROCESS_GROUP)
@@ -296,9 +295,10 @@ void WRTMainDelegateTV::LoaderCreated() {
   }
 }
 
-void WRTMainDelegateTV::LoaderTerminated() {
+void WRTMainDelegateTV::LoaderTerminated(int argc, char** argv) {
   reallaunch_mutex.unlock();
   monitoring_timer.Stop();
+  CheckArguments(argc, argv);
 }
 
 void WRTMainDelegateTV::PrelaunchOnLoader(const std::string& pkg_id) {
index be854e36fda0a8bfdb2815ec1c1b98a14b7dc18f..ddcd766c49a486c45ddeaae2b9784823bcd486e2 100644 (file)
@@ -20,19 +20,16 @@ class WRTMainDelegateTV : public WRTMainDelegate {
   bool BasicStartupComplete(int* exit_code) override;
   bool CheckPlatformReady(int argc, char** argv) override;
   void LoaderCreated() override;
-  void LoaderTerminated() override;
+  void LoaderTerminated(int argc, char** argv) override;
   void PrelaunchOnLoader(const std::string& pkg_id) override;
   bool PreSetup() override;
   void PostEarlyInitialization(bool is_running_tests) override;
-  bool SupportLazyInitialize() override;
 
   void CreateWorkers();
   void CheckCPUUsage();
 
   content::ContentBrowserClient* CreateContentBrowserClient() override;
   content::ContentRendererClient* CreateContentRendererClient() override;
-
-  bool lazy_initialize_;
 };
 
 }  // namespace wrt
index 3b8b9d66b133b0f4e2782ef4225a8fa4fe11811e..b8657575583df39c8fcd4c0e6ef19e626e56cbea 100644 (file)
@@ -59,10 +59,8 @@ class WRTContentMain::Loader {
           [](void* data) {
             LOG(INFO) << "ContentMain will be initialized in idler.";
             auto* content_main = static_cast<WRTContentMain*>(data);
-            if (!content_main->main_delegate_->SupportLazyInitialize()) {
-              content_main->Initialize();
-              content_main->main_delegate_->LoaderCreated();
-            }
+            content_main->Initialize();
+            content_main->main_delegate_->LoaderCreated();
             return ECORE_CALLBACK_CANCEL;
           }, static_cast<Loader*>(user_data)->content_main_);
     };
@@ -89,12 +87,10 @@ class WRTContentMain::Loader {
     callback.terminate = [](int argc, char** argv, void* user_data) {
       LOG(INFO) << "loader terminated";
       auto* content_main = static_cast<Loader*>(user_data)->content_main_;
-      if (content_main->main_delegate_->SupportLazyInitialize())
-        content_main->Initialize();
-
-      content_main->main_delegate_->LoaderTerminated();
+      content_main->main_delegate_->LoaderTerminated(argc, argv);
       for (int i = 0; i < argc; ++i)
         LOG(INFO) << "argv[" << i << "] : " << argv[i];
+
       base::CommandLine::ForCurrentProcess()->SetProgram(
           base::FilePath(argv[0]));
       electron::ElectronCommandLine::InitializeFromCommandLine();
index e13821a0d5b7492ae74bb0d8ce43eec4dd86c7da..d7a26bc605e722874c474d7df03da01a616d8d05 100644 (file)
@@ -18,9 +18,8 @@ class WRTMainDelegate : public electron::ElectronMainDelegate {
 
   // product specific functions
   virtual bool CheckPlatformReady(int argc, char** argv) { return true; }
-  virtual bool SupportLazyInitialize() { return false; }
   virtual void LoaderCreated() {}
-  virtual void LoaderTerminated() {}
+  virtual void LoaderTerminated(int argc, char** argv) {}
   virtual void PrelaunchOnLoader(const std::string& pkg_id) {}
   virtual bool PreSetup();
 
index 4d105f769a9628dcdf0cb124a7757ff6209f7b04..4cfae6f567e1b53f8b81a6fe5e3b5f407f266df2 100644 (file)
@@ -17,7 +17,6 @@
 #include "electron/shell/common/gin_converters/content_converter.h"
 #include "gin/object_template_builder.h"
 #include "tizen_src/chromium_impl/tizen/vconf_handle.h"
-#include "tizen_src/ewk/efl_integration/devtools_port_manager.h"
 #include "v8/include/v8.h"
 #include "wrt/src/base/platform_info.h"
 #include "wrt/src/browser/native_web_runtime.h"
@@ -138,8 +137,8 @@ TVExtension::TVExtension() {}
 TVExtension::~TVExtension() {}
 
 bool TVExtension::NeedUseInspector() const {
-  return devtools_http_handler::DevToolsPortManager::GetInstance()
-      ->ProcessCompare();
+  auto inspected_appid = VconfHandle("db/rwi/inspected_appid").Str();
+  return inspected_appid == ApplicationData::GetInstance().app_id();
 }
 
 bool TVExtension::IsAlwaysReload() const {
index a9d4dc555eb9fc5501e8328aef730b360203d53f..85eafc8e5d3b0836f6ba2285ddca4deac5a300f0 100644 (file)
@@ -269,15 +269,29 @@ NativeWebRuntimeDelegateTV::NativeWebRuntimeDelegateTV() {
 void NativeWebRuntimeDelegateTV::Initialize(void* data) {
   if (GetProductType() == "IWB")
     WRTNativeWindowTV::SetWindowBorderAlpha();
-  ApplicationData::GetInstance().Initialize();
-  app_id_ = ApplicationData::GetInstance().app_id();
+  auto& app_data = ApplicationData::GetInstance();
+  app_data.Initialize();
+  app_id_ = app_data.app_id();
   auto extension_manager = XWalkExtensionManager::GetInstance();
   extension_manager->ParseUpgradableExtensions();
   extension_manager->RegisterUpgradableExtensions();
   initialized_ = true;
 }
 
+void NativeWebRuntimeDelegateTV::EarlyLoadUrlIfHostedApp() {
+  auto& app_data = ApplicationData::GetInstance();
+  if (!app_data.IsHostedApp() || has_payload_data_)
+    return;
+
+  auto start_url = app_data.content_info().src();
+  LOG(INFO) << "start_url : " << start_url;
+  SetDiskCache(true);
+  std::vector<std::string> params = {start_url};
+  NativeWebRuntime::GetInstance().NotifyMessage("loadHostedApp", params);
+}
+
 void NativeWebRuntimeDelegateTV::DidInitialized() {
+  EarlyLoadUrlIfHostedApp();
   VideoSplashScreen::InitializeVSS();
   SetD2dServiceMessageListener();
   SubscribePowerState();
index 835f00cddcb0153ec1ec09185b69e1542667da53..2eb45f649cf6e23229534d8382e14007c911e29f 100644 (file)
@@ -54,7 +54,9 @@ class NativeWebRuntimeDelegateTV : public WRTProfileDelegate {
   void SetProxyInfo(const std::string& proxy_info) {
     proxy_info_ = proxy_info;
   }
-
+  void SetPayloadData() {
+    has_payload_data_ = true;
+  }
   void BuildPrivilegeCache();
   std::set<std::string> GetPrivilegeCache();
 
@@ -74,6 +76,7 @@ class NativeWebRuntimeDelegateTV : public WRTProfileDelegate {
 
   void ApplyHalfWindow(std::string half_window_option);
   void ClearTmpFolder();
+  void EarlyLoadUrlIfHostedApp();
   void SetD2dServiceMessageListener();
   void SetDiskCache(bool enable);
   base::FilePath GetTmgFilePath();
@@ -89,6 +92,7 @@ class NativeWebRuntimeDelegateTV : public WRTProfileDelegate {
   bool locale_dir_binded_ = false;
   bool privilege_cahce_init_ = false;
   bool power_callback_registered_ = false;
+  bool has_payload_data_ = false;
   base::FilePath tmg_file_path_;
   std::set<std::string> privileges_cache_;
 };