Merge ~3v1n0/ubuntu/+source/gnome-shell:ubuntu/master-xubuntu-cancel-search into ~ubuntu-desktop/ubuntu/+source/gnome-shell:ubuntu/master

Proposed by Marco Trevisan (Treviño)
Status: Merged
Merged at revision: 35c2f36937bbb2f798c66181662e13c3081dcd2d
Proposed branch: ~3v1n0/ubuntu/+source/gnome-shell:ubuntu/master-xubuntu-cancel-search
Merge into: ~ubuntu-desktop/ubuntu/+source/gnome-shell:ubuntu/master
Prerequisite: ~3v1n0/ubuntu/+source/gnome-shell:ubuntu/master-3.29.92
Diff against target: 325 lines (+275/-3)
6 files modified
debian/changelog (+9/-3)
debian/patches/search-Cancel-search-provider-operations-on-clear.patch (+29/-0)
debian/patches/search-Ignore-search-provider-results-metas-if-search-is-.patch (+30/-0)
debian/patches/series (+4/-0)
debian/patches/ubuntu/search-call-XUbuntuCancel-method-on-providers-when-no-dat.patch (+167/-0)
debian/patches/viewSelector-Cancel-search-on-overview-hidden.patch (+36/-0)
Reviewer Review Type Date Requested Status
Didier Roche-Tolomelli Approve
Review via email: mp+354050@code.launchpad.net

This proposal supersedes a proposal from 2018-08-27.

Description of the change

Added XUbuntuCancel method call for search providers

To post a comment you must log in.
Revision history for this message
Didier Roche-Tolomelli (didrocks) wrote : Posted in a previous version of this proposal

Ok, this looks good to me, see some of my questions.

I saw that you made some changes on the MR after Florian's comment on your patches. Is there anything you can borrow and refresh here?

See as well my 2 questions/comments

review: Needs Information
Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote : Posted in a previous version of this proposal

> I saw that you made some changes on the MR after Florian's comment on your
> patches. Is there anything you can borrow and refresh here?

Yes, I wanted to refresh in case a review (like in this case) was coming in time, so nothing functional has been changed there, but I can refresh it on that.

As per the two questions, let me know if you want get rid of that variable or use a property bound to the cancellable instead.

Revision history for this message
Didier Roche-Tolomelli (didrocks) wrote : Posted in a previous version of this proposal

For the variable, it's really up to you and what is the most readable in your eyes. I just wanted to trigger that question so that you can think about it, but I have no strong opinion :)

Revision history for this message
Marco Trevisan (Treviño) (3v1n0) : Posted in a previous version of this proposal
Revision history for this message
Marco Trevisan (Treviño) (3v1n0) :
Revision history for this message
Didier Roche-Tolomelli (didrocks) wrote :

