DISTRHO / Cardinal

Virtual modular synthesizer plugin
https://cardinal.kx.studio/
GNU General Public License v3.0
2.27k stars 155 forks source link

v23.09 LV2 Windows Creates Files Everywhere, Or Maybe in the Current Working Directory #587

Closed mfisher31 closed 1 year ago

mfisher31 commented 1 year ago

This report is for my app(s), but probably applies to any LV2 host on windows.

When loading the LV2 version on Windows with Element running within VSCode, Cardinal creates meta data all over the place. See screenshot below of Git changes. All of the *\Cardinal\* files were created by loading the plugin.

Screenshot 2023-10-04 221916

Other Notes:

falkTX commented 1 year ago

seems that finding the user dir fails, and then it uses the current dir? the stdout/stderr logs printed by cardinal should tell where it is storing user files

mfisher31 commented 1 year ago

[0.000 info CardinalCommon.cpp:589 Initializer] User directory: Cardinal

User directory is set as a relative path I guess. I noticed this happening in Linux as well this morning, so maybe not just a windows problem.

Loaded 'C:\Program Files\Common Files\LV2\CardinalFX.lv2\CardinalFX.dll'. Module was built without symbols.
Loaded 'C:\Windows\System32\dbghelp.dll'.
Loaded 'C:\Windows\System32\opengl32.dll'.
Loaded 'C:\Windows\System32\version.dll'.
Loaded 'C:\Windows\System32\glu32.dll'.
[0.000 info CardinalCommon.cpp:578 Initializer] Cardinal LV2 23.09, compatible with Rack version 2.3.0
[0.000 info CardinalCommon.cpp:579 Initializer] Windows 6.2
[0.000 info CardinalCommon.cpp:580 Initializer] Binary filename: C:\Program Files\Common Files\LV2\CardinalFX.lv2\CardinalFX.dll
[0.000 info CardinalCommon.cpp:582 Initializer] Bundle path: C:/Program Files/Common Files/LV2/CardinalFX.lv2/
[0.000 info CardinalCommon.cpp:588 Initializer] System directory: C:/Program Files/Common Files/Cardinal
[0.000 info CardinalCommon.cpp:589 Initializer] User directory: Cardinal
[0.000 info CardinalCommon.cpp:590 Initializer] Template patch: Cardinal/templates/fx.vcv
[0.000 info CardinalCommon.cpp:591 Initializer] System template patch: C:/Program Files/Common Files/Cardinal/patches/templates/fx.vcv
[0.000 info CardinalCommon.cpp:605 Initializer] Initializing plugins
[0.020 info CardinalCommon.cpp:608 Initializer] Initializing plugin browser DB
[0.024 info CardinalCommon.cpp:670 loadSettings] Loading settings
[0.024 info Rack/src/settings.cpp:512 load] Loading settings Cardinal/fx.json
[0.024 info CardinalCommon.cpp:625 Initializer] OSC Remote control is not available on plugin variants
Loaded 'C:\Windows\System32\AppXDeploymentClient.dll'.
Loaded 'C:\Windows\System32\Windows.ApplicationModel.dll'.
Loaded 'C:\Windows\System32\propsys.dll'.
Loaded 'C:\Windows\System32\Windows.FileExplorer.Common.dll'.
Loaded 'C:\Windows\System32\mssprxy.dll'.
Loaded 'C:\Windows\System32\DriverStore\FileRepository\iigd_dch.inf_amd64_bef59ff5f9d0461f\igxelpicd64.dll'.
Loaded 'C:\Windows\System32\dwmapi.dll'.
Loaded 'C:\Windows\System32\DriverStore\FileRepository\iigd_dch.inf_amd64_bef59ff5f9d0461f\igdml64.dll'.
Loaded 'C:\Windows\System32\DriverStore\FileRepository\iigd_dch.inf_amd64_bef59ff5f9d0461f\igdgmm64.dll'.
Loaded 'C:\Windows\System32\ControlLib.dll'.
Loaded 'C:\Windows\System32\DriverStore\FileRepository\iigd_dch.inf_amd64_bef59ff5f9d0461f\IntelControlLib.dll'.
Unloaded 'C:\Windows\System32\DriverStore\FileRepository\iigd_dch.inf_amd64_bef59ff5f9d0461f\IntelControlLib.dll'.
Unloaded 'C:\Windows\System32\ControlLib.dll'.
Loaded 'C:\Windows\System32\DriverStore\FileRepository\iigd_dch.inf_amd64_bef59ff5f9d0461f\igc64.dll'.
[0.146 info Rack/src/patch.cpp:273 load] Loading patch Cardinal/templates/fx.vcv
Exception thrown at 0x00007FFB8DBD531C (KernelBase.dll) in element.exe: 0x20474343 (parameters: 0x0000011F98D10390).
Exception thrown at 0x00007FFB8DBD531C (KernelBase.dll) in element.exe: 0x21474343 (parameters: 0x0000011F98D10390, 0x000000094571E2A0, 0x00007FFB012857EA, 0x0000000000000000).
[0.149 info Rack/src/patch.cpp:273 load] Loading patch C:/Program Files/Common Files/Cardinal/patches/templates/fx.vcv
[0.149 info Rack/src/patch.cpp:339 loadAutosave] Loading autosave C:/Users/info/AppData/Local/Temp/Cardinal.0020/patch.json
[0.151 info Rack/src/patch.cpp:486 fromJson] Patch was made with Rack 2.1.1, current Rack version is 2.3.0
[0.153 info Rack/src/window/Svg.cpp:28 loadFile] Loaded SVG C:/Program Files/Common Files/Cardinal/Cardinal/res/HostAudio.svg
[0.153 info Rack/src/window/Svg.cpp:28 loadFile] Loaded SVG C:/Program Files/Common Files/Cardinal/ComponentLibrary/ScrewBlack.svg
[0.153 info Rack/src/window/Svg.cpp:28 loadFile] Loaded SVG C:/Program Files/Common Files/Cardinal/ComponentLibrary/PJ301M.svg
[0.153 info Rack/src/window/Svg.cpp:28 loadFile] Loaded SVG C:/Program Files/Common Files/Cardinal/Cardinal/res/HostMIDI.svg
[0.154 info Rack/src/window/Svg.cpp:28 loadFile] Loaded SVG C:/Program Files/Common Files/Cardinal/Cardinal/res/HostTime.svg
[0.154 info Rack/src/window/Svg.cpp:28 loadFile] Loaded SVG C:/Program Files/Common Files/Cardinal/ComponentLibrary/SmallLight.svg
[0.154 info Rack/src/window/Svg.cpp:28 loadFile] Loaded SVG C:/Program Files/Common Files/Cardinal/Cardinal/res/HostParameters.svg
[0.155 info Rack/src/window/Svg.cpp:28 loadFile] Loaded SVG C:/Program Files/Common Files/Cardinal/Cardinal/res/HostParamsMap.svg
[0.155 info Rack/src/app/RackWidget.cpp:327 fromJson] Creating module widget DISTRHO Text Editor
[0.155 info Rack/src/app/RackWidget.cpp:327 fromJson] Creating module widget DISTRHO Audio 2
[0.155 info Rack/src/app/RackWidget.cpp:327 fromJson] Creating module widget DISTRHO Host MIDI
[0.155 info Rack/src/app/RackWidget.cpp:327 fromJson] Creating module widget DISTRHO Host Time
[0.155 info Rack/src/app/RackWidget.cpp:327 fromJson] Creating module widget DISTRHO Host Parameters
[0.155 info Rack/src/app/RackWidget.cpp:327 fromJson] Creating module widget DISTRHO Host Parameters Map
[0.155 info Rack/src/window/Svg.cpp:28 loadFile] Loaded SVG C:/Program Files/Common Files/Cardinal/ComponentLibrary/Plug.svg
[0.155 info Rack/src/window/Svg.cpp:28 loadFile] Loaded SVG C:/Program Files/Common Files/Cardinal/ComponentLibrary/PlugPort.svg
[0.156 info override/context.cpp:48 ~Context] Deleting window
[0.159 info override/context.cpp:52 ~Context] Deleting patch manager
[0.159 info override/context.cpp:56 ~Context] Deleting scene
[0.159 info override/context.cpp:60 ~Context] Deleting event state
[0.159 info override/context.cpp:64 ~Context] Deleting history state
[0.159 info override/context.cpp:68 ~Context] Deleting engine
[0.159 info CardinalCommon.cpp:642 ~Initializer] Save settings
[0.159 info Rack/src/settings.cpp:491 save] Saving settings Cardinal/fx.json
[0.160 info CardinalCommon.cpp:646 ~Initializer] Clearing asset paths
[0.160 info CardinalCommon.cpp:651 ~Initializer] Destroying plugins
[0.160 info CardinalCommon.cpp:654 ~Initializer] Destroying colourized assets
[0.160 info CardinalCommon.cpp:657 ~Initializer] Destroying settings
[0.160 info CardinalCommon.cpp:660 ~Initializer] Destroying logger
Unloaded 'C:\Windows\System32\dbghelp.dll'.
Unloaded 'C:\Windows\System32\version.dll'.
Unloaded 'C:\Program Files\Common Files\LV2\CardinalFX.lv2\CardinalFX.dll'.
Loaded 'C:\Program Files\Common Files\LV2\CardinalFX.lv2\CardinalFX.dll'. Module was built without symbols.
Loaded 'C:\Windows\System32\version.dll'.
Loaded 'C:\Windows\System32\dbghelp.dll'.
[0.000 info CardinalCommon.cpp:578 Initializer] Cardinal LV2 23.09, compatible with Rack version 2.3.0
[0.000 info CardinalCommon.cpp:579 Initializer] Windows 6.2
[0.000 info CardinalCommon.cpp:580 Initializer] Binary filename: C:\Program Files\Common Files\LV2\CardinalFX.lv2\CardinalFX.dll
[0.000 info CardinalCommon.cpp:582 Initializer] Bundle path: C:/Program Files/Common Files/LV2/CardinalFX.lv2/
[0.000 info CardinalCommon.cpp:588 Initializer] System directory: C:/Program Files/Common Files/Cardinal
[0.000 info CardinalCommon.cpp:589 Initializer] User directory: Cardinal
[0.000 info CardinalCommon.cpp:590 Initializer] Template patch: Cardinal/templates/fx.vcv
[0.000 info CardinalCommon.cpp:591 Initializer] System template patch: C:/Program Files/Common Files/Cardinal/patches/templates/fx.vcv
[0.000 info CardinalCommon.cpp:605 Initializer] Initializing plugins
[0.022 info CardinalCommon.cpp:608 Initializer] Initializing plugin browser DB
[0.025 info CardinalCommon.cpp:670 loadSettings] Loading settings
[0.025 info Rack/src/settings.cpp:512 load] Loading settings Cardinal/fx.json
[0.026 info CardinalCommon.cpp:625 Initializer] OSC Remote control is not available on plugin variants
[0.047 info Rack/src/patch.cpp:273 load] Loading patch Cardinal/templates/fx.vcv
Exception thrown at 0x00007FFB8DBD531C (KernelBase.dll) in element.exe: 0x20474343 (parameters: 0x0000011F9D66EAC0).
Exception thrown at 0x00007FFB8DBD531C (KernelBase.dll) in element.exe: 0x21474343 (parameters: 0x0000011F9D66EAC0, 0x000000094571E250, 0x00007FFB012857EA, 0x0000000000000000).
[0.048 info Rack/src/patch.cpp:273 load] Loading patch C:/Program Files/Common Files/Cardinal/patches/templates/fx.vcv
[0.049 info Rack/src/patch.cpp:339 loadAutosave] Loading autosave C:/Users/info/AppData/Local/Temp/Cardinal.0020/patch.json
[0.053 info Rack/src/patch.cpp:486 fromJson] Patch was made with Rack 2.1.1, current Rack version is 2.3.0
[0.055 info Rack/src/window/Svg.cpp:28 loadFile] Loaded SVG C:/Program Files/Common Files/Cardinal/Cardinal/res/HostAudio.svg
[0.055 info Rack/src/window/Svg.cpp:28 loadFile] Loaded SVG C:/Program Files/Common Files/Cardinal/ComponentLibrary/ScrewBlack.svg
[0.056 info Rack/src/window/Svg.cpp:28 loadFile] Loaded SVG C:/Program Files/Common Files/Cardinal/ComponentLibrary/PJ301M.svg
[0.056 info Rack/src/window/Svg.cpp:28 loadFile] Loaded SVG C:/Program Files/Common Files/Cardinal/Cardinal/res/HostMIDI.svg
[0.056 info Rack/src/window/Svg.cpp:28 loadFile] Loaded SVG C:/Program Files/Common Files/Cardinal/Cardinal/res/HostTime.svg
[0.056 info Rack/src/window/Svg.cpp:28 loadFile] Loaded SVG C:/Program Files/Common Files/Cardinal/ComponentLibrary/SmallLight.svg
[0.056 info Rack/src/window/Svg.cpp:28 loadFile] Loaded SVG C:/Program Files/Common Files/Cardinal/Cardinal/res/HostParameters.svg
[0.057 info Rack/src/window/Svg.cpp:28 loadFile] Loaded SVG C:/Program Files/Common Files/Cardinal/Cardinal/res/HostParamsMap.svg
[0.057 info Rack/src/app/RackWidget.cpp:327 fromJson] Creating module widget DISTRHO Text Editor
[0.057 info Rack/src/app/RackWidget.cpp:327 fromJson] Creating module widget DISTRHO Audio 2
[0.057 info Rack/src/app/RackWidget.cpp:327 fromJson] Creating module widget DISTRHO Host MIDI
[0.057 info Rack/src/app/RackWidget.cpp:327 fromJson] Creating module widget DISTRHO Host Time
[0.057 info Rack/src/app/RackWidget.cpp:327 fromJson] Creating module widget DISTRHO Host Parameters
[0.057 info Rack/src/app/RackWidget.cpp:327 fromJson] Creating module widget DISTRHO Host Parameters Map
[0.057 info Rack/src/window/Svg.cpp:28 loadFile] Loaded SVG C:/Program Files/Common Files/Cardinal/ComponentLibrary/Plug.svg
[0.057 info Rack/src/window/Svg.cpp:28 loadFile] Loaded SVG C:/Program Files/Common Files/Cardinal/ComponentLibrary/PlugPort.svg
falkTX commented 1 year ago

