Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
ryukau opened this issue Sep 28, 2024 · 25 comments
Open

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

ryukau opened this issue Sep 28, 2024 · 25 comments

Comments

@ryukau
Copy link
Owner

ryukau commented Sep 28, 2024

This issue opened from the linked comment on another issue.

#35 (comment)_

@ryukau
Copy link
Owner Author

ryukau commented Sep 28, 2024

@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.

@maxxatgit
Copy link

maxxatgit commented Sep 30, 2024

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

@ryukau
Copy link
Owner Author

ryukau commented Sep 30, 2024

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
Copy link
Owner Author

ryukau commented Oct 11, 2024

Closing due to no response.

@ryukau ryukau closed this as completed Oct 11, 2024
@maxxatgit
Copy link

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
Copy link

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

@ryukau ryukau reopened this Jan 2, 2025
@ryukau
Copy link
Owner Author

ryukau commented Jan 2, 2025

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

@maxxatgit
Copy link

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
Copy link

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

@ryukau
Copy link
Owner Author

ryukau commented Jan 2, 2025

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 (steinbergmedia/vstgui#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.

@maxxatgit
Copy link

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!

@madah81pnz1
Copy link

FYI, I got the same crash with one of my own plugins:
steinbergmedia/vstgui#334

I made a fix here:
steinbergmedia/vstgui#335

@ryukau
Copy link
Owner Author

ryukau commented Jan 9, 2025

@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
Copy link
Owner Author

ryukau commented Jan 9, 2025

@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.

@madah81pnz1
Copy link

@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.

@ryukau
Copy link
Owner Author

ryukau commented Jan 9, 2025

@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
Copy link
Owner Author

ryukau commented Jan 10, 2025

@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
Copy link
Owner Author

ryukau commented Jan 14, 2025

@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.

@maxxatgit
Copy link

@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!

@ryukau
Copy link
Owner Author

ryukau commented Jan 15, 2025

@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).

2025-01-15.10-06-20.mp4

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
Copy link
Owner Author

ryukau commented Jan 22, 2025

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

@ryukau
Copy link
Owner Author

ryukau commented Jan 22, 2025

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.

2025-01-22.12-13-45.mp4

@maxxatgit
Copy link

@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! 💯

@ryukau
Copy link
Owner Author

ryukau commented Feb 3, 2025

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

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
Copy link
Owner Author

ryukau commented Feb 3, 2025

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.

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

No branches or pull requests

3 participants