[Solved] Unity Plugin Crashes Unity

I built a very basic plugin - a stereo passthrough

with no processing at all

for (int channel = 0; channel < totalNumInputChannels; ++channel)
    auto* channelData = buffer.getWritePointer (channel);

    // ..do something to the data...

It crashes Unity on play.

I’m building a VST3 in the same project. That’s working fine.

Any thoughts?

chrash log:

Unity Editor [version: Unity 2017.3.1f1_fc1d3344e6ea]

audioplugin_u_stereo.dll caused an Access Violation (0xc0000005)

in module audioplugin_u_stereo.dll at 0033:483739c2.

Error occurred at 2018-11-08_115904.

C:\Program Files\Unity\Editor\Unity.exe, run by garry.

76% memory in use.

16269 MB physical memory [3843 MB free].

30093 MB paging file [7475 MB free].

134217728 MB user address space [134211366 MB free].

Write to location 00000000 caused an access violation.

BTW, a Unity Plugin I built with the ‘experimental’ version from the development branch (commit b3a1d56ebace79e9d3b3d0ac6e6d21b978a14e1f) works fine

Can you attach the debugger and see where it is actually crashing?

line 258 \modules\juce_audio_basics\buffers\juce_AudioDataConverters.h

Exception thrown at 0x00007FFF3B169C19 (audioplugin_u_stereo.dll) in Unity.exe: 0xC0000005: Access violation writing location 0x0000000000000000.

Can you reproduce it with one of the plug-in example projects or the audio plug-in template project?

i built the ‘Gain audio Plugin’ @ed95 and that worked in unity!

OK, sounds like it might be an issue with your plug-in code then. Posting some of the relevant parts here or trying to reproduce it with a stripped down example would help to track it down.

I didn’t change any code - I just created a new audio plugin and with no changes built from that.

Edit: I can confirm this again. Building a new audio plugin from the template crashes Unity.

What platform are you on? I can’t reproduce this on macOS 10.14.

Are you using the latest tip of develop? I pushed a fix for some assertions that were being hit in Unity here earlier which may have something to do with the issues you’re seeing.

Windows 10

I’m using the 5.4 release.

I’ll build get the development release and see.

thanks for you thoughts so far.

Hi @ed95

the same outcome is reproduced!

  1. I pulled your latest commit on the develop branch (cda5c144f4b595b0c04b38aec1f786abde9c9d10)

  2. built the x64 Projucer in …\extras\Projucer\Builds\VisualStudio2017

  3. ran the projucer.exe …\extras\Projucer\Builds\VisualStudio2017\x64\Release\App

  4. set the Global Modules path …\modules (in the tip of the develop branch)

  5. start a new projucer and select the ‘audio plugin’ template,

  6. name it, check that Visual Studio 17 is my target platform and the modules dir is correct

  7. create the project

  8. in the settings for the project, I select ‘Unity’ as the plugin format and ‘{2,2}’ as the channel configuration

  9. select save and open the VS2017 project

  10. Build the x64 release

  11. Copy the *.dll and *.cs from …\Builds\VisualStudio2017\x64\Release\Unity Plugin to my Unity project …\Assets\Plugins

  12. launch my unity project, add the plugin to a mixer, and press play.

  13. unluckily, Unity crashes.

Hi @ed95

it is setting the channel configuration that is ‘causing’ the problem.

If I create a template project without setting the channel configuration it builds as expected.

I’ll push a fix to the develop branch shortly. It’ll make its way onto the master branch sometime in the next week or so when we do a bugfix release.

1 Like

Thanks @ed95, I can confirm this works.

[if you saw the unedited message, the multiple issue was my lack of a comma between the configs :wink: ]