Skip to content

Implement permanent plugin architecture and update API#87

Merged
tristanpoland merged 4 commits intooverhaul/WGPUIfrom
main
Feb 28, 2026
Merged

Implement permanent plugin architecture and update API#87
tristanpoland merged 4 commits intooverhaul/WGPUIfrom
main

Conversation

@tristanpoland
Copy link
Copy Markdown
Member

This pull request makes significant improvements to the plugin API documentation and safety model, clarifies memory management practices, and simplifies several type definitions in the crates/plugin_editor_api/src/lib.rs file. The main focus is on ensuring ABI safety by never unloading plugin libraries, which enables safe sharing of function pointers, trait objects, and Arc<T> across the plugin boundary. It also updates the plugin interface to reflect these guarantees and removes outdated cleanup logic.

Plugin safety model and memory management [1] [2] [3]

  • The documentation now clearly states that plugins are loaded once and never unloaded, ensuring function pointers, vtables, and drop glue remain valid for the process lifetime. This enables safe sharing of Arc<T>, trait objects, and function pointers, and removes the need for weak reference workarounds. Detailed guidance on preventing Arc cycles is added. [1] [2] [3]

API and trait changes [1] [2] [3]

  • The EditorInstance trait is removed; plugins now return an Arc<dyn PanelView> directly, simplifying the interface and aligning with the new safety model. All documentation and examples are updated accordingly. [1] [2] [3]
  • The plugin constructor function type (PluginCreate) is updated to return a 'static reference, and the destructor function is removed since plugins are never unloaded. The macro for exporting plugins is updated to reflect these changes.

Version compatibility and type simplification [1] [2] [3]

  • Version checking is clarified: Rustc version must match exactly (ABI is not stable across versions), and only the semver part of the Rustc version is hashed for compatibility. [1] [2] [3]

Documentation improvements [1] [2] [3]

  • Safety notes are added throughout the API, especially for function pointers and trait objects, explaining why they are safe to use. The statusbar button API is updated with clearer safety documentation. [1] [2] [3]

Minor code and formatting cleanups [1] [2] [3] [4] [5]

  • Several enums and structs are reformatted for conciseness, and redundant code (such as the EditorLogger and its usages) is removed. Minor formatting and documentation corrections are made throughout. [1] [2] [3] [4] [5]

Add a comprehensive PLUGIN_ARCHITECTURE.md (v2.0) that documents the redesigned Pulsar plugin system: permanent library loading (never unload), shared Rust types, build-time compatibility checks, memory/Arc cycle guidance, cross-platform loading details, API surface, and migration steps. Also update .gitignore to ignore /.vscode/fastsearch.
Switch plugin system to a permanent-library model: plugins are loaded once and never unloaded. Add PermanentLibrary and related handling (crates/plugin_manager/src/permanent_library.rs) and stop exporting/using plugin destroy/unload symbols. Change the plugin API to return owned 'static references and Arcs across the boundary: PluginCreate now returns &'static mut dyn EditorPlugin, create_editor returns Arc<dyn PanelView>, and the export_plugin! macro leaks the boxed plugin and registers theme access via OnceLock. Remove the old EditorInstance trait and EditorLogger, simplify statusbar callback and function-pointer safety docs, and update many docs and version/ABI checks to reflect the permanent-load safety model. Update PluginManager to use PermanentLibrary, drop unsafe raw-pointer destroy logic, adjust loading/registration flows, and update logging. Overall this simplifies cross-DLL memory model (no dlclose/destroy), but requires plugins and engine to remain compatible and loaded for process lifetime.
Update call sites to match PluginManager API changes and temporarily disable the UI unload action. In ui_core: use pm.editor_registry().get_plugin_for_editor(...).cloned() and handle pm.create_editor returning just a panel (remove tuple pattern). In ui_plugin_manager: remove the unload_plugin helper and replace the unload button handler with a todo! that documents the need to implement plugin unloading in the PluginManager. These changes align the UI with the updated plugin API and avoid referencing removed return values/handlers.
@tristanpoland tristanpoland marked this pull request as ready for review February 28, 2026 16:23
@tristanpoland tristanpoland merged commit 01c3ab6 into overhaul/WGPUI Feb 28, 2026
5 of 8 checks passed
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.

1 participant