VSTPlugins icon indicating copy to clipboard operation
VSTPlugins copied to clipboard

A plugin from V 0.62 cause crashes in Ubuntu 22.04/Reaper

Open ryukau opened this issue 1 year ago • 25 comments

This issue opened from the linked comment on another issue.

https://github.com/ryukau/VSTPlugins/issues/35#issuecomment-2379895132_

ryukau avatar Sep 28 '24 03:09 ryukau

@maxxatgit Are you using the plugins from zip file on the release page, or built from source code?

Probably the plugins in zip files only work on Ubuntu 24.04. I set ubuntu-latest on GitHub Actions, and it seems like the Ubuntu version is updated recently. I updated documentations in commit 2d8b3bc.

Edit: Fixed the commit link.

ryukau avatar Sep 28 '24 04:09 ryukau

Yes, I'm using the plugins from the zip file. Is it possible to choose an older version of Ubuntu to build against?

maxxatgit avatar Sep 30 '24 04:09 maxxatgit

Yes, it's possible. Instructions are below.

  1. Fork this repository on GitHub.
  2. Clone the forked repository to your local.
  3. Replace the content of .github/workflows/build.yml.
  4. Trigger GitHub Actions.

On step 3, delete all texts in the original build.yml, and replace to following. Click "Details" below to display the code.

on: push

env:
  package_path: package

jobs:
  build-ubuntu:
    runs-on: ubuntu-22.04  # Ubuntu version can be set here.
    steps:
    - name: Checkout
      uses: actions/checkout@v4
      with:
        submodules: recursive
    - name: Run script
      run: ci/ci_ubuntu.sh
    - name: Upload
      if: ${{ startsWith(github.ref, 'refs/tags/') }}
      uses: actions/upload-artifact@v4
      with:
        name: vst_ubuntu
        path: vst_ubuntu

On step 4, following commands trigger GitHub Action. Assuming that the remote name is set as origin.

git add -A
git commit --allow-empty -m ""
git push -u origin master

After the workflow is completed, you can find the plugins in a bit deep in Action tab in your forked repository.

I will not setup the build for older versions of OSes, because I once got a warning related to the storage limit on GitHub.

ryukau avatar Sep 30 '24 06:09 ryukau

Closing due to no response.

ryukau avatar Oct 11 '24 17:10 ryukau

Hi, me again. Sorry for the slow response. I have done steps 1, 2, and 3 above. I have never forked a repo in git before, I do not know how to trigger a github action. Where do I enter the commands? Thank you very much.

maxxatgit avatar Jan 02 '25 01:01 maxxatgit

OK, I figured it out. I ran the action, but I cannot find any artifacts from the build.

maxxatgit avatar Jan 02 '25 07:01 maxxatgit

Ah, sorry. There was a mistake in the step 3. Following line is unnecessary.

      if: ${{ startsWith(github.ref, 'refs/tags/') }}

The above means that the actions below that line are only triggered by Git tag. So following commands should also work. Text editor, likely vi or nano, opens after entering the first command (git tag -a ...) to write a tag message. Tag message can be anything but empty.

# bash
git tag -a trigger
git push -u origin master --tags

ryukau avatar Jan 02 '25 10:01 ryukau

That did it! I was able to build Ubuntu 22.04 specific binaries. Unfortunately, they still crash. Here is the error I got when running Reaper form the console:

reaper: ../../../../src/cairo-xcb-screen.c:219: _get_screen_index: Assertion `!"reached"' failed.

I hope that is a helpful error message. I Really like your plugins, I hope to get the latest set working. Thank you!

maxxatgit avatar Jan 02 '25 19:01 maxxatgit

I did a search for that error and found this (from a U-He dev): https://cairo.cairographics.narkive.com/eXgzeIgH/concerns-regarding-xcb-backend I hope this helps

maxxatgit avatar Jan 02 '25 20:01 maxxatgit

reaper: ../../../../src/cairo-xcb-screen.c:219: _get_screen_index: Assertion `!"reached"' failed.

Pretty sure I saw the same error at one point, and the way it crashes sounds similar to #16 (related: #14, #35). I also filed a issue (https://github.com/steinbergmedia/vstgui/issues/249) to VSTGUI and it was seemed to be solved at that time. If I understand correctly, the crash happens when the plugin window is repeatedly opened and closed.

My apologies. I didn't know better and had to be avoided using VSTGUI at all. It caused so much trouble years after years. I wasn't experienced at C++ programming at all when I started this repository.

