[NUI] fix the defect that the focus of VitualRemote App is stuck very rarely
authordongsug.song <dongsug.song@samsung.com>
Wed, 14 Dec 2022 18:09:54 +0000 (03:09 +0900)
committerdongsug-song <35130733+dongsug-song@users.noreply.github.com>
Wed, 14 Dec 2022 18:19:09 +0000 (03:19 +0900)
src/Tizen.NUI/src/internal/Common/Registry.cs
src/Tizen.NUI/src/public/BaseComponents/LottieAnimationView.cs

index ecceb81..4cefbb0 100755 (executable)
@@ -58,9 +58,49 @@ namespace Tizen.NUI
 
             RegistryCurrentThreadCheck();
 
-            if (Instance._controlMap.TryAdd(refCptr, new WeakReference(baseHandle, false)) != true)
+            if (baseHandle == null)
             {
-                NUILog.Debug("refCptr is already exist! OR something wrong!");
+                Tizen.Log.Info("NUI", $"Register() baseHandle == null, refCptr(key)={refCptr.ToString("X8")} just return!");
+                return;
+            }
+
+            if (baseHandle.HasBody() == false)
+            {
+                Tizen.Log.Info("NUI", $"HasBody() == false, just reture here!");
+                return;
+            }
+
+            const int retryCount = 3;
+            for (int i = 0; i < retryCount; i++)
+            {
+                if (Instance._controlMap.TryAdd(refCptr, new WeakReference(baseHandle, false)))
+                {
+                    break;
+                }
+                else
+                {
+                    Tizen.Log.Info("NUI", $"refCptr is already exist! OR something wrong! couldn't add, refCptr(key)={refCptr.ToString("X8")}");
+                    WeakReference wr;
+                    if (Instance._controlMap.TryGetValue(refCptr, out wr))
+                    {
+                        if (wr?.Target == null)
+                        {
+                            Tizen.Log.Info("NUI", $"wr?.Target == null!");
+                            if (Instance._controlMap.TryRemove(refCptr, out wr))
+                            {
+                                Tizen.Log.Info("NUI", $"remove OK");
+                            }
+                        }
+                        else
+                        {
+                            BaseHandle bh = wr?.Target as BaseHandle;
+                            if (bh != null)
+                            {
+                                Tizen.Log.Info("NUI", $"bh.Disposed={bh.Disposed} IsDisposeQueued={bh.IsDisposeQueued} type={bh.GetType()}");
+                            }
+                        }
+                    }
+                }
             }
 
             NUILog.Debug($"[Registry] Register! type:{baseHandle.GetType()} count:{Instance._controlMap.Count} copyNativeHandle:{baseHandle.GetBaseHandleCPtrHandleRef.Handle.ToString("X8")}");
@@ -107,7 +147,7 @@ namespace Tizen.NUI
             if (refObjectPtr == global::System.IntPtr.Zero)
             {
                 NUILog.Debug("Registry refObjectPtr is NULL! This means bind native object is NULL!");
-                //return null;
+                return null;
             }
             else
             {
index 9c0e4b9..c162a70 100755 (executable)
@@ -176,7 +176,7 @@ namespace Tizen.NUI.BaseComponents
                         }
                     }
                 }
-                Tizen.Log.Error(tag, $"  [ERROR][{GetId()}](LottieAnimationView) Fail to get URL from dali >");
+                //Tizen.Log.Info(tag, $"  [ERROR][{GetId()}](LottieAnimationView) Fail to get URL from dali >");
                 return ret;
             }
         }