Merge lp:~vikoadi/slingshot/async_update_menu into lp:~elementary-pantheon/slingshot/trunk

Proposed by Viko Adi Rahmawan
Status: Rejected
Rejected by: Danielle Foré
Proposed branch: lp:~vikoadi/slingshot/async_update_menu
Merge into: lp:~elementary-pantheon/slingshot/trunk
Diff against target: 227 lines (+63/-42)
4 files modified
src/Backend/AppSystem.vala (+46/-18)
src/Backend/SynapseSearch.vala (+12/-4)
src/SlingshotView.vala (+5/-8)
src/Widgets/CategoryView.vala (+0/-12)
To merge this branch: bzr merge lp:~vikoadi/slingshot/async_update_menu
Reviewer Review Type Date Requested Status
Cody Garver (community) Needs Fixing
xapantu (community) Approve
Review via email: mp+268855@code.launchpad.net

Description of the change

* asynchronousely update_app_system on AppSystem backend and Synapse plugin registration

To post a comment you must log in.
570. By Viko Adi Rahmawan

tidy up

571. By Viko Adi Rahmawan

dont animate if previous stack is search_view

572. By Viko Adi Rahmawan

remove spinner after itsn't used anymore

573. By Viko Adi Rahmawan

make synapse backend initialized asynchronously

Revision history for this message
xapantu (xapantu) wrote :

That's cool :)

However, as we discussed a few minutes ago, there is 2 main issues:

* Please add some Mutex, this way it is not thread safe, in AppSystem *and* in SynapseSearch.
* In the async function, if the thread creation fails, the function never finish, not sure it is a good thing, the yield should probably be before the catch.

(also some code style issues written in the diff comments)

review: Needs Fixing
574. By Viko Adi Rahmawan

lock shared variable

575. By Viko Adi Rahmawan

dont create a new thread, update on each category addition

576. By Viko Adi Rahmawan

dont screw to much code

Revision history for this message
Viko Adi Rahmawan (vikoadi) wrote :

I'm trying a completely different take, now we dont use different thread instead we update icon on using Idle cycle. Icon will be added on each every finished category.
this one should be much more simpler yet we show icon quicker although showing first popover will be a little bit slower (need to wait for first category to be completely created)

Revision history for this message
xapantu (xapantu) wrote :
Download full text (33.4 KiB)

Hum I just got this after a lot of launch:

