Relaunch widget when widget_instance_launch is failed 96/324696/3 tizen_7.0
authortscholb <scholb.kim@samsung.com>
Fri, 23 May 2025 04:16:50 +0000 (13:16 +0900)
committersunghyun kim <scholb.kim@samsung.com>
Fri, 13 Jun 2025 13:05:16 +0000 (22:05 +0900)
Change-Id: Id6ff25f5df2b6203c62261c117c7d706f5362085

widget_viewer_dali/internal/widget_view/widget_view_impl.cpp
widget_viewer_dali/internal/widget_view/widget_view_impl.h

index 5058b77c89120bad3c186d8ab15fb1b734a291cb..dc30975f3a62bc7adf17e0c2b87f06edb4b76eb7 100644 (file)
@@ -73,6 +73,9 @@ namespace
 
 const int DEFAULT_FONT_PIXEL_SIZE = 30; // Referred platform widget viewer evas
 
+const int RELAUNCH_COUNT_MAX = 3;
+const int RELAUNCH_TIME = 500;
+
 #define GET_LOCALE_TEXT(string) dgettext(PKGNAME, string)
 
 #if defined(DEBUG_ENABLED)
@@ -245,7 +248,8 @@ WidgetView::WidgetView()
   mPreviewEnable( true ),
   mIsReadyToRender(false),
   mCornerRadius(Vector4::ZERO),
-  mCornerRadiusPolicy(1.0f)
+  mCornerRadiusPolicy(1.0f),
+  mRelaunchTryCount(0)
 {
 }
 
@@ -274,7 +278,8 @@ WidgetView::WidgetView( const std::string& widgetId, const std::string& contentI
   mPreviewEnable( true ),
   mIsReadyToRender(false),
   mCornerRadius(Vector4::ZERO),
-  mCornerRadiusPolicy(1.0f)
+  mCornerRadiusPolicy(1.0f),
+  mRelaunchTryCount(0)
 {
 }
 
@@ -1506,6 +1511,13 @@ void WidgetView::CloseRemoteSurface()
     mWatcherHandle = NULL;
     mRemoteSurface = NULL;
     mPid = -1;
+
+    mRelaunchTryCount = 0;
+    if(mRelaunchTimer)
+    {
+      mRelaunchTimer.Stop();
+      mRelaunchTimer.Reset();
+    }
   }
 }
 
@@ -1921,6 +1933,18 @@ bool WidgetView::LaunchWidget()
   mPid = widget_instance_launch( mInstanceId.c_str(), (char *)mContentInfo.c_str(), mWidth, mHeight );
   if( mPid < 0)
   {
+    if(!mRelaunchTimer)
+    {
+      // Delete WidgetVisual for relaunch widget
+      mResizeRequired = true;
+      RemoveWidgetRenderer();
+      CloseRemoteSurface();
+
+      mRelaunchTimer = Timer::New(RELAUNCH_TIME);
+      mRelaunchTimer.TickSignal().Connect(this, &WidgetView::OnRelaunch);
+      mRelaunchTimer.Start();
+    }
+
     ShowLoadingState( false );
     ShowRetryState( true );
 
@@ -2085,6 +2109,31 @@ void WidgetView::OnSizeAnimation( Animation& animation, const Vector3& targetSiz
   widget_instance_resize(mInstanceId.c_str(), targetSize.x, targetSize.y);
 }
 
+bool WidgetView::OnRelaunch()
+{
+  DALI_LOG_RELEASE_INFO("OnRelaunch: Try WidgetView Relaunch [%s] [%p]\n", mWidgetId.c_str(), this );
+
+  mPid = widget_instance_launch( mInstanceId.c_str(), (char *)mContentInfo.c_str(), mWidth, mHeight );
+  if(mPid < 0 && mRelaunchTryCount <= RELAUNCH_COUNT_MAX )
+  {
+    DALI_LOG_RELEASE_INFO("OnRelaunch: widget_instance_launch is failed. try again(%d/%d) [%s] [%p]\n", mRelaunchTryCount, RELAUNCH_COUNT_MAX,  mWidgetId.c_str(), this );
+    mRelaunchTryCount ++;
+    return true;
+  }
+
+  if(mPid >= 0)
+  {
+
+    DALI_LOG_RELEASE_INFO("OnRelaunch: widget_instance_launch is succesed. [%s] [%p]\n", mWidgetId.c_str(), this );
+  }
+
+  // Reset Relaunch Data
+  mRelaunchTryCount = 0;
+  mRelaunchTimer.Stop();
+  mRelaunchTimer.Reset();
+  return false;
+}
+
 WidgetView::WidgetViewAccessible::WidgetViewAccessible(Dali::Actor self)
 : ControlAccessible(self)
 {
index af11b960f3e7f4ad3b61eba11535b3657167f968..4837dd54f3f959e0c122dfbd4331e598713b5a25 100644 (file)
 #include <dali/devel-api/adaptor-framework/native-image-source-devel.h>
 #include <dali/devel-api/adaptor-framework/proxy-accessible.h>
 #include <dali/devel-api/adaptor-framework/window-devel.h>
+#include <dali/public-api/adaptor-framework/timer.h>
 #include <dali/public-api/object/property-notification.h>
 
+
 namespace Dali
 {
 
@@ -480,6 +482,11 @@ private:
    */
   void OnUpdateArea( Dali::PropertyNotification& source );
 
+  /**
+   * @brief Callback when widgetview need to relaunch
+   */
+  bool OnRelaunch();
+
   // Undefined
   WidgetView( const WidgetView& );
 
@@ -556,6 +563,10 @@ private:
   Vector4 mCornerRadius;                     /// < Corner radius
   float   mCornerRadiusPolicy;               /// < Corner radius policy
 
+  // For re-launch widgetviewer
+  Dali::Timer mRelaunchTimer;
+  int         mRelaunchTryCount;
+
   // Notification for property change confirmation
   Dali::PropertyNotification mPositionUpdateNotification;
   Dali::PropertyNotification mSizeUpdateNotification;