antonok-edm / ampli-Fe

Fully cross-platform VST2 plugin with a custom editor UI, written in Rust.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Plugin crashes when used in reaper

d2weber opened this issue · comments

I tried to load the plugin with reaper 6.34, the program crashes (using Ubuntu 20.04):

$ ./reaper jack: created client jack: setting TIME_CRITICAL = 4 jack: activated client MESA-INTEL: warning: Ivy Bridge Vulkan support is incomplete thread '<unnamed>' panicked at 'calledOption::unwrap()on aNonevalue', src/editor/interface/graphics.rs:111:18 note: run withRUST_BACKTRACE=1environment variable to display a backtrace fatal runtime error: failed to initiate panic, error 5 Aborted (core dumped)

I guess there is a problem with my gpu. It is an integrated GPU. sudo lshw -C display gives
*-display description: VGA compatible controller product: 3rd Gen Core processor Graphics Controller vendor: Intel Corporation physical id: 2 bus info: pci@0000:00:02.0 version: 09 width: 64 bits clock: 33MHz capabilities: msi pm vga_controller bus_master cap_list rom configuration: driver=i915 latency=0 resources: irq:36 memory:62000000-623fffff memory:70000000-7fffffff ioport:3000(size=64) memory:c0000-dffff

Loading the plugin with ardour seems to work as expected.

(A minor issue might be that when the plugin is compiled in debug I get an overflow when loading the plugin:
MESA-INTEL: warning: Ivy Bridge Vulkan support is incomplete thread '<unnamed>' panicked at 'attempt to subtract with overflow', src/editor/interface/state.rs:77:20 note: run with RUST_BACKTRACE=1environment variable to display a backtrace fatal runtime error: failed to initiate panic, error 5 Aborted (core dumped))
(fixed in #3)

The first one looks like an issue somewhere between wgpu and vst_window:

    pub fn new<W: raw_window_handle::HasRawWindowHandle>(handle: W) -> Self {
        let instance = wgpu::Instance::new(wgpu::BackendBit::PRIMARY);

        // Acquire the window as a surface to be rendered on.
        // This is the only unsafe code in the plugin; it is only required to satisfy the
        // `raw_window_handle` API. Safety is upheld by taking ownership of `handle` in the
        // function signature, ensuring it is only ever used to create a single surface.
        let surface = unsafe { instance.create_surface(&handle) };

        // Get a handle to the GPU and a queue of commands to be uploaded to it while rendering.
        let (device, queue) = futures::executor::block_on(async {
            let adapter = instance
                .request_adapter(&wgpu::RequestAdapterOptions {
                    power_preference: wgpu::PowerPreference::Default,
                    compatible_surface: Some(&surface),
                })
                .await
                .unwrap();
        // ...

I imagine it's a problem with compatible_surface; for whatever reason the window handle created by Reaper isn't recognized as compatible by wgpu. This could also potentially be a problem with how vst_window is creating the RawWindowHandle from the pointer provided by Reaper.

The second issue is just with handling mouse click coordinates, and is a pretty silly error on my part. It shouldn't affect behavior in Release mode in practice, but should be fixed anyways. I opened #3 with the fix.