Closed Bug 1369119 Opened 9 years ago Closed 9 years ago

Disconnected and removed devices still listed in the 'Send Tab to Devices'

Categories

(Firefox :: Sync, defect, P1)

defect

Tracking

()

RESOLVED FIXED
Firefox 56
Tracking Status
firefox55 --- wontfix
firefox56 --- fixed

People

(Reporter: aaronmt, Assigned: eoger)

Details

Attachments

(1 file)

55.0a1 (2017-05-31) (64-bit) => Disconnect and remove all remote devices => Right click on a tab, send tab to device: see devices Expected: Inability to perform such a task Actual: Menu of remote devices still available despite them being disconnected Work-around to rid that menu: restart the browser As a user, if I remove a disconnected device, I don't want to see remnants of it still in the browser UI.
Flags: needinfo?(eoger)
(in a similar realm of things, might be of interest also seeing https://bugzilla.mozilla.org/show_bug.cgi?id=1369116 for iOS)
Bug 1339861 fixes the stale devices problem, but needs a restart to rebuild that filter list. https://github.com/mozilla/fxa-auth-server/issues/1777 paves the way to solution (1) by sending the push "disconnect" notification to every device of the account. So now there's 2 things we can do: (1) Refresh the filter list when we receive a disconnect notification. (2) Refresh the filter list every sync (that's what Android is heading to). However, even if we do this, solution 1 helps between syncs.
Flags: needinfo?(eoger)
Priority: -- → P2
Assignee: nobody → eoger
Status: NEW → ASSIGNED
Priority: P2 → P1
Comment on attachment 8874934 [details] Bug 1369119 - Refresh known stale devices list on FxA device disconnect. https://reviewboard.mozilla.org/r/146318/#review150952 ::: services/fxaccounts/FxAccountsPush.js:171 (Diff revision 1) > switch (payload.command) { > case ON_DEVICE_CONNECTED_NOTIFICATION: > Services.obs.notifyObservers(null, ON_DEVICE_CONNECTED_NOTIFICATION, payload.data.deviceName); > break; > case ON_DEVICE_DISCONNECTED_NOTIFICATION: > + Services.obs.notifyObservers(null, ON_DEVICE_DISCONNECTED_NOTIFICATION); Now that I think about it, that seems wrong to me, we should only fire this notification (or do something in the observer) if the deviceID is different that ours.
Comment on attachment 8874934 [details] Bug 1369119 - Refresh known stale devices list on FxA device disconnect. https://reviewboard.mozilla.org/r/146318/#review151072 The observer doesn't work (so it looks like you didn't test the most recent version;). Please fix that and adjust the new test to pick that up (ie, check isLocalDevice is unpacked correctly) ::: browser/components/nsBrowserGlue.js:368 (Diff revision 2) > break; > case "fxaccounts:device_connected": > this._onDeviceConnected(data); > break; > case "fxaccounts:device_disconnected": > + if (data.isLocalDevice) { Data is a string, so this doesn't work. ::: services/fxaccounts/FxAccounts.jsm:1571 (Diff revision 2) > - } > - if (deviceId == localDeviceId) { > - this.notifyObservers(ON_DEVICE_DISCONNECTED_NOTIFICATION); > - return this.signOut(true); > - } > + } > + Services.obs.notifyObservers(null, ON_DEVICE_DISCONNECTED_NOTIFICATION, { isLocalDevice }); You probably want `this._notifyObservers` - but data is a string - it sucks that this doesn't fail, but the string the notification gets is "[object Object]", so this isn't doing what you expect. Passing data will require passing an object as *subject* with a wrappedJSObject value, and the other end will need to unpack it via wrappedJSObject. `this._notifyObservers` doesn't support a subject param, so calling Services.obs... is fine if you go that route. ::: services/fxaccounts/FxAccounts.jsm:1584 (Diff revision 2) > if (!localUid) { > log.info(`Account destroyed push notification received, but we're already logged-out`); > return null; > } > if (uid == localUid) { > - this.notifyObservers(ON_DEVICE_DISCONNECTED_NOTIFICATION); > + this.notifyObservers(ON_DEVICE_DISCONNECTED_NOTIFICATION, { isLocalDevice: true }); ditto here - the 2nd arg is a string ::: services/fxaccounts/tests/xpcshell/test_push_service.js:190 (Diff revision 2) > QueryInterface() { > return this; > } > }; > - let customAccounts = Object.assign(mockFxAccounts, { > - handleDeviceDisconnection() { > + > + const handleDeviceDisconnectionObserved = new Promise(resolve => { this test should ensure both the logic for isLocalDevice works correctly and also that the isLocalDevice flag moves across the observer boundaries correctly. ::: services/sync/modules/service.js:419 (Diff revision 2) > } > break; > + case "fxaccounts:device_disconnected": > + if (!data.isLocalDevice) { > + this.clientsEngine.refreshKnownStaleClients(); > + this.sync([]); // [] = clients collection only why do we need to sync here? ::: services/sync/tests/unit/test_clients_engine.js:1562 (Diff revision 2) > + engine._processIncoming(); > + equal(calls, 1, "Should not refresh the known stale clients since it's already populated"); > + > + engine.refreshKnownStaleClients = origRefreshKnownStaleClients; > + SyncEngine.prototype._processIncoming = origSuperProcessIncoming; > +}); We should also check that sending the notifcation causes refreshKnownStaleClients to be called (ie, this seems to be the test that should have been included when `_refreshKnownStaleClients` first landed rather than a test for the changes made in this patch.
Attachment #8874934 - Flags: review?(markh) → review-
Comment on attachment 8874934 [details] Bug 1369119 - Refresh known stale devices list on FxA device disconnect. https://reviewboard.mozilla.org/r/146318/#review151072 > why do we need to sync here? The actual filtering of the clients records is made in _processIncoming, which is why I'm forcing a sync.
Comment on attachment 8874934 [details] Bug 1369119 - Refresh known stale devices list on FxA device disconnect. https://reviewboard.mozilla.org/r/146318/#review152640 Passing json as data is quite unusual, but I guess that's OK. I do however think we should skip the sync because that is extra work for no real benefit that might still not work as expected if we are already syncing. ::: services/sync/modules/engines/clients.js:330 (Diff revision 3) > // Fetch all records from the server. > this.lastSync = 0; > this._incomingClients = {}; > try { > SyncEngine.prototype._processIncoming.call(this); > // Refresh the known stale clients list once per browser restart We should tweak this comment as it is now a little misleading (ie, it should say something like "We refresh at startup and also on a device disconnection notification" or similar) ::: services/sync/modules/service.js:420 (Diff revision 3) > break; > + case "fxaccounts:device_disconnected": > + data = JSON.parse(data); > + if (!data.isLocalDevice) { > + this.clientsEngine.refreshKnownStaleClients(); > + this.sync([]); // [] = clients collection only Doing a sync here seems a little heavy-handed, when all we need to do is set a record.stale = true, especially as we might already be syncing something else so would not immediately remove the client in that case. How about we leave `_refreshKnownStaleClients` as a private method, and add a new public method, say, updateKnownStateClients that does both the `_refresh`, and iterates over `_remoteClients[]` setting the stale flag?
Attachment #8874934 - Flags: review?(markh)
Fixed the UIState test failing. I also realized that in some cases UIState could return a half-assed state object, which should be fixed.
Comment on attachment 8874934 [details] Bug 1369119 - Refresh known stale devices list on FxA device disconnect. https://reviewboard.mozilla.org/r/146318/#review154928 Thanks!
Attachment #8874934 - Flags: review?(markh) → review+
Pushed by eoger@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/302073cb4a3c Refresh known stale devices list on FxA device disconnect. r=markh
Status: ASSIGNED → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 56
Do we need this fix in beta55?
Flags: needinfo?(eoger)
It's probably not that urgent, restarting the browser will refresh the "Send Tab to Devices" list.
Flags: needinfo?(eoger)
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: