Nota — a free DAW for macOS, Windows and Linux. No subscription, no account — just open it and make music.
C# audioaudio-unitavaloniacpp20cross-platformdawdigital-audio-workstationdspjucelinux-audiomcp-servermidimusicmusic-productionpiano-rollplugin-hostsequencersynthesizervstvst3
(fix) Silence benign IBus D-Bus errors spamming the Linux system log (#175)
Egor Khindikaynen71d4ac80daf0
diff --git a/.specify/bugs/linux-ibus-log-spam/assessment.md b/.specify/bugs/linux-ibus-log-spam/assessment.mdnew file mode 100644index 00000000..6bb3265a--- /dev/null+++ b/.specify/bugs/linux-ibus-log-spam/assessment.md@@ -0,0 +1,118 @@+# Bug Assessment: dbus errors spam syslog++- **Slug**: linux-ibus-log-spam+- **Created**: 2026-10-17+- **Source**: https://github.com/nota-daw/nota/issues/36 (fetched; host `github.com`, policy branch: `allowlisted`)+- **Verdict**: valid+- **Severity**: low (log noise only — no functional impact; but unbounded syslog/journal spam on affected Linux setups)++## Report (verbatim or summarized)++Issue title: "dbus errors spam syslog". Linux Mint 22.3 Cinnamon, Nota 0.53.1 built from+source; "running nota after compiling everything works as expected, but the syslog has+lots of entries like the following":++```+2026-10-14T19:56:38.876857+02:00 xxxxxxx Nota.App: [IME] Error while destroying the context:#012Tmds.DBus.Protocol.DBusException: org.freedesktop.DBus.Error.UnknownMethod: Method Destroy is not implemented on interface org.freedesktop.IBus.Service#012 at Tmds.DBus.Protocol.InnerConnection.MyValueTaskSource`1...#012 at Avalonia.FreeDesktop.DBusIme.DBusTextInputMethodBase.Dispose() (IBusX11TextInputMethod #22714424)+```++## Symptom++On Linux systems whose IBus daemon does not implement `Destroy` on+`org.freedesktop.IBus.Service` for portal-created input contexts, every dispose of an+Avalonia per-window IME client (each popup, tooltip and focus change gets one) logs a+full `Tmds.DBus.Protocol.DBusException` stack trace at Error level. Nota forwards+Avalonia logs to stderr via `.LogToTrace()`, and the desktop session journal captures+stderr — so the system log fills with repeated benign errors. Expected: no recurring+benign errors in the system log.++## Reproduction++1. Run Nota on a Linux desktop using IBus with the affected daemon build+ (reporter: Linux Mint 22.3 Cinnamon).+2. Use the app normally — open menus/popups/tooltips, move focus around.+3. Watch `journalctl` / syslog accumulate `[IME] Error while destroying the context:`+ entries.++[NEEDS CLARIFICATION: exact ibus daemon version/portal configuration that triggers the+`UnknownMethod` reply — not all distros are affected. The fix does not depend on it.]++## Suspected Code Paths++- `src/managed/Nota.App/Program.cs:26` — `.LogToTrace()` installs Avalonia's+ `TraceLogSink` as `Avalonia.Logging.Logger.Sink`; Error-level events go to stderr →+ journald.+- Third-party, outside this repo (verified against Avalonia master, 2026-10-17):+ - `src/Avalonia.FreeDesktop/DBusIme/IBus/IBusX11TextInputMethod.cs` —+ `DisconnectAsync() => _service?.DestroyAsync()` is the failing D-Bus call.+ - `src/Avalonia.FreeDesktop/DBusIme/DBusTextInputMethodBase.cs` — `Dispose()` and+ `QueueOnErrorAsync()` catch and log `"Error while destroying the context:\n" + ex`+ at `LogEventLevel.Error`, area `"IME"`, embedding the whole exception into the+ message template.+ - Tracked upstream: [AvaloniaUI/Avalonia#15551](https://github.com/AvaloniaUI/Avalonia/issues/15551)+ (open) and [#19917](https://github.com/AvaloniaUI/Avalonia/issues/19917) (closed as+ duplicate). Unfixed in master as of 12.1.4 — a package bump alone does not fix it.++## Root Cause Hypothesis++Avalonia bug, surfaced by Nota's default logging config. Avalonia creates a D-Bus IME+input context per X11 window; on teardown it calls `Destroy` on+`org.freedesktop.IBus.Service`, which some ibus builds (portal-created contexts) do not+implement, replying `org.freedesktop.DBus.Error.UnknownMethod`. Avalonia treats that as+an Error and logs the full stack every time; Nota's `.LogToTrace()` sink passes it to+stderr, which the user session's journal records as syslog entries. Confidence: high+(matching upstream reports + source inspection of Avalonia 12.1.4 / master).++## Proposed Remediation++**Preferred**: install a filtering log sink in `Program.BuildAvaloniaApp()`, right+after `.LogToTrace()`: read `Avalonia.Logging.Logger.Sink` and replace it with a small+delegating `ILogSink` that suppresses the known-benign IME dispose noise — area+`"IME"` AND message contains `"Error while destroying the context:"` AND the embedded+D-Bus error name is `org.freedesktop.DBus.Error.UnknownMethod` (optionally also+`...UnknownObject`, the "context already gone" twin seen in upstream reports) — and+forwards everything else verbatim to the wrapped sink. `ILogSink` is a 3-member+interface (`IsEnabled` + two `Log` overloads); the exception text lives inside the+message template, so a cheap substring check suffices. The pattern can never match on+Windows/macOS, so the filter is inert there.++**Alternatives**:+- Drop all `"IME"`-area events (e.g. exclude the area from `LogToTrace`) — too broad;+ hides genuine failures ("Unable to create IME input context", "WatchNameOwner ...+ failed").+- Wait for an upstream Avalonia fix — this branch already bumps 12.0.3 → 12.1.4 and the+ bug is still in master; nothing to pick up.+- Disable the D-Bus IME (fall back to XIM) — regresses text input for IME users;+ unacceptable.++**Files likely to change**:+- `src/managed/Nota.App/Program.cs` (wrap the sink in the builder chain)+- `src/managed/Nota.App/<new file>` for the filtering sink (following the repo's+ one-class-per-file layout, AGPL header)+- `CHANGELOG.md` [Unreleased] Fixed entry++**Tests to add or update**:+- No managed unit-test project exists in the repo (`tests/` holds only the engine smoke+ test). Lock the fix in via an ad-hoc check in `/speckit-bug-test`: feed captured+ benign and non-benign message templates through the filter and assert drop/forward.+ Revisit a managed test project if one lands in the repo.++## Risks & Considerations++- Over-filtering: a future genuine destroy failure matching the pattern would be+ silenced. Mitigated by the narrow match (message prefix + specific D-Bus error names,+ `UnknownMethod` scoped to the destroy path).+- Ordering: the wrapper must be installed after `LogToTrace()` sets the sink. Doing it+ as the next fluent step in the same builder chain makes the order explicit; anything+ logging between the two calls is forwarded unfiltered (harmless).+- Upstream drift: if Avalonia rewords the message, the filter silently stops matching+ and the old behavior returns (fail-open). A code comment should link the upstream+ issue so the intent is discoverable.+- Observability: suppressed events are gone entirely rather than downgraded. Acceptable+ for a message with zero diagnostic value; note it in the changelog entry.++## Open Questions++- [NEEDS CLARIFICATION: which ibus builds/versions reply `UnknownMethod` for+ `org.freedesktop.IBus.Service.Destroy` — affects how many users see the spam, not the+ fix itself.]diff --git a/.specify/bugs/linux-ibus-log-spam/fix.md b/.specify/bugs/linux-ibus-log-spam/fix.mdnew file mode 100644index 00000000..eebf5263--- /dev/null+++ b/.specify/bugs/linux-ibus-log-spam/fix.md@@ -0,0 +1,77 @@+# Bug Fix: dbus errors spam syslog++- **Slug**: linux-ibus-log-spam+- **Fixed**: 2026-10-17+- **Assessment**: ./assessment.md+- **Status**: applied++## Summary++Added a filtering `ILogSink` wrapper installed right after `LogToTrace()` in+`Program.BuildAvaloniaApp()`. It drops the known-benign+`Error while destroying the context` IME errors — the D-Bus `UnknownMethod`/`UnknownObject`+replies some ibus builds give when Avalonia disposes an input context — so they no longer+reach stderr and through it the system log. Everything else is forwarded untouched.++## Changes++| File | Change | Notes |+|------|--------|-------|+| `src/managed/Nota.App/ImeLogNoiseFilter.cs` | added | `FilteringSink` (`ILogSink` decorator) + `WithImeLogNoiseFiltered()` `AppBuilder` extension |+| `src/managed/Nota.App/Program.cs` | modified | builder chain now ends `.LogToTrace().WithImeLogNoiseFiltered()` |+| `CHANGELOG.md` | modified | `[Unreleased]` → `Fixed` entry referencing nota-daw/nota#36 |++## Diff Highlights++```csharp+// Program.cs — install the filter right after the sink it wraps+ .LogToTrace()+ .WithImeLogNoiseFiltered();++// ImeLogNoiseFilter.cs — the suppression predicate (everything else passes through)+private static bool IsBenignNoise(string area, string? message) =>+ area == ImeArea+ && message is not null+ && message.StartsWith(DestroyContextMessage, StringComparison.Ordinal)+ && (message.Contains("org.freedesktop.DBus.Error.UnknownMethod", StringComparison.Ordinal)+ || message.Contains("org.freedesktop.DBus.Error.UnknownObject", StringComparison.Ordinal));+```++## Tests Added or Updated++- None in-repo: `tests/` holds only the engine smoke test, and no managed unit-test project+ exists (as the assessment noted). Locked in via an ad-hoc check instead — below.++## Local Verification++- Commands run: `dotnet build src/managed/Nota.App/Nota.App.csproj` → 0 errors+ (11 warnings, all pre-existing in unrelated files).+- Ad-hoc filter check — scratch console project (`/tmp/imefilter-check`) referencing+ `Nota.App.csproj`, installing the **compiled** `FilteringSink` over a recording sink and+ logging through the real `Avalonia.Logging.Logger.TryGet(...)?.Log(...)` path, exactly the+ way Avalonia's IME code logs:+ - the verbatim `UnknownMethod`/`Destroy` spam from the issue → **dropped**+ - the `UnknownObject` "context already gone" twin → **dropped**+ - a real IME failure ("Unable to create IME input context", `ServiceUnknown`) → forwarded+ - the same message under a different log area → forwarded+ - an IME destroy failure with a non-benign D-Bus error (`AccessDenied`) → forwarded+ - result: exactly 3 of 5 forwarded, in order, all assertions PASS, exit 0+- `scripts/build.sh` → full pipeline green: native engine (universal),+ `dotnet build Nota.sln -c Release`, `SMOKE TEST PASSED`.+- Manual checks: none possible on macOS — the IBus path only exists on Linux/X11; verified+ at the logging API boundary instead.++## Deviations from Assessment++None. The assessment's optional `UnknownObject` coverage was included (same benign+destroy path, locale-independent error name).++## Follow-ups++- Upstream is still unfixed (AvaloniaUI/Avalonia#15551). If a future Avalonia rewords the+ message, the filter silently stops matching and the old behavior returns (fail-open) —+ the code comment links the upstream issue for discoverability.+- A Linux user report confirming the syslog is now quiet would close the loop on+ nota-daw/nota#36.+- If more managed UI-layer logic accumulates, consider a managed unit-test project; the+ filter would be its first tenant.diff --git a/.specify/bugs/linux-ibus-log-spam/test.md b/.specify/bugs/linux-ibus-log-spam/test.mdnew file mode 100644index 00000000..711a00e5--- /dev/null+++ b/.specify/bugs/linux-ibus-log-spam/test.md@@ -0,0 +1,58 @@+# Bug Verification: dbus errors spam syslog++- **Slug**: linux-ibus-log-spam+- **Tested**: 2026-10-17+- **Assessment**: ./assessment.md+- **Fix**: ./fix.md+- **Result**: partial — every runnable check passes and the filter provably drops the exact+ message from the issue at the logging boundary, but the end-to-end reproduction+ (Nota running on Linux with the affected ibus daemon, watching the system log) could not+ be exercised on this macOS machine. Downgraded from `verified` for that reason alone.++## Summary++The fix holds everywhere it can be observed here: the verbatim syslog message from+nota-daw/nota#36 is dropped by the production `FilteringSink`, benign and non-benign+messages are correctly separated, and the full build + smoke-test pipeline is green.+No regressions found; final confirmation needs one run on an affected Linux + IBus setup.++## Checks Performed++| Check | Command / Action | Result | Notes |+|-------|------------------|--------|-------|+| Reproduction (post-fix), automated equivalent | scratch project `/tmp/imefilter-check`: compiled `FilteringSink` + real `Logger.TryGet(...)?.Log(...)` path, 5 messages | pass | verbatim issue message and its `UnknownObject` twin dropped; real IME error, other-area message, non-benign destroy error forwarded — exactly 3 of 5, in order |+| Reproduction (post-fix), end-to-end | Nota on Linux + IBus, watch `journalctl`/syslog | not-run | no Linux/IBus environment on this machine; needs a confirmation run on an affected setup |+| New / updated tests | none in-repo | not-run | no managed unit-test project exists (recorded in fix.md); the ad-hoc check above stands in |+| Regression suite | `./scripts/build.sh` (after all source changes) | pass | native engine + `dotnet build Nota.sln -c Release` + `SMOKE TEST PASSED` |+| Lint / type-check | via `dotnet build` (no separate lint configured) | pass | 0 errors; 11 warnings, all pre-existing in unrelated files |++## Output Excerpts++```+forwarded 3 messages (expected 3)+PASS forwarded[0] = 'IME: Unable to create IME input con'+PASS forwarded[1] = 'FreeDesktopPlatform: Error while destroying the con'+PASS forwarded[2] = 'IME: Error while destroying the con'+```++```+SMOKE TEST PASSED+==> Done. Run the app with: dotnet run --project src/managed/Nota.App+```++## Residual Risks++- No run on an actually affected Linux + IBus machine — the syslog being quiet end-to-end+ is proven by construction (the message the journal captured is dropped before the sink),+ not by observation.+- Upstream message drift: if Avalonia rewords `"Error while destroying the context:"`, the+ filter stops matching and the spam returns (fail-open, no crash).+- Only the destroy-context path is filtered; the separate `"Error:\n"` queue path seen in+ AvaloniaUI/Avalonia#19917 reports is deliberately still logged — it can carry real+ failures.++## Recommendation++Ship it: the code-level verification is complete and nothing runnable fails. Before closing+nota-daw/nota#36, have the reporter (or any Linux + IBus user) run a build with this fix+and confirm the syslog stays clean — that single data point upgrades this to `verified`.diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 4d78918f..b42d75d9 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -82,6 +82,12 @@ Entry categories: `Added`, `Changed`, `Fixed`, `Removed`.Windows and Linux) always starts a new track.### Fixed+- **No more benign IBus errors in the system log on Linux** (nota-daw/nota#36): with the+ IBus input method (Linux Mint with Cinnamon, some Ubuntu and Fedora setups), the system+ log filled up with `[IME] Error while destroying the context` entries — a harmless D-Bus+ quirk in how Avalonia disposes its input contexts, repeated for every popup and tooltip.+ Those known-harmless messages are now filtered out; every other error still reaches the+ log unchanged.- **A tempo set over MCP shows in the transport bar and is saved**: `set_tempo` (andanything driving it, such as a hardware controller) changed the tempo you hear, but theBPM field kept the old number, and saving, autosave and export used that stale tempo, sodiff --git a/src/managed/Nota.App/ImeLogNoiseFilter.cs b/src/managed/Nota.App/ImeLogNoiseFilter.csnew file mode 100644index 00000000..a4eca09d--- /dev/null+++ b/src/managed/Nota.App/ImeLogNoiseFilter.cs@@ -0,0 +1,63 @@+// SPDX-License-Identifier: AGPL-3.0-only+// Copyright (c) 2026 Egor Khindikaynen (Nota). See LICENSES/ for license terms.++using System;+using Avalonia;+using Avalonia.Logging;++namespace Nota.App;++/// <summary>Drops known-benign Linux IME errors on the floor before they reach the log+/// sink, so a harmless D-Bus quirk doesn't fill the user's system log. Install with+/// <see cref="WithImeLogNoiseFiltered"/> right after <c>LogToTrace</c>.</summary>+public static class ImeLogNoiseFilter+{+ /// <summary>The log area Avalonia's FreeDesktop D-Bus IME code logs under.</summary>+ private const string ImeArea = "IME";++ private const string DestroyContextMessage = "Error while destroying the context:";++ /// <summary>Wraps whatever sink Avalonia is currently logging to so the benign IME+ /// dispose errors are filtered out; everything else passes through untouched.</summary>+ public static AppBuilder WithImeLogNoiseFiltered(this AppBuilder builder)+ {+ if (Logger.Sink is not null)+ Logger.Sink = new FilteringSink(Logger.Sink);+ return builder;+ }++ private sealed class FilteringSink : ILogSink+ {+ private readonly ILogSink _inner;++ public FilteringSink(ILogSink inner) => _inner = inner;++ public bool IsEnabled(LogEventLevel level, string area) => _inner.IsEnabled(level, area);++ public void Log(LogEventLevel level, string area, object? source, string messageTemplate)+ {+ if (!IsBenignNoise(area, messageTemplate))+ _inner.Log(level, area, source, messageTemplate);+ }++ public void Log(LogEventLevel level, string area, object? source, string messageTemplate,+ params object?[] propertyValues)+ {+ if (!IsBenignNoise(area, messageTemplate))+ _inner.Log(level, area, source, messageTemplate, propertyValues);+ }++ // Some ibus builds don't implement Destroy on org.freedesktop.IBus.Service for+ // portal-created input contexts, replying UnknownMethod (or UnknownObject when the+ // context is already gone). Avalonia logs that failure at Error level every time a+ // popup, tooltip or focus change disposes its IME client (AvaloniaUI/Avalonia#15551,+ // nota-daw/nota#36), which floods stderr and with it the system log. The message+ // carries no diagnostic value, so it is dropped rather than forwarded.+ private static bool IsBenignNoise(string area, string? message) =>+ area == ImeArea+ && message is not null+ && message.StartsWith(DestroyContextMessage, StringComparison.Ordinal)+ && (message.Contains("org.freedesktop.DBus.Error.UnknownMethod", StringComparison.Ordinal)+ || message.Contains("org.freedesktop.DBus.Error.UnknownObject", StringComparison.Ordinal));+ }+}diff --git a/src/managed/Nota.App/Program.cs b/src/managed/Nota.App/Program.csindex 50030ba7..05f83af3 100644--- a/src/managed/Nota.App/Program.cs+++ b/src/managed/Nota.App/Program.cs@@ -23,5 +23,6 @@ class Program.WithDeveloperTools()#endif.WithNotaFonts()- .LogToTrace();+ .LogToTrace()+ .WithImeLogNoiseFiltered();}