What is your host passing as the bundle path during LV2 instantiation? I am thinking it is passing an empty string, which then triggers this issue. Or maybe missing the trailing separator at the end as required by the spec?

    /**
       Instantiate the plugin.
...
       @param bundle_path Path to the LV2 bundle which contains this plugin
       binary. It MUST include the trailing directory separator (e.g. '/') so
       that simply appending a filename will yield the path to that file in the
       bundle.
...
    */
    LV2_Handle (*instantiate)(const struct _LV2_Descriptor * descriptor,
                              double                         sample_rate,
                              const char *                   bundle_path,
                              const LV2_Feature *const *     features);
falkTX commented 1 year ago

actually found something related, with a potential fix in adfd2966386a44ca9b2160c251619cdf7198222f

mfisher31 commented 1 year ago

I'm using lilv_plugin_instantiate to instantiate the plugin, so i assume that's to LV2 spec. Any gotchas for building Cardinal on Windows? I'd like to verify your change.

falkTX commented 1 year ago

there are github actions in place which should have automated builds appear very soon, that is the easiest for testing

mfisher31 commented 1 year ago

Even better! Thanks

mfisher31 commented 1 year ago

Ok, tested it out and still getting Cardinal folder with json files from the current working directly: windows running host from command line. Love this plugin though BTW.

