From 11a6b2fbc6f47cdf8e9383fa496339c604822656 Mon Sep 17 00:00:00 2001 From: "Eunki, Hong" Date: Tue, 14 Nov 2023 18:25:53 +0900 Subject: [PATCH] [NUI] Change SetMinAndMaxFrameByMarker behavior + Fix some async cases Let we allow to call SetMinAndMaxFrameByMarker API even if load is not finished. Instead, let we just call some log if the file is not loaded yet. Plus, Some API (GetContentInfo, GetMarkerInfo) might cache wrong values when we use async load Before try to get correct value, let we check whether the resource is loaded or not. Signed-off-by: Eunki, Hong --- .../BaseComponents/AnimatedVectorImageView.cs | 24 ++++-- .../public/BaseComponents/LottieAnimationView.cs | 99 ++++++++++++---------- 2 files changed, 70 insertions(+), 53 deletions(-) diff --git a/src/Tizen.NUI/src/public/BaseComponents/AnimatedVectorImageView.cs b/src/Tizen.NUI/src/public/BaseComponents/AnimatedVectorImageView.cs index 690eacb..1edac88 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/AnimatedVectorImageView.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/AnimatedVectorImageView.cs @@ -410,8 +410,13 @@ namespace Tizen.NUI.BaseComponents break; case minMaxSetTypes.SetByMinAndMaxFrameByMarkerMethod: - GetFrameValueFromMarkerInfo(); - goto case minMaxSetTypes.SetByMinAndMaxFrameMethod; + base.SetMinMaxFrameByMarker(minimumFrameMarker, maximumFrameMarker); + if (GetFrameValueFromMarkerInfo()) + { + base.CurrentFrame = minimumFrame; + innerCurrentFrame = minimumFrame; + } + break; case minMaxSetTypes.SetByMinAndMaxFrameMethod: base.SetMinMaxFrame(minimumFrame, maximumFrame); @@ -609,7 +614,7 @@ namespace Tizen.NUI.BaseComponents #region Internal - internal void GetFrameValueFromMarkerInfo() + internal bool GetFrameValueFromMarkerInfo() { bool minimumMarkerFoundSuccess = false; bool maximumMarkerFoundSuccess = false; @@ -618,12 +623,6 @@ namespace Tizen.NUI.BaseComponents NUILog.Debug($" [{GetId()}] GetFrameValueFromMarkerInfo : marker = (minimumFrameMarker:{minimumFrameMarker}, maximumFrameMarker:{maximumFrameMarker})"); - // Note : let we insure to get marker frame value only one time per each frame marker setter - if (minimumFrameMarker == null) - { - return; - } - var markerInfoList = GetMarkerInfo(); if (markerInfoList != null) { @@ -661,13 +660,20 @@ namespace Tizen.NUI.BaseComponents { NUILog.Debug($" [{GetId()}] minimumFrame:{minimumFrame} > maximumFrame:{maximumFrame})"); } + + // Note : let we insure to get marker frame value only one time per each frame marker setter minimumFrameMarker = maximumFrameMarker = null; + isMinMaxFrameSet = minMaxSetTypes.SetByMinAndMaxFrameMethod; + return true; } else { + Tizen.Log.Error("NUI", $"Fail to get frame from marker = (minimumFrameMarker:{minimumFrameMarker}, maximumFrameMarker:{maximumFrameMarker}). Maybe file is not loaded yet, or invalid marker used. url : {resourceUrl}\n"); + minimumFrame = 0; maximumFrame = totalFrameNum - 1; NUILog.Debug($" [{GetId()}] GetFrameValueFromMarkerInfo Failed! frame set as {minimumFrame} ~ {maximumFrame} : marker = (minimumFrameMarker:{minimumFrameMarker}, maximumFrameMarker:{maximumFrameMarker})"); + return false; } } #endregion Internal diff --git a/src/Tizen.NUI/src/public/BaseComponents/LottieAnimationView.cs b/src/Tizen.NUI/src/public/BaseComponents/LottieAnimationView.cs index 54bc229..cc05ebb 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/LottieAnimationView.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/LottieAnimationView.cs @@ -206,6 +206,11 @@ namespace Tizen.NUI.BaseComponents currentStates.totalFrame = ret; NUILog.Debug($"TotalFrameNumber get! ret={ret}"); + + if (ret <= 0) + { + Tizen.Log.Error("NUI", $"Fail to get TotalFrame. Maybe file is not loaded yet, or invalid url used. url : {currentStates.url}\n"); + } } return ret; } @@ -556,38 +561,41 @@ namespace Tizen.NUI.BaseComponents PropertyMap imageMap = base.Image; if (imageMap != null) { - PropertyValue val = imageMap.Find(ImageVisualProperty.ContentInfo); - PropertyMap contentMap = new PropertyMap(); - if (val?.Get(ref contentMap) == true) + if (TotalFrame > 0) // Check whether image file loaded successfuly. { - currentStates.contentInfo = new List>(); - for (uint i = 0; i < contentMap.Count(); i++) + PropertyValue val = imageMap.Find(ImageVisualProperty.ContentInfo); + PropertyMap contentMap = new PropertyMap(); + if (val?.Get(ref contentMap) == true) { - using PropertyKey propertyKey = contentMap.GetKeyAt(i); - string key = propertyKey.StringKey; - - using PropertyValue arrVal = contentMap.GetValue(i); - using PropertyArray arr = new PropertyArray(); - if (arrVal.Get(arr)) + currentStates.contentInfo = new List>(); + for (uint i = 0; i < contentMap.Count(); i++) { - int startFrame = -1; - using PropertyValue start = arr.GetElementAt(0); - start?.Get(out startFrame); + using PropertyKey propertyKey = contentMap.GetKeyAt(i); + string key = propertyKey.StringKey; + + using PropertyValue arrVal = contentMap.GetValue(i); + using PropertyArray arr = new PropertyArray(); + if (arrVal.Get(arr)) + { + int startFrame = -1; + using PropertyValue start = arr.GetElementAt(0); + start?.Get(out startFrame); - int endFrame = -1; - using PropertyValue end = arr.GetElementAt(1); - end?.Get(out endFrame); + int endFrame = -1; + using PropertyValue end = arr.GetElementAt(1); + end?.Get(out endFrame); - NUILog.Debug($"[{i}] layer name={key}, startFrame={startFrame}, endFrame={endFrame}"); + NUILog.Debug($"[{i}] layer name={key}, startFrame={startFrame}, endFrame={endFrame}"); - Tuple item = new Tuple(key, startFrame, endFrame); + Tuple item = new Tuple(key, startFrame, endFrame); - currentStates.contentInfo?.Add(item); + currentStates.contentInfo?.Add(item); + } } } + contentMap.Dispose(); + val?.Dispose(); } - contentMap.Dispose(); - val?.Dispose(); } NUILog.Debug($">"); @@ -612,38 +620,41 @@ namespace Tizen.NUI.BaseComponents PropertyMap imageMap = base.Image; if (imageMap != null) { - PropertyValue val = imageMap.Find(ImageVisualProperty.MarkerInfo); - PropertyMap markerMap = new PropertyMap(); - if (val?.Get(ref markerMap) == true) + if (TotalFrame > 0) // Check whether image file loaded successfuly. { - currentStates.markerInfo = new List>(); - for (uint i = 0; i < markerMap.Count(); i++) + PropertyValue val = imageMap.Find(ImageVisualProperty.MarkerInfo); + PropertyMap markerMap = new PropertyMap(); + if (val?.Get(ref markerMap) == true) { - using PropertyKey propertyKey = markerMap.GetKeyAt(i); - string key = propertyKey.StringKey; - - using PropertyValue arrVal = markerMap.GetValue(i); - using PropertyArray arr = new PropertyArray(); - if (arrVal.Get(arr)) + currentStates.markerInfo = new List>(); + for (uint i = 0; i < markerMap.Count(); i++) { - int startFrame = -1; - using PropertyValue start = arr.GetElementAt(0); - start?.Get(out startFrame); + using PropertyKey propertyKey = markerMap.GetKeyAt(i); + string key = propertyKey.StringKey; - int endFrame = -1; - using PropertyValue end = arr.GetElementAt(1); - end?.Get(out endFrame); + using PropertyValue arrVal = markerMap.GetValue(i); + using PropertyArray arr = new PropertyArray(); + if (arrVal.Get(arr)) + { + int startFrame = -1; + using PropertyValue start = arr.GetElementAt(0); + start?.Get(out startFrame); - NUILog.Debug($"[{i}] marker name={key}, startFrame={startFrame}, endFrame={endFrame}"); + int endFrame = -1; + using PropertyValue end = arr.GetElementAt(1); + end?.Get(out endFrame); - Tuple item = new Tuple(key, startFrame, endFrame); + NUILog.Debug($"[{i}] marker name={key}, startFrame={startFrame}, endFrame={endFrame}"); - currentStates.markerInfo?.Add(item); + Tuple item = new Tuple(key, startFrame, endFrame); + + currentStates.markerInfo?.Add(item); + } } } + markerMap.Dispose(); + val?.Dispose(); } - markerMap.Dispose(); - val?.Dispose(); } NUILog.Debug($">"); -- 2.7.4