I was about to say that rolling back to VSTGUI 4.9 might solve the problem, but I remembered that they changed API after 4.9. So I can't think of an easy workaround that doesn't change the existing C++ code. Sorry again for inconvenience.

For now, I'm not sure how to solve the crash issue without breaking existing user projects. GUI library must be changed but I'm not sure which one is the most suitable (which means easy to static link and low maintenance). I'm currently looking at tcl/tk.

I'll work on this as a next milestone. It will take time.

ryukau avatar Jan 02 '25 21:01 ryukau

I appreciate your good work, and responding to my questions/issues. I'm not a coder, but if I can help in any way (now I know how to run a build on GitHub), I will be happy to help.

In Reaper, I can turn the GUI off. That may be the solution for now. Again, thank you very much!

maxxatgit avatar Jan 02 '25 21:01 maxxatgit

FYI, I got the same crash with one of my own plugins: https://github.com/steinbergmedia/vstgui/issues/334

I made a fix here: https://github.com/steinbergmedia/vstgui/pull/335

madah81pnz1 avatar Jan 09 '25 03:01 madah81pnz1

@madah81pnz1 Thank you. I was closely watching your issue on VSTGUI repo.

I have a comment on remaining ref counts. Any chance you are using the pattern linked below?

https://github.com/steinbergmedia/vstgui/blob/ad46cf69c1b242f799764611b82c5af4c34ea95e/vstgui/plugin-bindings/vst3editor.cpp#L1259-L1263

Suspicious places are:

  • RunLoop::Impl in vstgui4/vstgui/lib/platform/linux/x11platform.cpp
  • CDrawContext::Impl in lib/vst3sdk/vstgui4/vstgui/lib/cdrawcontext.cpp
  • DrawHandler in vstgui4/vstgui/lib/platform/linux/x11frame.cpp

It looks like PlatformGraphicsDeviceContextPtr is an alias of std::shared_ptr, but RunLoop::Impl is holding raw pointer. DrawHandler is calling std::make_shared, while getting device by calling cairo_surface_get_device.

ryukau avatar Jan 09 '25 06:01 ryukau

@maxxatgit The patch of @madah81pnz1 might solve the problem for now. I'll provide steps to apply it. Please let me know if it works or not.

  1. Download cairographicscontext.patch from here.
  2. Move cairographicscontext.patch to ci/linux_patch in this repository. Overwrite the existing one.
  3. Run following commands to commit the change.
git commit -am "Change cairographicscontext.patch"
git push -u origin master

There's already an existing patch for cairographicscontext.cpp. The patch linked in the step 1 is a merge of the existing one and the patch provided by @madah81pnz1.

ryukau avatar Jan 09 '25 06:01 ryukau

@madah81pnz1 Thank you. I was closely watching your issue on VSTGUI repo.

I have a comment on remaining ref counts. Any chance you are using the pattern linked below?

https://github.com/steinbergmedia/vstgui/blob/ad46cf69c1b242f799764611b82c5af4c34ea95e/vstgui/plugin-bindings/vst3editor.cpp#L1259-L1263

Suspicious places are:

* `RunLoop::Impl` in `vstgui4/vstgui/lib/platform/linux/x11platform.cpp`

* `CDrawContext::Impl` in `lib/vst3sdk/vstgui4/vstgui/lib/cdrawcontext.cpp`

* `DrawHandler` in `vstgui4/vstgui/lib/platform/linux/x11frame.cpp`

It looks like PlatformGraphicsDeviceContextPtr is an alias of std::shared_ptr, but RunLoop::Impl is holding raw pointer. DrawHandler is calling std::make_shared, while getting device by calling cairo_surface_get_device.

I'm not using vst3editor.cpp, my plugin is based on https://github.com/surge-synthesizer/clap-saw-demo/blob/main/src/linux-vstgui-adapter.cpp But that clap-saw-demo is a bit incomplete though, it doesn't have this crash since it never calls VSTGUI::exit(). Other than that, the end result should be the same calls I think.

There is no code calling RunLoop::Impl::setDevice(), so the device raw pointer in RunLoop::Impl is never used. I think the code using it was removed when CairoGraphicsDevice was added, and CairoGraphicsDeviceFactory is supposed to take over the ownership of the device instead.

There are other places, like CairoGraphicsDeviceContext::Impl stores a reference to the CairoGraphicsDevice, which I find a bit dangerous. But seems to never be used either.

