From 0017dd0e49ffbc78d8c51c6f068afd6e8fdbc8d0 Mon Sep 17 00:00:00 2001 From: "dongsug.song" Date: Thu, 15 Dec 2022 03:09:54 +0900 Subject: [PATCH] [NUI] fix the defect that the focus of VitualRemote App is stuck very rarely --- src/Tizen.NUI/src/internal/Common/Registry.cs | 46 ++++++++++++++++++++-- .../public/BaseComponents/LottieAnimationView.cs | 2 +- 2 files changed, 44 insertions(+), 4 deletions(-) diff --git a/src/Tizen.NUI/src/internal/Common/Registry.cs b/src/Tizen.NUI/src/internal/Common/Registry.cs index ecceb81..4cefbb0 100755 --- a/src/Tizen.NUI/src/internal/Common/Registry.cs +++ b/src/Tizen.NUI/src/internal/Common/Registry.cs @@ -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 { diff --git a/src/Tizen.NUI/src/public/BaseComponents/LottieAnimationView.cs b/src/Tizen.NUI/src/public/BaseComponents/LottieAnimationView.cs index 9c0e4b9..c162a70 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/LottieAnimationView.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/LottieAnimationView.cs @@ -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; } } -- 2.7.4