Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tmds.DBus.Protocol.DBusException: org.freedesktop.DBus.Error.ServiceUnknown: The name com.canonical.AppMenu.Registrar was not provided by any .service files #17616

Open
xecrets opened this issue Nov 26, 2024 · 4 comments
Labels
bug help-wanted A contribution from the community would be most welcome. os-linux

Comments

@xecrets
Copy link

xecrets commented Nov 26, 2024

Describe the bug

Intermittently, at an indeterminate time after successful startup and use, an Avalonia UI app running on Linux (Ubuntu 22.04 and/or 24.04), crashes with the following stack trace:

System.AggregateException: A Task's exception(s) were not observed either by Waiting on the Task or accessing its Exception property. As a result, the unobserved exception was rethrown by the finalizer thread. (org.freedesktop.DBus.Error.ServiceUnknown: The name com.canonical.AppMenu.Registrar was not provided by any .service files)
 ---> Tmds.DBus.Protocol.DBusException: org.freedesktop.DBus.Error.ServiceUnknown: The name com.canonical.AppMenu.Registrar was not provided by any .service files
   at Tmds.DBus.Protocol.DBusConnection.CallMethodAsync(MessageBuffer)
   at Tmds.DBus.Protocol.Connection.CallMethodAsync(MessageBuffer)

The exception is caught at the top level of the application, but since the app has no way of knowing what this is about, it does what any sensible app does - logs it and exits.

(This can well happen to other apps without them realizing what's happening - if you're not catching all uncaught exceptions at the top, the app will just quietly die without giving any indication of what happened)

This seems somewhat related to #4175 which was closed with a comment from @kekekeks stating:

You can ignore that, it means that your DE doesn't support dbusmenu protocol and the app will fall back to in-window menu.

Which doesn't seem entirely correct in this case. The app works fine apart from this, and the menus are where expected. It just crashes with this exception every now and then.

It does not appear to happen when running in debug mode directly from VS Code on the target Linux system, but does happen when running a Release build packaged as a self contained single file app. Then again, as it's so intermittent, it's hard to be really sure.

To Reproduce

It's very hard to reproduce, as it's intermittent, so it's quite hard to trim down to a simple example. Possibly I can see a correlation between this happening and the OS being recently booted, or woken up from suspension, but I can't be sure. I have not been able to correlate it to anything particular being done with the app. It just suddenly dies.

Expected behavior

I'd expect the app to be stable and not crash with this exception intermittently.

Avalonia version

11.2.0

OS

Linux

Additional context

No response

@nARN
Copy link

nARN commented Dec 20, 2024

With all fairness, I've seen it 3 times so far, so it's not as intermittent for me. If I continue seeing it reasonably often I can try and get more debugging info, though I'm not very familiar with .NET and will need some guidance if so.

@kekekeks
Copy link
Member

Are you manually crashing the app by subscribing to TaskScheduler.UnobservedTaskException? By default the runtime simply ignores exceptions thrown in this manner. You can check the exception text for com.canonical.AppMenu.Registrar and ignore the exception.

We could potentially try finding which particular call failed and wrapping it into some fire-and-forget handler, but that would require some time.

@BldgBlocks
Copy link

I get this exact exception but I wasn't getting the info about the name of the service and spent a long time chasing until I ran dbus-monitor and got meaningful info. I was already logging from TaskScheduler.UnobservedTaskException and flattening the exceptions to get all the info into the log. It happens all the time, I was trying to avoid making some kind of ignore till I knew what was going on.

Running Arch Linux with Hyprland. App works fine.
AI Generated analysis of output.
Here's a breakdown of the dbus-monitor output relevant to sender :1.498:

Overview:
Sender :1.498: This is likely your application or a part of it communicating via D-Bus. The 1.498 is a unique identifier for a connection on the bus.

Detailed Explanation:

1. Signal: LayoutUpdated
Path: /net/avaloniaui/dbusmenu/<unique_id>
Interface: com.canonical.dbusmenu
Member: LayoutUpdated
Parameters:
uint32 2: Possibly an identifier or a version number for the menu layout.
int32 0: Likely a status code or an indicator of some kind.

This signal suggests that the menu structure or content associated with that path has been updated. It's broadcasting this information to anyone who might be listening, as indicated by the (null destination).

2. Method Call: RegisterWindow
Path: /com/canonical/AppMenu/Registrar
Interface: com.canonical.AppMenu.Registrar
Member: RegisterWindow
Parameters:
uint32 <window_id>: The window ID being registered, like 16777299, 16777303, or 16777307.
object path "/net/avaloniaui/dbusmenu/<unique_id>": The path to the menu object for this window.

The application is attempting to register a window with an app menu service. This is typically done to integrate the application's menu into a global menu system like AppMenu in some desktop environments.

3. Error: ServiceUnknown
Error Name: org.freedesktop.DBus.Error.ServiceUnknown
Message: "The name is not activatable"

Each RegisterWindow attempt results in this error. This error indicates that the service com.canonical.AppMenu.Registrar is not available or cannot be started. This might happen if:
The AppMenu service is not running or not installed.
The application is running in an environment where AppMenu isn't supported (e.g., a different desktop environment like GNOME instead of Unity).
There's a configuration issue preventing the service from being activated.

4. Method Call: UnregisterWindow
Path: Same as RegisterWindow
Interface: Same as RegisterWindow
Member: UnregisterWindow
Parameters:
uint32 16777303: The window ID to unregister.

This call attempts to unregister a previously registered window, but again, it encounters the same ServiceUnknown error, suggesting that the com.canonical.AppMenu.Registrar service is not available.

@timunie
Copy link
Contributor

timunie commented Jan 4, 2025

You may want to add your repo to src/samples/sandbox and see if you can add a break point or something. Could be an option to solve the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug help-wanted A contribution from the community would be most welcome. os-linux
Projects
None yet
Development

No branches or pull requests

6 participants