From: Mobaswirul Islam/NC eXperience Group /SRBD/Engineer/Samsung Electronics Date: Wed, 26 Jun 2024 05:29:41 +0000 (+0600) Subject: Modifying SettingView to improve launch time X-Git-Tag: accepted/tizen/unified/20240704.075704~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=1221ca09be0afa3f5ab4c7b434b056026dba1068;p=profile%2Fiot%2Fapps%2Fdotnet%2Fsettings.git Modifying SettingView to improve launch time [Problem] Launch time was delayed. [Cause & Measure] Cause : Overhead of handling multiple threads. Measure : Removed workerthreads. Change-Id: I0a054a166283d0be382da408eeb85d5a7136b2df Signed-off-by: Mobaswirul Islam/NC eXperience Group /SRBD/Engineer/Samsung Electronics --- diff --git a/SettingView/SettingView.cs b/SettingView/SettingView.cs index bd9defd..ff1896d 100644 --- a/SettingView/SettingView.cs +++ b/SettingView/SettingView.cs @@ -38,8 +38,6 @@ namespace SettingView private static bool noVisibleMainMenus; private static List mainMenuInfos; private static List mainMenuItems = new List(); - private static Task itemsLoaded; - private static Task contentLoaded; private bool isLightTheme => ThemeManager.PlatformThemeId == "org.tizen.default-light-theme"; public Program(Size2D windowSize, Position2D windowPosition, ThemeOptions themeOptions, IBorderInterface borderInterface) @@ -47,67 +45,44 @@ namespace SettingView { } - private Task InitResourcesManager() + private void CreateTitleAndScroll() { - return Task.Run(() => + Logger.Performance($"CreateTitleAndScroll start"); + page.Title = new TextLabel() { - // initialize ResourcesManager instance - var title = Resources.IDS_ST_OPT_SETTINGS; - return true; - }); - } - - private Task CreateTitleAndScroll() - { - return Task.Run(async () => + Size = new Size(-1, 64).SpToPx(), + Margin = new Extents(16, 0, 0, 0).SpToPx(), + Text = Resources.IDS_ST_OPT_SETTINGS, + VerticalAlignment = VerticalAlignment.Center, + PixelSize = 24.SpToPx(), + ThemeChangeSensitive = true, + }; + + page.Add(page.Title); + page.Title.Relayout += (s, e) => { - await Post(() => - { - Logger.Performance($"CreateTitleAndScroll start"); - page.Title = new TextLabel() - { - Size = new Size(-1, 64).SpToPx(), - Margin = new Extents(16, 0, 0, 0).SpToPx(), - Text = Resources.IDS_ST_OPT_SETTINGS, - VerticalAlignment = VerticalAlignment.Center, - PixelSize = 24.SpToPx(), - ThemeChangeSensitive = true, - }; - page.Add(page.Title); - page.Title.Relayout += (s, e) => - { - Logger.Performance($"CreateTitleAndScroll label"); - }; + Logger.Performance($"CreateTitleAndScroll label"); + }; - page.Content = new ScrollableBase() - { - WidthSpecification = LayoutParamPolicies.MatchParent, - HeightSpecification = LayoutParamPolicies.MatchParent, - ScrollingDirection = ScrollableBase.Direction.Vertical, - HideScrollbar = false, - Layout = new LinearLayout() - { - LinearOrientation = LinearLayout.Orientation.Vertical, - }, - }; - SetScrollbar(); + page.Content = new ScrollableBase() + { + WidthSpecification = LayoutParamPolicies.MatchParent, + HeightSpecification = LayoutParamPolicies.MatchParent, + ScrollingDirection = ScrollableBase.Direction.Vertical, + HideScrollbar = false, + Layout = new LinearLayout() + { + LinearOrientation = LinearLayout.Orientation.Vertical, + }, + }; - page.Add(page.Content); - page.Content.Relayout += (s, e) => - { - Logger.Performance($"CreateTitleAndScroll scroll"); - }; - return true; - }); - }); - } + SetScrollbar(); - protected override void OnPreCreate() - { - Logger.Performance($"OnPreCreate"); - _ = InitResourcesManager(); - itemsLoaded = LoadMainMenuItems(); - base.OnPreCreate(); + page.Add(page.Content); + page.Content.Relayout += (s, e) => + { + Logger.Performance($"CreateTitleAndScroll scroll"); + }; } protected override void OnCreate() @@ -130,8 +105,9 @@ namespace SettingView Logger.Performance($"ONCREATE main page"); - contentLoaded = CreateTitleAndScroll(); - rowsCreated = CreateContentRows(); + LoadMainMenuItems(); + CreateTitleAndScroll(); + CreateContentRows(); _ = CheckCustomization(); @@ -339,109 +315,64 @@ namespace SettingView } } - private static Task LoadMainMenuItems(bool customizationChanged = false) + private static void LoadMainMenuItems(bool customizationChanged = false) { - return Task.Run(() => { - System.Diagnostics.Stopwatch stopwatch = new System.Diagnostics.Stopwatch(); - stopwatch.Start(); - noMainMenus = false; - noVisibleMainMenus = false; - mainMenuInfos = MainMenuInfo.CacheMenu; - if (mainMenuInfos.Count == 0 || customizationChanged) - { - var mainMenus = GadgetManager.Instance.GetMainWithCurrentOrder(); - if (!mainMenus.Any()) - { - noMainMenus = true; - return Task.CompletedTask; - } + noMainMenus = false; + noVisibleMainMenus = false; + var mainMenus = GadgetManager.Instance.GetMainWithCurrentOrder(); + if (!mainMenus.Any()) + { + noMainMenus = true; + return; + } - var visibleMenus = mainMenus.Where(i => i.IsVisible); - if (!visibleMenus.Any()) - { - noVisibleMainMenus = true; - return Task.CompletedTask; - } + var visibleMenus = mainMenus.Where(i => i.IsVisible); + if (!visibleMenus.Any()) + { + noVisibleMainMenus = true; + return; + } - mainMenuInfos = new List(); - foreach (var gadgetInfo in visibleMenus) - { - if (MainMenuInfo.Create(gadgetInfo) is MainMenuInfo menu) - { - mainMenuInfos.Add(menu); - } - } + mainMenuInfos = new List(); + foreach (var gadgetInfo in visibleMenus) + { + if (MainMenuInfo.Create(gadgetInfo) is MainMenuInfo menu) + { + mainMenuInfos.Add(menu); } - - stopwatch.Stop(); - Logger.Performance($"CONTENT get data: {stopwatch.Elapsed.TotalMilliseconds}"); - return Task.CompletedTask; - }); + } } - private static async Task CreateContentRows() + private static void CreateContentRows() { - await Task.WhenAll(new Task[] { itemsLoaded, contentLoaded }); - await Task.Run(async () => + if (noMainMenus) { - if (noMainMenus) - { - await Post(() => - { - var textLabel = GetTextNotice("There is no setting menus installed.", Color.Orange); - page.Content.Add(textLabel); - return true; - }); - return; - } - - if (noVisibleMainMenus) - { - await Post(() => - { - var textLabel = GetTextNotice("There is no setting menus visible.", Color.Gray); - page.Content.Add(textLabel); - return true; - }); - return; - } - - System.Diagnostics.Stopwatch stopwatch = new System.Diagnostics.Stopwatch(); - foreach (var menu in mainMenuInfos) - { - await Post(() => - { - if(menu == mainMenuInfos.First()) - { - Logger.Performance($"CreateContentRows start"); - stopwatch.Start(); - } - var row = new MainMenuItem(menu.IconPath, new Color(menu.IconColorHex), menu.Title, menu.Path); + var textLabel = GetTextNotice("There is no setting menus installed.", Color.Orange); + page.Content.Add(textLabel); + return; + } - if (mainMenuInfos.Last() == menu) - { - row.Relayout += (s, e) => - { - stopwatch.Stop(); - Logger.Performance($"UICompleted items: {stopwatch.Elapsed.TotalMilliseconds}"); - }; - } - mainMenuItems.Add(row); - page.Content.Add(row); - return true; - }); - } + if (noVisibleMainMenus) + { + var textLabel = GetTextNotice("There is no setting menus visible.", Color.Gray); + page.Content.Add(textLabel); + return; + } - MainMenuInfo.UpdateCache(mainMenuInfos); - }); + foreach (var menu in mainMenuInfos) + { + var row = new MainMenuItem(menu.IconPath, new Color(menu.IconColorHex), menu.Title, menu.Path); + mainMenuItems.Add(row); + page.Content.Add(row); + } } private static void CreateContent(bool customizationChanged = false) { mainMenuItems.Clear(); page.Content.RemoveAllChildren(true); - itemsLoaded = LoadMainMenuItems(customizationChanged); - _ = CreateContentRows(); + LoadMainMenuItems(customizationChanged); + CreateContentRows(); } private void SetScrollbar() @@ -464,9 +395,9 @@ namespace SettingView private static async void UpdateContent() { MainMenuInfo.ClearCache(); - await LoadMainMenuItems(true); + LoadMainMenuItems(); - foreach(var menu in mainMenuInfos) + foreach (var menu in mainMenuInfos) { var item = mainMenuItems.Where(a => a.MenuPath == menu.Path).FirstOrDefault(); if (item != null) diff --git a/packaging/org.tizen.cssettings-1.1.20.tpk b/packaging/org.tizen.cssettings-1.1.20.tpk index 6cb8862..26e90cb 100644 Binary files a/packaging/org.tizen.cssettings-1.1.20.tpk and b/packaging/org.tizen.cssettings-1.1.20.tpk differ