xapantu@ntu /t/a/build> ./slingshot-launcher
[INFO 00:20:35.638194] Application.vala:155: Slingshot version: 0.8.1.1
[INFO 00:20:35.638579] Application.vala:157: Kernel version: 4.1.4-1-ARCH
[WARNING 00:20:35.786079] App.vala:192: Could not load icon. Falling back to method 2
[WARNING 00:20:35.786172] App.vala:225: Could not load icon. Falling back to method 4
[22:20:37.467840 Warning] App.vala:192: Could not load icon. Falling back to method 2
[22:20:37.467907 Warning] App.vala:225: Could not load icon. Falling back to method 4
*** Error in `./slingshot-launcher': free(): invalid next size (fast): 0x0000000001715a40 ***
======= Backtrace: =========
/usr/lib/libc.so.6(+0x72055)[0x7f9924dfd055]
/usr/lib/libc.so.6(+0x779a6)[0x7f9924e029a6]
/usr/lib/libc.so.6(+0x7818e)[0x7f9924e0318e]
/usr/lib/libglib-2.0.so.0(+0x37e5c)[0x7f9925464e5c]
/usr/lib/libglib-2.0.so.0(+0x3847f)[0x7f992546547f]
/usr/lib/libglib-2.0.so.0(+0x385b6)[0x7f99254655b6]
/usr/lib/libglib-2.0.so.0(g_string_chunk_insert_const+0x95)[0x7f9925498d75]
/usr/lib/libzeitgeist-2.0.so.0(zeitgeist_subject_set_interpretation+0x1c)[0x7f9925968fbc]
/usr/lib/libzeitgeist-2.0.so.0(zeitgeist_db_reader_get_subject_from_row+0x14b)[0x7f992597385b]
/usr/lib/libzeitgeist-2.0.so.0(zeitgeist_db_reader_get_events+0x1a8)[0x7f9925973bb8]
/usr/lib/libzeitgeist-2.0.so.0(zeitgeist_db_reader_find_events+0xe0)[0x7f9925976c00]
/usr/lib/libzeitgeist-2.0.so.0(+0x1b326)[0x7f9925958326]
/usr/lib/libzeitgeist-2.0.so.0(+0x1c9e3)[0x7f99259599e3]
/usr/lib/libglib-2.0.so.0(+0x70fb8)[0x7f992549dfb8]
/usr/lib/libglib-2.0.so.0(+0x70625)[0x7f992549d625]
/usr/lib/libpthread.so.0(+0x74a4)[0x7f99245424a4]
/usr/lib/libc.so.6(clone+0x6d)[0x7f9924e7413d]
======= Memory map: ========
00400000-004bc000 r-xp 00000000 00:22 182906 /tmp/async_update_menu/build/slingshot-launcher
006bc000-006be000 rw-p 000bc000 00:22 182906 /tmp/async_update_menu/build/slingshot-launcher
013eb000-03f6f000 rw-p 00000000 00:00 0 [heap]
7f98e8000000-7f98e8023000 rw-p 00000000 00:00 0
7f98e8023000-7f98ec000000 ---p 00000000 00:00 0
7f98f0000000-7f98f0076000 rw-p 00000000 00:00 0
7f98f0076000-7f98f4000000 ---p 00000000 00:00 0
7f98f4000000-7f98f404f000 rw-p 00000000 00:00 0
7f98f404f000-7f98f8000000 ---p 00000000 00:00 0
7f98f8000000-7f98f8022000 rw-p 00000000 00:00 0
7f98f8022000-7f98fc000000 ---p 00000000 00:00 0
7f98fd5e7000-7f98fe5e7000 rw-s 00000000 00:05 17825805 /SYSV00000000 (deleted)
7f98fe5e7000-7f98fe5fd000 r-xp 00000000 08:04 8129989 /usr/lib/libgcc_s.so.1
7f98fe5fd000-7f98fe7fc000 ---p 00016000 08:04 8129989 /usr/lib/libgcc_s.so.1
7f98fe7fc000-7f98fe7fd000 rw-p 00015000 08:04 8129989 /usr/lib/libgcc_s.so.1
7f98fe7fd000-7f98fe7fe000 ---p 00000000 00:00 0
7f98fe7fe000-7f98feffe000 rw-p 00000000 00:00 0 [stack:19193]
7f98feffe000-7f98fefff000 ---p 00000000 00:00 0
7f98fefff000-7f98ff7ff000 rw-p 00000000 00:00 0 [stack:19192]
7f98ff7ff000-7f98ff800000 ---p 00000000 00:00 0
7f98ff80000...

Revision history for this message
xapantu (xapantu) wrote :

See inline comments.

Ah, and do you notice performance improvements ? It's hard to mesure, but it looks like to be roughly the same here (however I have a rather fast computer and not so many apps).

Revision history for this message
xapantu (xapantu) :
review: Needs Fixing
Revision history for this message
xapantu (xapantu) wrote :

About the crash, I will test more later, that may not be related to your branch, as it does not appear very often. The core dump is not usable I am afraid:

(gdb) bt
#0 0x00007f9924dbe5f8 in raise () from /usr/lib/libc.so.6
#1 0x00007f9924dbfa7a in abort () from /usr/lib/libc.so.6
#2 0x00007f9924dfd05a in __libc_message () from /usr/lib/libc.so.6
#3 0x00007f9924e029a6 in malloc_printerr () from /usr/lib/libc.so.6
#4 0x00007f9924e0318e in _int_free () from /usr/lib/libc.so.6
#5 0x00007f9925464e5c in ?? () from /usr/lib/libglib-2.0.so.0
#6 0x00007f992546547f in ?? () from /usr/lib/libglib-2.0.so.0
#7 0x00007f99254655b6 in ?? () from /usr/lib/libglib-2.0.so.0
#8 0x00007f9925498d75 in g_string_chunk_insert_const () from /usr/lib/libglib-2.0.so.0
#9 0x00007f9925968fbc in zeitgeist_subject_set_interpretation () from /usr/lib/libzeitgeist-2.0.so.0
#10 0x00007f992597385b in zeitgeist_db_reader_get_subject_from_row () from /usr/lib/libzeitgeist-2.0.so.0
#11 0x00007f9925973bb8 in zeitgeist_db_reader_get_events () from /usr/lib/libzeitgeist-2.0.so.0
#12 0x00007f9925976c00 in zeitgeist_db_reader_find_events () from /usr/lib/libzeitgeist-2.0.so.0
#13 0x00007f9925958326 in ?? () from /usr/lib/libzeitgeist-2.0.so.0
#14 0x00007f99259599e3 in ?? () from /usr/lib/libzeitgeist-2.0.so.0
#15 0x00007f992549dfb8 in ?? () from /usr/lib/libglib-2.0.so.0
#16 0x00007f992549d625 in ?? () from /usr/lib/libglib-2.0.so.0
#17 0x00007f99245424a4 in start_thread () from /usr/lib/libpthread.so.0
#18 0x00007f9924e7413d in clone () from /usr/lib/libc.so.6
(gdb) quit

577. By Viko Adi Rahmawan

use cancellation on appsystem update

578. By Viko Adi Rahmawan

rename to async

579. By Viko Adi Rahmawan

try to behave with zero apps

580. By Viko Adi Rahmawan

dont use implisit begin

581. By Viko Adi Rahmawan

merge trunk

Revision history for this message
Viko Adi Rahmawan (vikoadi) wrote :

now use cancellation to cancel previous update_appsystem.
this thing should not fasten anything, it just show popup earlier and then categories/apps are added incrementally to gridview. it is visible on my low performance computer

582. By Viko Adi Rahmawan

dont wait for data-sink

Revision history for this message
xapantu (xapantu) wrote :

Minor code-style issues that could be fixed, but perfect otherwise. Works fine in the indicator version too (however, in this one, we should have an api in wingpanel to decide when heavy loading can be done (to balance everything, if every indicator loads at startup, it will just be too heavy).

review: Approve
583. By Viko Adi Rahmawan

dont wait for refersh_popularty

584. By Viko Adi Rahmawan

tidy up

Revision history for this message
Viko Adi Rahmawan (vikoadi) wrote :

good to hear that it works in wingpanel too

Revision history for this message
Cody Garver (codygarver) wrote :

Conflicts with trunk

review: Needs Fixing
Revision history for this message
Zisu Andrei (matzipan) wrote :

It would be ashame to see all this work wasted. Merge trunk?

Unmerged revisions

584. By Viko Adi Rahmawan

tidy up

583. By Viko Adi Rahmawan

dont wait for refersh_popularty

582. By Viko Adi Rahmawan

dont wait for data-sink

581. By Viko Adi Rahmawan

merge trunk

580. By Viko Adi Rahmawan

dont use implisit begin

579. By Viko Adi Rahmawan

try to behave with zero apps

578. By Viko Adi Rahmawan

rename to async

577. By Viko Adi Rahmawan

use cancellation on appsystem update

576. By Viko Adi Rahmawan

dont screw to much code

575. By Viko Adi Rahmawan

dont create a new thread, update on each category addition

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/Backend/AppSystem.vala'
--- src/Backend/AppSystem.vala 2014-08-16 15:13:42 +0000
+++ src/Backend/AppSystem.vala 2015-09-24 06:06:49 +0000
@@ -24,6 +24,8 @@
24 private Gee.ArrayList<GMenu.TreeDirectory> categories = null;24 private Gee.ArrayList<GMenu.TreeDirectory> categories = null;
25 private Gee.HashMap<string, Gee.ArrayList<App>> apps = null;25 private Gee.HashMap<string, Gee.ArrayList<App>> apps = null;
26 private GMenu.Tree apps_menu = null;26 private GMenu.Tree apps_menu = null;
27 private Cancellable update_category_cancellable = null;
28 private Cancellable update_apps_cancellable = null;
2729
28#if HAVE_ZEITGEIST30#if HAVE_ZEITGEIST
29 private RelevancyService rl_service;31 private RelevancyService rl_service;
@@ -38,42 +40,61 @@
38#endif40#endif
3941
40 apps_menu = new GMenu.Tree ("pantheon-applications.menu", GMenu.TreeFlags.INCLUDE_EXCLUDED | GMenu.TreeFlags.SORT_DISPLAY_NAME);42 apps_menu = new GMenu.Tree ("pantheon-applications.menu", GMenu.TreeFlags.INCLUDE_EXCLUDED | GMenu.TreeFlags.SORT_DISPLAY_NAME);
41 apps_menu.changed.connect (update_app_system);43 apps_menu.changed.connect (()=>{update_app_system_async.begin ();});
42 44
43 apps = new Gee.HashMap<string, Gee.ArrayList<App>> ();45 apps = new Gee.HashMap<string, Gee.ArrayList<App>> ();
44 categories = new Gee.ArrayList<GMenu.TreeDirectory> ();46 categories = new Gee.ArrayList<GMenu.TreeDirectory> ();
47 update_category_cancellable = new Cancellable ();
48 update_apps_cancellable = new Cancellable ();
4549
46 update_app_system ();50 update_app_system_async.begin ();
47 }51 }
4852
49 private void update_app_system () {53 private async void update_app_system_async () {
50 debug ("Updating Applications menu tree...");54 debug ("Updating Applications menu tree...");
51#if HAVE_ZEITGEIST55#if HAVE_ZEITGEIST
56 Idle.add (update_app_system_async.callback);
57 yield;
52 rl_service.refresh_popularity ();58 rl_service.refresh_popularity ();
53#endif59#endif
60
54 try {61 try {
62 Idle.add (update_app_system_async.callback);
63 yield;
55 apps_menu.load_sync ();64 apps_menu.load_sync ();
56 } catch (Error e) {65 } catch (Error e) {
57 warning (e.message);66 warning (e.message);
58 }67 }
5968
60 update_categories_index ();69 update_category_cancellable.cancel ();
61 update_apps ();
62
63 changed ();
64 }
65
66 private void update_categories_index () {
67 categories.clear ();70 categories.clear ();
6871 update_category_cancellable.reset ();
69 var iter = apps_menu.get_root_directory ().iter ();72 yield update_categories_index_async (update_category_cancellable);
73
74 update_apps_cancellable.cancel ();
75 apps.clear ();
76 update_apps_cancellable.reset ();
77 yield update_apps_async (update_apps_cancellable);
78 }
79
80 private async void update_categories_index_async (Cancellable cancellable) {
81
82 GMenu.TreeIter iter;
83 iter = apps_menu.get_root_directory ().iter ();
84
70 GMenu.TreeItemType type;85 GMenu.TreeItemType type;
71 while ((type = iter.next ()) != GMenu.TreeItemType.INVALID) {86 while ((type = iter.next ()) != GMenu.TreeItemType.INVALID) {
87 uint handle = Idle.add (update_categories_index_async.callback);
88 var c_handler = cancellable.connect (() => {Source.remove (handle);});
89 yield;
90
72 if (type == GMenu.TreeItemType.DIRECTORY) {91 if (type == GMenu.TreeItemType.DIRECTORY) {
73 var dir = iter.get_directory ();92 var dir = iter.get_directory ();
74 if (!dir.get_is_nodisplay ())93 if (!dir.get_is_nodisplay ())
75 categories.add (dir);94 categories.add (dir);
76 }95 }
96
97 cancellable.disconnect (c_handler);
77 }98 }
78 }99 }
79100
@@ -85,10 +106,18 @@
85 }106 }
86#endif107#endif
87108
88 private void update_apps () {109 private async void update_apps_async (Cancellable cancellable) {
89 apps.clear ();110 foreach (var cat in categories) {
90 foreach (var cat in categories)111 GMenu.TreeDirectory category = cat;
91 apps.set (cat.get_name (), get_apps_by_category (cat));112 uint handle = Idle.add (update_apps_async.callback);
113 var c_handler = cancellable.connect (() => {Source.remove (handle);});
114 yield;
115
116 apps.set (category.get_name (), get_apps_by_category (category));
117 changed ();
118
119 cancellable.disconnect(c_handler);
120 }
92 }121 }
93122
94 public Gee.ArrayList<GMenu.TreeDirectory> get_categories () {123 public Gee.ArrayList<GMenu.TreeDirectory> get_categories () {
@@ -133,7 +162,6 @@
133 && (GCC_PANEL_CATEGORY in app.categories162 && (GCC_PANEL_CATEGORY in app.categories
134 || SWITCHBOARD_PLUG_CATEGORY in app.categories))163 || SWITCHBOARD_PLUG_CATEGORY in app.categories))
135 continue;164 continue;
136
137165
138 if (!(app.exec in sorted_apps_execs)) {166 if (!(app.exec in sorted_apps_execs)) {
139 sorted_apps.insert_sorted_with_data (app, Utils.sort_apps_by_name);167 sorted_apps.insert_sorted_with_data (app, Utils.sort_apps_by_name);
@@ -144,4 +172,4 @@
144172
145 return sorted_apps;173 return sorted_apps;
146 }174 }
147}
148\ No newline at end of file175\ No newline at end of file
176}
149177
=== modified file 'src/Backend/SynapseSearch.vala'
--- src/Backend/SynapseSearch.vala 2015-06-03 19:10:24 +0000
+++ src/Backend/SynapseSearch.vala 2015-09-24 06:06:49 +0000
@@ -36,15 +36,23 @@
36 public SynapseSearch () {36 public SynapseSearch () {
3737
38 if (sink == null) {38 if (sink == null) {
39 sink = new Synapse.DataSink ();39 register_static_plugins_async.begin ();
40 foreach (var plugin in plugins) {
41 sink.register_static_plugin (plugin);
42 }
4340
44 favicon_cache = new Gee.HashMap<string,Gdk.Pixbuf> ();41 favicon_cache = new Gee.HashMap<string,Gdk.Pixbuf> ();
45 }42 }
46 }43 }
4744
45 private async void register_static_plugins_async () {
46 Idle.add (register_static_plugins_async.callback);
47 yield;
48 sink = new Synapse.DataSink ();
49 foreach (var plugin in plugins) {
50 Idle.add_full (Priority.LOW, register_static_plugins_async.callback);
51 yield;
52 sink.register_static_plugin (plugin);
53 }
54 }
55
48 public async Gee.List<Synapse.Match>? search (string text, Synapse.SearchProvider? provider = null) {56 public async Gee.List<Synapse.Match>? search (string text, Synapse.SearchProvider? provider = null) {
4957
50 if (current_search != null)58 if (current_search != null)
5159
=== modified file 'src/SlingshotView.vala'
--- src/SlingshotView.vala 2015-02-01 15:13:15 +0000
+++ src/SlingshotView.vala 2015-09-24 06:06:49 +0000
@@ -87,16 +87,14 @@
87 this.set_type_hint (Gdk.WindowTypeHint.MENU);87 this.set_type_hint (Gdk.WindowTypeHint.MENU);
88 this.focus_on_map = true;88 this.focus_on_map = true;
8989
90 // Have the window in the right place
91 read_settings (true);
9290
93 Slingshot.icon_theme = Gtk.IconTheme.get_default ();91 Slingshot.icon_theme = Gtk.IconTheme.get_default ();
9492 categories = new Gee.ArrayList<GMenu.TreeDirectory> ();
93 apps = new Gee.HashMap<string, Gee.ArrayList<Backend.App>> ();
95 app_system = new Backend.AppSystem ();94 app_system = new Backend.AppSystem ();
96 synapse = new Backend.SynapseSearch ();95 synapse = new Backend.SynapseSearch ();
9796 // Have the window in the right place
98 categories = app_system.get_categories ();97 read_settings (true);
99 apps = app_system.get_apps ();
10098
101 primary_monitor = screen.get_primary_monitor ();99 primary_monitor = screen.get_primary_monitor ();
102 Gdk.Rectangle geometry;100 Gdk.Rectangle geometry;
@@ -108,6 +106,7 @@
108 setup_ui ();106 setup_ui ();
109107
110 connect_signals ();108 connect_signals ();
109
111 debug ("Apps loaded");110 debug ("Apps loaded");
112 }111 }
113112
@@ -830,8 +829,6 @@
830 grid_view.append (app_entry);829 grid_view.append (app_entry);
831 app_entry.show_all ();830 app_entry.show_all ();
832 }831 }
833
834 stack.set_visible_child_name ("normal");
835 }832 }
836833
837 private void read_settings (bool first_start = false, bool check_columns = true, bool check_rows = true) {834 private void read_settings (bool first_start = false, bool check_columns = true, bool check_rows = true) {
838835
=== modified file 'src/Widgets/CategoryView.vala'
--- src/Widgets/CategoryView.vala 2015-01-17 23:56:32 +0000
+++ src/Widgets/CategoryView.vala 2015-09-24 06:06:49 +0000
@@ -52,7 +52,6 @@
52 add (container);52 add (container);
5353
54 connect_events ();54 connect_events ();
55 setup_sidebar ();
56 }55 }
5756
58 public void setup_sidebar () {57 public void setup_sidebar () {
@@ -72,17 +71,6 @@
72 }71 }
73 category_switcher.show_all ();72 category_switcher.show_all ();
7473
75 int minimum_width;
76 category_switcher.get_preferred_width (out minimum_width, null);
77
78 // Because of the different sizes of the column widget, we need to calculate if it will fit.
79 int removing_columns = (int)((double)minimum_width / (double)Pixels.ITEM_SIZE);
80 if (minimum_width % Pixels.ITEM_SIZE != 0)
81 removing_columns++;
82
83 int columns = view.columns - removing_columns;
84 app_view.resize (view.rows, columns);
85
86 category_switcher.selected = old_selected;74 category_switcher.selected = old_selected;
87 }75 }
8876

Subscribers

People subscribed via source and target branches