madah81pnz1 avatar Jan 09 '25 08:01 madah81pnz1

@madah81pnz1 Sorry for making confusion, I was probably talking something irrelevant. clap-saw-demo looks quite different to my usage of VSTGUI (common/gui/plugeditor.hpp for reference).

ryukau avatar Jan 09 '25 17:01 ryukau

@maxxatgit I found an interesting bridge plugin that might be used as a workaround.

https://github.com/robbert-vdh/yabridge

It says to be using Wine, so it might not work. One of the reason I gave up Linux is that my old FL projects couldn't work on Wine. Some of the plugins in the projects didn't work. (Maybe it was related to SIMD, as one of the crashed plugin has "SSE" in their name.)

ryukau avatar Jan 10 '25 09:01 ryukau

@maxxatgit I'll communicate my failure early. I probably can't solve this issue in foreseeable future. Replacing VSTGUI is far more involved than I thought, and if I do it I will likely introduce more bugs than fixes. I'm lacking the skill. More details are on issue #58.

I'll leave this issue open. What's lacking here is a cross platfrom GUI library that is specifically made for audio plugins. Or some friendly tutorial about how to integrate a GUI library into VST 3 SDK.

ryukau avatar Jan 14 '25 20:01 ryukau

@ryukau Thank you for your attention on this issue. I will try the cairographicscontext.patch fix you suggested in a few days. I'm super busy right now. I don't use wine... only Linux native plugins.

Please excuse the noob questions, but, is Juce a viable framework? If not, what about CLAP? CLAP is cross-platform, and is an open standard that is not controlled by large corporations. Thanks again for your excellent code!

maxxatgit avatar Jan 14 '25 23:01 maxxatgit

@maxxatgit The reason I'm not using JUCE is that it was lacking a feature I use frequently. The feature doesn't have a name, but I'd call it "fractional pitch at note-on". Without it, I can't do something like the video linked below (note delay with pitch shift).

https://github.com/user-attachments/assets/d54a8e28-0bfa-481e-89e7-93bcda71bad7


CLAP is not a solution to this specific issue. Changing plugin format breaks existing projects which I would like to avoid at any cost.

That said, I'm considering to write my new plugins on CLAP. It's that I'm not sure what to do with this repository, when it comes to fixing this issue. The reason this repository is targeting VST 3 is that there was no option other than VST 3 when I started. It was the summer of 2019. VST 2 was deprecated right before I started, and FL Studio at that time only supported VST 2, VST 3, AU, and FL's own plugin format.

ryukau avatar Jan 15 '25 02:01 ryukau

@maxxatgit I decided to move to JUCE. I won't migrate plugins in this repository, but maybe make improved version for some.

ryukau avatar Jan 22 '25 02:01 ryukau

I setup Ubuntu 24.10 virtual machine. The video below is showing the issue. The patch from @madah81pnz1 is applied. It still crashes sometimes, and the text disappears randomly.

https://github.com/user-attachments/assets/d290e0d4-6fab-43a3-8acc-62892b7f5602

ryukau avatar Jan 22 '25 03:01 ryukau

@ryukau I appreciate what you are doing to solve this issue. Your plugins are very unusual, and help me to easily make sounds that would be difficult to produce with more common plugins.

Thanks for all that you do! 💯

maxxatgit avatar Jan 29 '25 02:01 maxxatgit

@maxxatgit A patch to partially fix this issue is available on the link below:

  • https://gist.github.com/ryukau/2db96333e667cbaf8358e8d0e7890ecf

To apply the patch, please refer to this comment. The filename of the new patch must be changed from vstgui4.14.1_linux_crash_fix.patch to cairographicscontext.patch.

It seems that crash still happens in some cases (link). The condition is not clear, but opening 2 windows of the same plugin might trigger the crash. I'd recommend to save often, and to write the result to a file by using freeze or bounce feature provided by your DAW.

ryukau avatar Feb 03 '25 07:02 ryukau

I was forgetting to mention some quirks. XY pad may looks weird as the black circle is large.

I once provided a fix, but it is ignored for like 5 years at this point. There's also other fix on the link below.

  • https://github.com/steinbergmedia/vstgui/issues/333

ryukau avatar Feb 03 '25 07:02 ryukau

I'll close this issue as VSTGUI4 and the related patch in this repository are updated. At least the GUI is working on my Ubuntu virtual machine.

If anything is left, feel free to add comment or open another issue.

ryukau avatar Aug 31 '25 04:08 ryukau