Hosted editors (macOS NSView)¶
The default-disabled ravet-host/vst3-editor feature (it enables
vst3-catalogue) adds vst3::instances::editor. The caller-linked native
archive exports ravet_vst3_editor_provider_v1, whose 88-byte table names the
exact instance ABI-v2 table as its origin. editor::Provider::from_raw checks
the size, the version, all nine entries and a non-null origin.
Instance::open_editor also checks pointer identity with the instance's own
table before any native call. Statuses 16..19 (unavailable, unsupported,
reentry, empty) belong to this companion only; existing layouts and domains are
unchanged.
Lifecycle¶
open_editor(provider, Platform::NsView) runs on the platform main thread. It
calls createView("editor") and requires isPlatformTypeSupported("NSView").
It then installs a host IPlugFrame, queries canResize, and admits a
getSize of 1..=16384 per dimension. A missing view is Error::Unavailable
(stage 201) and another platform is Error::Unsupported (stage 202). A creation
failure clears the frame and releases the view before returning.
Each child holds at most one editor. The guard exclusively borrows the
Instance, which borrows its Library, and exposes only &Instance. Native
child destruction returns LIFECYCLE while an editor lives, and module close
returns CHILDREN. A view released through close or drop is therefore
released before handler clearing, controller and component terminate, and
module exit.
Because the guard holds &mut Instance, the scoped Rust calls that also need it
(with_audio, prepare, start, stop, state and parameter refresh) require
the editor to be closed first. An open editor with running audio on the same
instance is demonstrated only through the raw native tables. This is an
accepted limitation (decision 0271). For an editor that stays open while
audio runs, use a Graph-bank child editor; see
Graph-bank child editors and edit gestures.
mem::forget on the guard leaves the native editor alive. Dropping the
Instance then leaks the native child, because the refused destroy is ignored,
and dropping the Library leaks the module. This leak is memory-safe and never
an out-of-order release. A drop-time destroy refused before teardown starts
keeps the native editor alive and increments editor::refused_drops().
unsafe Editor::attach(parent) borrows a caller-owned NSView. The view must
stay alive until a successful detach or until the guard is closed or dropped.
The plug-in may add subviews. A returned attached refusal leaves the editor
detached. A throw is treated as attached and faulted, so teardown still calls
removed. A returned removed refusal keeps the editor attached and
retryable. Every owner reply, refusals included, reports the authoritative
attached state, and Editor::attached() follows it. A refused second attach or
an operation after a fault never reads as detached. close and drop run
removed (if attached), then setFrame(nullptr), then release. Thread and
reentry refusals happen before teardown starts and return the guard in
CloseFailure. Once teardown starts it always consumes the editor and reports
the first foreign failure as Closed::FailedNative.
Sizing, frame requests and scale¶
resize(size) calls canResize (anything other than kResultTrue is
Unsupported), then checkSizeConstraint, then onSize. Only kResultTrue
from checkSizeConstraint, which equals kResultOk, accepts the adjusted
rectangle, and that rectangle must be bounded. kResultFalse,
kNotImplemented and any other result are returned refusals with no
unconstrained fallback, so a resizable view without constraint support cannot be
host-resized. After onSize the size is re-queried with getSize and that
value is recorded. A differing or failed re-query is counted in
size_mismatches.
The native frame handles resizeView on the main thread:
- During host
attachedorsetContentScaleFactorthe request is acknowledged and honoured later. It is applied once after the call if the view is attached, otherwise at the next successful attach. - A superseded request, a request refused by the plug-in's own
onSize, and a request lost to a fault or teardown are counted indeferred_discarded. - During any other host call into the view, or a frame-initiated
onSize, the request is refused as reentry and counted. - When idle and attached,
onSizeruns in the same call stack. Idle requests to a detached view are refused. - Off-main calls, a foreign view, an out-of-range rect, calls after teardown and calls to a faulted owner are refused.
Applied plug-in sizes go to a one-slot mailbox. Read it with
take_resize_request and resize your own container; the native owner never
resizes the caller's view. Detach, teardown and a successful host resize clear
the mailbox. state() copies flags and saturating frame counters.
set_content_scale(0.25..=8.0) uses the optional
IPlugViewContentScaleSupport and is normally Unsupported on macOS.
Reentry and threads¶
Editor entries hold the module's busy flag, as does an idle frame-driven
onSize. Nested editor entries from view callbacks return REENTRY, and nested
instance CONTROL entries return LIFECYCLE. The raw native editor entries do
not take the live-core CONTROL admission, so an AUDIO capability can stay
active. The Rust guard cannot be combined with Rust-side audio on the same
instance; see the lifecycle section above.
Provider and Editor are neither Send nor Sync. No callback enters Rust, and
no view, frame or controller pointer is exposed.
Native validation¶
Configure as above, optionally with
-DRAVET_VST3_EDITOR_TEST_MODULES="editor:/abs/Gain.vst3;none:/abs/Performance.vst3".
Then run CTest. The registered tests are:
ravet-vst3-editor-abi-tests(C11 layout)ravet-vst3-editor-owner-{normal,fast}-tests(injected SDK view: faults, deferred and refused frame calls, constraint policy, retained frames, ordered teardown, 1000 cycles)ravet-vst3-editor-provider-{normal,fast}-tests(substituted loader: origin, argument, alias and thread refusals, ordering, reentry, active AUDIO)ravet-vst3-editor-window-tests(actual modules in a hidden offscreenNSWindow, three cycles each, one with audio on a worker)
ravet-vst3-editor-visible-probe is a manual-only, EXCLUDE_FROM_ALL target
that is never registered with CTest.
Limits¶
Only macOS NSView is supported, with local arm64 evidence. That evidence is
authored fixtures plus the RAVET Gain editor built with RAVET_GAIN_EDITOR=ON;
Performance and default Gain have no editor and report unavailable. There is no
DAW, third-party editor, visual-rendering or accessibility claim. Keyboard,
wheel and focus forwarding are not provided. Edit gestures are adopted only
for Graph-bank children that enable them; every other child's handler still
returns kNotImplemented. See
decision 0271.