[NUI] Fix LottieAnimationView not to reference disposed delegate
authorJaehyun Cho <jae_hyun.cho@samsung.com>
Fri, 29 Mar 2024 03:49:57 +0000 (12:49 +0900)
committerJaehyun Cho <jaehyun0cho@gmail.com>
Fri, 29 Mar 2024 04:35:23 +0000 (13:35 +0900)
Delegate rootCallback of LottieAnimationView is called by multi threads
for lottie dynamic properties.

This causes the following issues.
- Delegate rootCallback of disposed LottieAnimationView can be
  referenced.
- Local variables in RootCallback is disposed by multi threads.

To resolve the above issues, the followings are done.
- Delegate rootCallback of LottieAnimationView is changed to be static.
- Local variables in RootCallback is not disposed.

src/Tizen.NUI/src/public/BaseComponents/LottieAnimationView.cs

index f280826..886356c 100755 (executable)
@@ -1185,7 +1185,7 @@ namespace Tizen.NUI.BaseComponents
         [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
         internal delegate void RootCallbackType(int id, int returnType, uint frameNumber, ref float val1, ref float val2, ref float val3);
 
-        internal RootCallbackType rootCallback = RootCallback;
+        static internal RootCallbackType rootCallback = RootCallback;
 
         static internal void RootCallback(int id, int returnType, uint frameNumber, ref float val1, ref float val2, ref float val3)
         {
@@ -1196,9 +1196,9 @@ namespace Tizen.NUI.BaseComponents
 
             if (weakReferencesOfLottie.TryGetValue(id, out current))
             {
-                if (current.TryGetTarget(out currentView))
+                if (current.TryGetTarget(out currentView) && (currentView != null) && !currentView.Disposed && !currentView.IsDisposeQueued)
                 {
-                    if (currentView != null && currentView.InternalSavedDynamicPropertyCallbacks != null &&
+                    if (currentView.InternalSavedDynamicPropertyCallbacks != null &&
                         currentView.InternalSavedDynamicPropertyCallbacks.TryGetValue(id, out currentCallback))
                     {
                         ret = currentCallback?.Invoke(returnType, frameNumber);
@@ -1232,7 +1232,6 @@ namespace Tizen.NUI.BaseComponents
                         val2 = tmpVector3.Y;
                         val3 = tmpVector3.Z;
                     }
-                    tmpVector3.Dispose();
                     break;
 
                 case (int)(VectorProperty.TransformAnchor):
@@ -1244,7 +1243,6 @@ namespace Tizen.NUI.BaseComponents
                         val1 = tmpVector2.X;
                         val2 = tmpVector2.Y;
                     }
-                    tmpVector2.Dispose();
                     break;
 
                 case (int)(VectorProperty.FillOpacity):