Skip to content

feat: Add external stamp generator support for Android#38

Open
torlando-tech wants to merge 1 commit intomarkqvist:masterfrom
torlando-tech:feature/external-stamp-generator
Open

feat: Add external stamp generator support for Android#38
torlando-tech wants to merge 1 commit intomarkqvist:masterfrom
torlando-tech:feature/external-stamp-generator

Conversation

@torlando-tech
Copy link
Copy Markdown

I ran into issues with multiprocessing in chaquopy where stamp generation would fail due to Android's aggressive process culling. I explored changing python's multiprocessing to threads, but it seems there is some GIL limitation that results in only one thread running at a time, which greatly slows it down.

This change lets Columba do stamp generation in Kotlin, which ends up roughly twice as fast as the python version.

No worries if you'd rather not merge this (or do it differently!), I don't mind maintaining a fork for Columba.

Thank you!

Add set_external_generator() function to LXStamper.py that allows
platforms like Android to provide a native stamp generator callback.
This bypasses Python multiprocessing which fails on Android due to
lack of sem_open support and aggressive process killing.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@markqvist
Copy link
Copy Markdown
Owner

Great idea. I'll look at merging this during the next round of work on LXMF, and should have it ready for the next release. Hope you can just use it internally in Columba until then.

torlando-tech added a commit to torlando-tech/lxmf-conformance that referenced this pull request Apr 28, 2026
Replaces the prior raw monkey-patch of LXStamper.generate_stamp with a
call to the upstream-blessed registration hook
(LXStamper.set_external_generator, added in markqvist/LXMF#38, available
on torlando-tech/LXMF feature/external-stamp-generator since 2025-12).

This is the same hook Columba uses on Android via Chaquopy to delegate
proof-of-work to a native Kotlin callback (see
release/v0.10.x:python/reticulum_wrapper.py:1170-1178). Using the public
API instead of patching the function pointer means the bridge's stamp
override won't break if upstream restructures generate_stamp's internals.

Falls back to the original monkey-patch when run against an older LXMF
that lacks the API, so no environment configuration changes are needed.
Both paths exercised; python->lxmd_pn->python propagation passes against
either upstream master or the feature branch in 40s.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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