falkTX commented 1 year ago

thanks for testing, sounds like I need to try a couple of things on a local build until it works as intended.

mfisher31 commented 1 year ago

Yeah no problem! I'll load it up in REAPER, or another installed host and see what happens. I know little to nothing about windows. Maybe there's differences between running an app from a CMD prompt as opposed to launching from Explorer.

mfisher31 commented 1 year ago

I should have asked: where is the expected user data dir? somewhere in c:/Users/me/AppData ?

falkTX commented 1 year ago

user dir is $mydocs/Cardinal, the adfd2966386a44ca9b2160c251619cdf7198222f tried to fix that by using an alternative method to find "my documents" folder but still fails in the end

mfisher31 commented 1 year ago

Ok, got it thanks.
[0.000 info CardinalCommon.cpp:582 Initializer] Bundle path: C:/Program Files/Common Files/LV2/Cardinal.lv2/

Can't blame lilv . I'll check it out a little further.

mfisher31 commented 1 year ago

Could be this, regarding the 3rd parameter in SHGetFolderPathW use -1 instead of nullptr.

https://learn.microsoft.com/en-us/windows/win32/api/shlobj_core/nf-shlobj_core-shgetfolderpathw

Assigning the hToken parameter a value of -1 indicates the Default User. This enables clients
 of SHGetFolderPath to find folder locations (such as the Desktop folder) for the Default User. 
The Default User user profile is duplicated when any new user account is created, and includes 
special folders such as My Documents and Desktop. Any items added to the Default User 
folder also appear in any new user account.
falkTX commented 1 year ago

Issue was a silly missing break, that fell-through to a direct empty return {} :facepalm:

Fixed in b7ad2d26271662e273e7a83d24dfd514bf8694ed

Please confirm once the builds are available.

mfisher31 commented 1 year ago

It works! I tested da276ee

As for REAPER, it didn't create any files, anywhere. In this new build, all seems to be ok! Thanks