Possible races when using lenses

Bug #936976 reported by Michal Hruby
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Unity
Confirmed
Low
Unassigned
libunity
New
Undecided
Unassigned
libunity (Ubuntu)
New
Undecided
Unassigned
unity (Ubuntu)
New
Undecided
Unassigned

Bug Description

There are currently possible races when using lenses - currently a lens will emit the "Changed" signal once it starts up which basically contains all properties of a lens - that means there's time between getting an active GDBusProxy and receiving the "Changed" signal when things can go wrong.

To fix this issue we should be using dbus properties which are automatically read when getting a proxy and readily available after g_dbus_proxy_new_finish call. This will also allow us to get rid of the InfoRequest() method.

Michal Hruby (mhr3)
Changed in libunity:
assignee: nobody → Michal Hruby (mhr3)
Michal Hruby (mhr3)
Changed in unity:
status: New → Confirmed
assignee: nobody → Michal Hruby (mhr3)
importance: Undecided → Low
milestone: none → 5.6.0
Changed in unity:
milestone: 5.6.0 → 5.8.0
Revision history for this message
Mikkel Kamstrup Erlandsen (kamstrup) wrote :

I don't see how the two solutions differ. They both require an async dbus call to fully set up the proxy... InfoRequest() or GetProperties(), sure one is automated by gdbus, but breaking wire protocol just for that seems like a steep price for no real gain..?

Revision history for this message
Michal Hruby (mhr3) wrote :

They do differ, because as you said GetAll() is automatically done by gdbus (even now, so there'd be fewer context switches!), so we get rid of the time where a lens proxy is half-initialized ie connected but not knowing if it should search in home view, is visible, etc.

Moreover we don't need to break the wire protocol, the InfoRequest method can stay, but we won't use it.

Revision history for this message
Mikkel Kamstrup Erlandsen (kamstrup) wrote :

Oh, now I get it. I was expecting InfoRequest() to return the same values as passed in the Changed() signal.

But basically InfoRequest() is just a dummy to DBus activate the lens I guess. We could probably just have used a standard DBus Peer.Ping() message for that in stead.

IIRC the reason we have it like this is because we didn't want to force the lenses to populate all properties right on the spot when they were activated. Unity can pre-render a dummy with the info from the .lens file. This is to relieve some IO stress on startup. By having a signal as the only mechanism for this the lenses have some wiggle room in how they start up.

AND! If we're really keen on shaving off context switches I'd rather drop the idea of subscribing to Changed() on each lens proxy, but simply have one single DBus match rule to catch them all (just like pokemon - you gotta catch them all!). Ie. AddMatch("type='signal',interface='com.canonical.Unity.Lens',member='Changed'")

Revision history for this message
Michal Hruby (mhr3) wrote :

> IIRC the reason we have it like this is because we didn't want to force the lenses to populate all properties right on the spot when they were activated.

That would be pretty dangerous - it'd imply that lenses are fully operational only after a InfoRequest() call, but because of dbus-activation the first method call can easily be Search() or even Activate(uri).

> AND! If we're really keen on shaving off context switches I'd rather drop the idea of subscribing to Changed() on each lens proxy, but simply have one single DBus match rule to catch them all (just like pokemon - you gotta catch them all!). Ie. AddMatch("type='signal',interface='com.canonical.Unity.Lens',member='Changed'")

Using standard dbus-properties and their change notification signal would probably fix this automagically.

Revision history for this message
Michal Hruby (mhr3) wrote :

> Using standard dbus-properties and their change notification signal would probably fix this automagically.

But ultimately the Changed signal isn't really needed in most cases, most lenses won't change any of the properties after initially setting them.

Changed in unity:
milestone: 5.8.0 → 5.10.0
Changed in unity:
milestone: 5.10.0 → 5.12.0
Changed in unity:
milestone: 5.12.0 → 5.14.0
Changed in unity:
milestone: 5.14.0 → 5.16.0
Changed in unity:
milestone: 5.16.0 → 5.18.0
Changed in unity:
milestone: 5.18.0 → 7.0.0
Stephen M. Webb (bregma)
Changed in unity:
milestone: 7.0.0 → 7.0.1
Changed in unity:
milestone: 7.0.1 → 7.3.1
Stephen M. Webb (bregma)
Changed in unity:
milestone: 7.3.1 → 7.3.2
Stephen M. Webb (bregma)
Changed in unity:
milestone: 7.3.2 → 7.3.3
Changed in unity:
assignee: Michal Hruby (mhr3) → nobody
Changed in libunity:
assignee: Michal Hruby (mhr3) → nobody
Changed in unity:
milestone: 7.3.3 → none
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.