perf: return raw bytes from GetItemContent instead of base64

The D-Bus interface previously returned content as a base64-encoded
string (type 's'), requiring the daemon to encode and GJS to decode
on every paste. D-Bus natively supports byte arrays (type 'ay'),
eliminating both encode and decode steps entirely.

Changes:
- dbus_service.rs: return (String, Vec<u8>); drop base64 calls
- dbus.js: content_b64 arg changed from type 's' to type 'ay'
- panel.js: remove GLib.base64_decode(); pass ay bytes directly
- Cargo.toml/Cargo.lock: remove base64 dependency (no longer used)

For a 1 MB text paste this avoids allocating a 1.33 MB intermediate
string and decoding it on the compositor main thread.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
Eduard Tolosa 2026-05-25 04:00:06 -05:00
parent 40a9a3bbd5
commit f9826c63a8
5 changed files with 11 additions and 19 deletions

View file

@ -30,9 +30,9 @@ const STRATA_IFACE_XML = `
</method>
<method name="GetItemContent">
<arg type="s" direction="in" name="id"/>
<arg type="s" direction="out" name="mime_type"/>
<arg type="s" direction="out" name="content_b64"/>
<arg type="s" direction="in" name="id"/>
<arg type="s" direction="out" name="mime_type"/>
<arg type="ay" direction="out" name="content"/>
</method>
<method name="SetClipboard">

View file

@ -471,8 +471,8 @@ export class StrataPanel {
async _onItemActivated(id) {
try {
const [mimeType, contentB64] = await this._proxy.GetItemContentAsync(id);
this._writeToClipboard(mimeType, GLib.base64_decode(contentB64));
const [mimeType, content] = await this._proxy.GetItemContentAsync(id);
this._writeToClipboard(mimeType, content);
} catch (e) {
console.error('[Strata] Paste error:', e);
}