FFI-safe UI and related structures
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 30.6k
- Forks
- 2.1k
- Avg merge
- 1d 9h
- Merged PRs (30d)
- 72
Description
Is your feature request related to a problem? Please describe.
Consider a program that wishes to enable development of plugins which could render their own UI within the parent app window. A concrete example would be a Digital Audio Workstation (DAG).
This maps well to egui architecture, as the plugin only needs &mut egui::Ui for most basic functionality. Passing &egui::Context as well would enable more, but isn’t necessary for an MVP.
The issue here is that Rust doesn’t provide a stable ABI out of the box.
Describe the solution you'd like
Make egui::Ui and all arguments of its methods repr(C) and FFI-safe.
Describe alternatives you've considered
- Switching to a different tech stack — viable, but irrelevant for this discussion
- Expressing UI in detached FFI-safe data structure and evaluating this within the main app. This works, but the inherent indirection makes the developer UX worse. Also, this doesn’t scale to widgets which the parent app doesn’t explicitly expose.
- Only share a raw window handle and a rectangle, building another egui instance basing on that. There are some issues like passing the global state of dark/light mode choice or widget styling, but otherwise I think it’s a viable approach as well.
Additional Context
The abi_stable crate could do most of the heavy lifting AFAICT.
Open questions
- Is this feature in line with project goals?
- Support semver-compatible version mismatch, or only the exact same version?
- Performance implications? (I don’t think it’s a real issue, but I have not investigated this)
- Build time implications? If bad, is introducing another feature-flag justified?
- Even if useful, do the users care? If this brings little practical value, additional maintenance cost might not be worth it.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by auditing egui::Ui and the arguments of its methods to determine the scope of the ABI changes. Read the abi_stable crate documentation and assess the open questions around version compatibility, performance, build time, and feature flags. Done would require an agreed project direction and a defined, maintainable FFI-safe API.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- desktop, frontend
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100