Just a nitpick on wrong alignement, but otherwise, looks good :)

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/debian/changelog b/debian/changelog
2index 6fbc804..16b0afa 100644
3--- a/debian/changelog
4+++ b/debian/changelog
5@@ -1,4 +1,4 @@
6-gnome-shell (3.29.92-1ubuntu1) UNRELEASED; urgency=medium
7+gnome-shell (3.29.92-1ubuntu1) cosmic; urgency=medium
8
9 * Merge with debian, remaining changes:
10 + Replace gnome-backgrounds dep with ubuntu-wallpapers and Suggests
11@@ -63,8 +63,14 @@ gnome-shell (3.29.92-1ubuntu1) UNRELEASED; urgency=medium
12 - Updated as per upstream review
13 * d/p/js-ui-Choose-some-actors-to-cache-on-the-GPU.patch:
14 - Removed (applied upstream)
15-
16- -- Marco Trevisan (Treviño) <marco@ubuntu.com> Thu, 30 Aug 2018 09:08:20 -0500
17+ * d/p/search-Cancel-search-provider-operations-on-clear.patch,
18+ d/p/search-Ignore-search-provider-results-metas-if-search-is-.patch,
19+ d/p/viewSelector-Cancel-search-on-overview-hidden.patch,
20+ d/p/ubuntu/search-call-XUbuntuCancel-method-on-providers-when-no-dat.patch:
21+ - Add support for cancelling remote search providers when the overlay
22+ is closed (and actually stop searches when requested from UI, LP: #1756826)
23+
24+ -- Marco Trevisan (Treviño) <marco@ubuntu.com> Thu, 30 Aug 2018 17:59:08 -0500
25
26 gnome-shell (3.29.92-1) experimental; urgency=medium
27
28diff --git a/debian/patches/search-Cancel-search-provider-operations-on-clear.patch b/debian/patches/search-Cancel-search-provider-operations-on-clear.patch
29new file mode 100644
30index 0000000..052ee8a
31--- /dev/null
32+++ b/debian/patches/search-Cancel-search-provider-operations-on-clear.patch
33@@ -0,0 +1,29 @@
34+From: =?utf-8?b?Ik1hcmNvIFRyZXZpc2FuIChUcmV2acOxbyki?= <mail@3v1n0.net>
35+Date: Thu, 23 Aug 2018 18:14:38 +0200
36+Subject: search: Cancel search provider operations on clear
37+
38+Ensure that the search provider operations (just getResultMetas requests in the
39+current implementation) in progress are properly cancelled when we clear the UI,
40+otherwise returned results might still be added when not needed.
41+
42+This is triggered for each provider by the SearchResults reset.
43+
44+Bug-GNOME: https://gitlab.gnome.org/GNOME/gnome-shell/issues/183
45+Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/bionic/+source/gnome-shell/+bug/1756826
46+Forwarded: https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/205
47+---
48+ js/ui/search.js | 1 +
49+ 1 file changed, 1 insertion(+)
50+
51+diff --git a/js/ui/search.js b/js/ui/search.js
52+index 1fb54b4..804be95 100644
53+--- a/js/ui/search.js
54++++ b/js/ui/search.js
55+@@ -192,6 +192,7 @@ var SearchResultsBase = new Lang.Class({
56+ },
57+
58+ clear() {
59++ this._cancellable.cancel();
60+ for (let resultId in this._resultDisplays)
61+ this._resultDisplays[resultId].actor.destroy();
62+ this._resultDisplays = {};
63diff --git a/debian/patches/search-Ignore-search-provider-results-metas-if-search-is-.patch b/debian/patches/search-Ignore-search-provider-results-metas-if-search-is-.patch
64new file mode 100644
65index 0000000..27645a5
66--- /dev/null
67+++ b/debian/patches/search-Ignore-search-provider-results-metas-if-search-is-.patch
68@@ -0,0 +1,30 @@
69+From: =?utf-8?b?Ik1hcmNvIFRyZXZpc2FuIChUcmV2acOxbyki?= <mail@3v1n0.net>
70+Date: Thu, 30 Aug 2018 07:11:24 +0200
71+Subject: search: Ignore search provider results metas if search is cancelled
72+
73+Call updateSearch callback with no results when the search provider has been
74+cancelled, without doing any logging.
75+
76+Bug-GNOME: https://gitlab.gnome.org/GNOME/gnome-shell/issues/183
77+Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/bionic/+source/gnome-shell/+bug/1756826
78+Forwarded: https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/205
79+---
80+ js/ui/search.js | 5 +++--
81+ 1 file changed, 3 insertions(+), 2 deletions(-)
82+
83+diff --git a/js/ui/search.js b/js/ui/search.js
84+index 804be95..dd4bfad 100644
85+--- a/js/ui/search.js
86++++ b/js/ui/search.js
87+@@ -227,8 +227,9 @@ var SearchResultsBase = new Lang.Class({
88+
89+ this.provider.getResultMetas(metasNeeded, metas => {
90+ if (metas.length != metasNeeded.length) {
91+- log('Wrong number of result metas returned by search provider ' + this.provider.id +
92+- ': expected ' + metasNeeded.length + ' but got ' + metas.length);
93++ if (!this._cancellable.is_cancelled())
94++ log(`Wrong number of result metas returned by search provider ${this.provider.id}` +
95++ `: expected ${metasNeeded.length} but got ${metas.length}`);
96+ callback(false);
97+ return;
98+ }
99diff --git a/debian/patches/series b/debian/patches/series
100index c198fe6..6833a31 100644
101--- a/debian/patches/series
102+++ b/debian/patches/series
103@@ -22,3 +22,7 @@ dnd-Nullify-_dragActor-after-we-ve-destroyed-it-and-avoid.patch
104 messageList-stop-syncing-if-closeButton-has-been-destroye.patch
105 automountManager-remove-allowAutorun-expire-timeout-on-vo.patch
106 workaround_crasher_fractional_scaling.patch
107+viewSelector-Cancel-search-on-overview-hidden.patch
108+search-Cancel-search-provider-operations-on-clear.patch
109+search-Ignore-search-provider-results-metas-if-search-is-.patch
110+ubuntu/search-call-XUbuntuCancel-method-on-providers-when-no-dat.patch
111diff --git a/debian/patches/ubuntu/search-call-XUbuntuCancel-method-on-providers-when-no-dat.patch b/debian/patches/ubuntu/search-call-XUbuntuCancel-method-on-providers-when-no-dat.patch
112new file mode 100644
113index 0000000..f601fd2
114--- /dev/null
115+++ b/debian/patches/ubuntu/search-call-XUbuntuCancel-method-on-providers-when-no-dat.patch
116@@ -0,0 +1,167 @@
117+From: =?utf-8?b?Ik1hcmNvIFRyZXZpc2FuIChUcmV2acOxbyki?= <mail@3v1n0.net>
118+Date: Thu, 23 Aug 2018 20:00:57 +0200
119+Subject: search: call XUbuntuCancel method on providers when no data is
120+ needed
121+
122+Add XUbuntuCancel method to search providers and call it when a search provider
123+is still doing operations.
124+Ignore the result when the method does not exist or is cancelled.
125+
126+This will allow to stop operations on providers.
127+
128+Fixes LP: #1756826
129+
130+Bug-GNOME: https://gitlab.gnome.org/GNOME/gnome-shell/issues/183
131+Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/bionic/+source/gnome-shell/+bug/1756826
132+Forwarded: not-needed
133+---
134+ data/org.gnome.ShellSearchProvider.xml | 6 ++++++
135+ data/org.gnome.ShellSearchProvider2.xml | 6 ++++++
136+ js/ui/remoteSearch.js | 15 +++++++++++++++
137+ js/ui/search.js | 34 +++++++++++++++++++++++++++++++++
138+ 4 files changed, 61 insertions(+)
139+
140+diff --git a/data/org.gnome.ShellSearchProvider.xml b/data/org.gnome.ShellSearchProvider.xml
141+index 78ad305..393cb01 100644
142+--- a/data/org.gnome.ShellSearchProvider.xml
143++++ b/data/org.gnome.ShellSearchProvider.xml
144+@@ -69,5 +69,11 @@
145+ <method name="ActivateResult">
146+ <arg type="s" name="identifier" direction="in" />
147+ </method>
148++
149++ <!--
150++ XUbuntuCancel:
151++ Cancel the current search operation
152++ -->
153++ <method name="XUbuntuCancel" />
154+ </interface>
155+ </node>
156+diff --git a/data/org.gnome.ShellSearchProvider2.xml b/data/org.gnome.ShellSearchProvider2.xml
157+index 9502340..8141bc0 100644
158+--- a/data/org.gnome.ShellSearchProvider2.xml
159++++ b/data/org.gnome.ShellSearchProvider2.xml
160+@@ -83,5 +83,11 @@
161+ <arg type="as" name="terms" direction="in" />
162+ <arg type="u" name="timestamp" direction="in" />
163+ </method>
164++
165++ <!--
166++ XUbuntuCancel:
167++ Cancel the current search operation
168++ -->
169++ <method name="XUbuntuCancel" />
170+ </interface>
171+ </node>
172+diff --git a/js/ui/remoteSearch.js b/js/ui/remoteSearch.js
173+index 3b847af..9245745 100644
174+--- a/js/ui/remoteSearch.js
175++++ b/js/ui/remoteSearch.js
176+@@ -31,6 +31,7 @@ const SearchProviderIface = `
177+ <method name="ActivateResult">
178+ <arg type="s" direction="in" />
179+ </method>
180++<method name="XUbuntuCancel" />
181+ </interface>
182+ </node>`;
183+
184+@@ -59,6 +60,7 @@ const SearchProvider2Iface = `
185+ <arg type="as" direction="in" />
186+ <arg type="u" direction="in" />
187+ </method>
188++<method name="XUbuntuCancel" />
189+ </interface>
190+ </node>`;
191+
192+@@ -312,6 +314,19 @@ var RemoteSearchProvider = new Lang.Class({
193+ cancellable);
194+ },
195+
196++ XUbuntuCancel(cancellable, callback) {
197++ this.proxy.XUbuntuCancelRemote((results, error) => {
198++ if (error &&
199++ !error.matches(Gio.DBusError, Gio.DBusError.UNKNOWN_METHOD) &&
200++ !error.matches(Gio.IOErrorEnum, Gio.IOErrorEnum.CANCELLED)) {
201++ log('Received error from DBus search provider %s during XUbuntuCancel: %s'.format(this.id, String(error)));
202++ } else if (callback && !error) {
203++ callback();
204++ }
205++ },
206++ cancellable);
207++ },
208++
209+ activateResult(id) {
210+ this.proxy.ActivateResultRemote(id);
211+ },
212+diff --git a/js/ui/search.js b/js/ui/search.js
213+index dd4bfad..629664e 100644
214+--- a/js/ui/search.js
215++++ b/js/ui/search.js
216+@@ -225,7 +225,9 @@ var SearchResultsBase = new Lang.Class({
217+ this._cancellable.cancel();
218+ this._cancellable.reset();
219+
220++ this.provider.resultsMetasInProgress = true;
221+ this.provider.getResultMetas(metasNeeded, metas => {
222++ this.provider.resultsMetasInProgress = this._cancellable.is_cancelled();
223+ if (metas.length != metasNeeded.length) {
224+ if (!this._cancellable.is_cancelled())
225+ log(`Wrong number of result metas returned by search provider ${this.provider.id}` +
226+@@ -450,6 +452,10 @@ var SearchResults = new Lang.Class({
227+
228+ this._searchTimeoutId = 0;
229+ this._cancellable = new Gio.Cancellable();
230++ this._searchCancelCancellable = new Gio.Cancellable();
231++ this._cancellable.connect(() => {
232++ this._cancelSearchProviderRequest();
233++ });
234+
235+ this._registerProvider(new AppDisplay.AppSearchProvider());
236+ this._reloadRemoteProviders();
237+@@ -491,11 +497,32 @@ var SearchResults = new Lang.Class({
238+ }
239+ },
240+
241++ _cancelSearchProviderRequest() {
242++ if (this._terms.length != 0 || this._searchCancelTimeoutId > 0)
243++ return;
244++
245++ this._searchCancelTimeoutId = GLib.timeout_add(GLib.PRIORITY_DEFAULT, 100, () => {
246++ this._providers.forEach(provider => {
247++ if (provider.isRemoteProvider &&
248++ (provider.searchInProgress || provider.resultsMetasInProgress)) {
249++ provider.XUbuntuCancel(this._searchCancelCancellable, () => {
250++ provider.searchInProgress = false;
251++ provider.resultsMetasInProgress = false;
252++ });
253++ }
254++ });
255++
256++ delete this._searchCancelTimeoutId;
257++ return GLib.SOURCE_REMOVE;
258++ });
259++ },
260++
261+ _reset() {
262+ this._terms = [];
263+ this._results = {};
264+ this._clearDisplay();
265+ this._clearSearchTimeout();
266++ this._cancelSearchProviderRequest();
267+ this._defaultResult = null;
268+ this._startingSearch = false;
269+
270+@@ -562,6 +589,13 @@ var SearchResults = new Lang.Class({
271+ if (this._terms.length > 0)
272+ isSubSearch = searchString.indexOf(previousSearchString) == 0;
273+
274++ this._searchCancelCancellable.cancel();
275++ this._searchCancelCancellable.reset();
276++ if (this._searchCancelTimeoutId > 0) {
277++ GLib.source_remove(this._searchCancelTimeoutId);
278++ delete this._searchCancelTimeoutId;
279++ }
280++
281+ this._terms = terms;
282+ this._isSubSearch = isSubSearch;
283+ this._updateSearchProgress();
284diff --git a/debian/patches/viewSelector-Cancel-search-on-overview-hidden.patch b/debian/patches/viewSelector-Cancel-search-on-overview-hidden.patch
285new file mode 100644
286index 0000000..e69ae1e
287--- /dev/null
288+++ b/debian/patches/viewSelector-Cancel-search-on-overview-hidden.patch
289@@ -0,0 +1,36 @@
290+From: =?utf-8?b?Ik1hcmNvIFRyZXZpc2FuIChUcmV2acOxbyki?= <mail@3v1n0.net>
291+Date: Thu, 23 Aug 2018 16:11:10 +0200
292+Subject: viewSelector: Cancel search on overview hidden
293+
294+Currently when the overview is hidden, any pending search is kept alive, not only
295+at remote search provider level (as per issue #183), but even the shell providers
296+proxies continue to get and process data. This happens even if this is not needed
297+anymore, while the UI reset is performed only next time that the overview is
298+shown (causing some more computation presentation time).
299+
300+In order to stop this to happen, when the overview is hidden, we have to unset
301+the search entry to an empty value as this would make SearchResults to have empty
302+terms list and that would make the proxies cancellable to be triggered (without
303+causing any further search to start).
304+
305+https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/205
306+
307+Bug-GNOME: https://gitlab.gnome.org/GNOME/gnome-shell/issues/183
308+Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/bionic/+source/gnome-shell/+bug/1756826
309+Forwarded: https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/205
310+---
311+ js/ui/viewSelector.js | 1 +
312+ 1 file changed, 1 insertion(+)
313+
314+diff --git a/js/ui/viewSelector.js b/js/ui/viewSelector.js
315+index 2d5c33f..c650886 100644
316+--- a/js/ui/viewSelector.js
317++++ b/js/ui/viewSelector.js
318+@@ -311,6 +311,7 @@ var ViewSelector = new Lang.Class({
319+ },
320+
321+ hide() {
322++ this.reset();
323+ this._workspacesDisplay.hide();
324+ },
325+

Subscribers

People subscribed via source and target branches