Skip to content

Conversation

@ids1024
Copy link
Contributor

@ids1024 ids1024 commented May 31, 2025

This seems like the simplest way to address #1111.

Before this, a PropertyStream created when a service wasn't running would never yield a value, even if the service started later and send property change signals.

But if a service stopped, and then was restarted, property changes would be received.

It seems PropertiesCache::init() was returning an error, from trying to call GetAll with a destination that doesn't exist.

Instead, let init() complete successfully (without populating the cache), so it returns a PropertiesChangedStream which is then monitored for changes.

It may also be good if it yielded values when a service takes ownership of the name, but that's a separate issue since it also applies to service restarts. And an application can handle OwnerChanged itself relatively easily.

ids1024 added a commit to pop-os/cosmic-settings-subscriptions that referenced this pull request May 31, 2025
Send events is settings daemon is started after the start of this
subscription, or if it is restarted.

To get updates when the daemon wasn't running at the start of the
stream, z-galaxy/zbus#1389 is also needed.

Loss of the name owner should probably also disable any brightness
controls, but if that's done by a change of the brightness values and
not by a seperate property, we probably can't rely on the ordering of
events from different streams...
@ids1024
Copy link
Contributor Author

ids1024 commented Jun 11, 2025

Seems to be working with that updating. (It would be nice if box patterns where stable...).

@zeenix
Copy link
Contributor

zeenix commented Jun 13, 2025

Seems to be working with that updating.

Nice!

(It would be nice if box patterns where stable...).

Right. Could you please add a FIXEM comment pointing to the relevant issue?

@ids1024
Copy link
Contributor Author

ids1024 commented Jun 17, 2025

Added a comment. rust-lang/rust#29641 has been open since 2015, but apparently rust-lang/rust#87121 supersedes that, so maybe it will actually be stable this decade.

@zeenix
Copy link
Contributor

zeenix commented Jun 21, 2025

@ids1024 the CI is failing. I think something goes wrong with the error conversion. Could you please have a look?

@ids1024
Copy link
Contributor Author

ids1024 commented Jun 23, 2025

With the error conversion commit, the basic_connection and basic_connection_async tests need to be updated to check for Error::FDO instead of Error::MethodError.

But then there's the error_from_zerror test. Instead of the expected fdo::Error::TimedOut("so long"), it's getting fdo::Error::ZBus::FDO(zbus::Error::FDO(fdo::Error::TimedOut("so long")))...

Because we already converted FDO error variants, and the DBusError macro used to define the conversion from zbus::fdo::Error doesn't handle the zbus::Error::FDO case, and just packs that into fdo::Error::ZBus.

Presumably changing that would require either a manual implementation of From<zbus::Error> that also handles the FDO case, or a special case in the macro. Though I don't know if this error conversion is likely to causes issues anywhere in general.

@zeenix
Copy link
Contributor

zeenix commented Jun 24, 2025

fdo::Error::ZBus::FDO(zbus::Error::FDO(fdo::Error::TimedOut("so long")))

Hmm.. this shouldn't be happening. This is what I was hoping to avoid with this part of my suggestion:

unless the conversion ends up with the fall-through fdo::Error::ZBus variant, in which case we discard the fdo::Error and keep the original Error.

@zeenix
Copy link
Contributor

zeenix commented Sep 2, 2025

@ids1024 do you intend to continue this work?

@zeenix
Copy link
Contributor

zeenix commented Nov 2, 2025

@ids1024 do you intend to continue this work?

I guess not. 😢

@ids1024 ids1024 force-pushed the property-stream branch 2 times, most recently from faaf8b8 to e56d01d Compare November 4, 2025 04:02
@codspeed-hq
Copy link

codspeed-hq bot commented Nov 4, 2025

CodSpeed Performance Report

Merging #1389 will not alter performance

Comparing ids1024:property-stream (b6d49c3) with main (b5515a9)

Summary

✅ 22 untouched

@ids1024
Copy link
Contributor Author

ids1024 commented Nov 4, 2025

Well, if changing the definition of From<zbus::Error> for fdo::Error to have a branch handling Error::FDO is the correct way to do things, that's demonstrated by copying the expanded DBusError macro code and modifying the From impl.

I guess the only not painfully verbose way to do that would be to add some kind of special case in the DBusError macro...

@ids1024 ids1024 force-pushed the property-stream branch 3 times, most recently from b1a18fe to 55ea2cd Compare November 4, 2025 04:23
@ids1024
Copy link
Contributor Author

ids1024 commented Nov 4, 2025

It doesn't seem too hard to add a special case in the macro, using an internal boolean attribute parameter.

@ids1024 ids1024 force-pushed the property-stream branch 2 times, most recently from 44bc041 to 56d8687 Compare November 4, 2025 04:48
@zeenix
Copy link
Contributor

zeenix commented Nov 4, 2025

@ids1024 Thanks so much for picking this up again! Although I pinged you (was just doing a quick old PR triage), I can't seem to remember exact details here so I'll have to re-read the discussion when I'm not tired (hopefully tomorrow morning). :)

When converting a `Error` to a `fdo::Error`, map `Error::FDO`
specially, instead of ending up with an
`fdo::Error::ZBus(zbus::Error::FDO(fdo::Error::...))`

This is implemented as a special case in the `DBusError` macro, using an
attribute specific to this usage.
This seems like the simplest way to address
z-galaxy#1111.

Before this, a `PropertyStream` created when a service wasn't running
would never yield a value, even if the service started later and send
property change signals.

But if a service stopped, and then was restarted, property changes would
be received.

It seems `PropertiesCache::init()` was returning an error, from trying
to call `GetAll` with a destination that doesn't exist.

Instead, let `init()` complete successfully (without populating the
cache), so it returns a `PropertiesChangedStream` which is then
monitored for changes.

It may also be good if it yielded values when a service takes ownership
of the name, but that's a separate issue since it also applies to
service restarts. And an application can handle `OwnerChanged` itself
relatively easily.
@ids1024
Copy link
Contributor Author

ids1024 commented Nov 17, 2025

Added a comment on the special case in zbus_macros, and added a little more detail to the comment in the error conversion code. Presumably 🐛 is appropriate for all three commits, since it seems like a correction to how one might expect things would already work.

@ids1024 ids1024 requested a review from zeenix November 19, 2025 03:53
@zeenix
Copy link
Contributor

zeenix commented Nov 20, 2025

Sorry for the delay in reviewing. I've been drowning in work-work lately. 😭

Added a comment on the special case in zbus_macros, and added a little more detail to the comment in the error conversion code.

Thank you!

Presumably 🐛 is appropriate for all three commits, since it seems like a correction to how one might expect things would already work.

Thanks for adding that but only the last commit is a bug fix so 🐛 doesn't seem appropriate for the other 2. Better candidates: 🥅 🚸.

Otherwise we're ready to merge.

@zeenix
Copy link
Contributor

zeenix commented Nov 20, 2025

Otherwise we're ready to merge.

Spoke too soon. I just realised we're missing a test case here. Would it be possible for you to add one?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants