Hello everyone! I could use a second set of eyes on an bug reported by a user.
===========UPDATE============
I originally thought that the code that wasn’t loading the background first checked if the file exists. However, as I’ve been digging in, that’s probably not where the issue is happening.
==============================
A little while ago, Pgatt contacted me and said,
Just letting you know, I’ve seen a couple of bug reports in the last couple of days where Rack is crashing and Voxglitch is saying it can’t find a background, and then crashes. The first one I thought was just user error but I’ve now seen it three times in a short span.
[3.067 warn src/window/Window.cpp:844 loadImage] Cannot read file /Users/usersname/Documents/Rack2/plugins/voxglitch/res/themes/default/background2.jpg
In response, in order to patch this quickly, I added code to check to ensure that the background exists before attempting to load it. At the very least, this would avoid a crash. I knew that this wasn’t a good long-term fix. I knew that the missing background would still cause problems. I just wanted to buy myself some time to look into it.
Sure enough, a user contacted me soon after my update. Modues that were using my theming code weren’t loading their backgrounds:
There seemed to be some part of my theming system that wasn’t working for this Windows user.
I asked the user to confirm all of the paths and capitalization of the files and folders. He sent screen captures of the file locations, such as:
Everything looked OK to me. The log file that he sent me contained the following information about his system:
[0.003 info adapters/standalone.cpp:129 main] VCV Rack Free v2.1.2
[0.003 info adapters/standalone.cpp:130 main] Windows 10.0
[0.003 info adapters/standalone.cpp:136 main] Args: C:\Program Files\VCV\Rack2Free\Rack.exe
[0.003 info adapters/standalone.cpp:139 main] System directory: C:\Program Files\VCV\Rack2Free
[0.003 info adapters/standalone.cpp:140 main] User directory: C:/Users/Aurélien/Passeport Elise/Rack2
[0.003 info adapters/standalone.cpp:144 main] System time: 2022-11-14 21:09:40 Paris, Madrid
[0.003 info src/settings.cpp:488 load] Loading settings C:/Users/Aurélien/Passeport Elise/Rack2/settings.json
Although the path to his User directory showed unusual characters in the log file, that didn’t pose an issue to other modules. For example:
[1.783 info src/window/Svg.cpp:28 loadFile] Loaded SVG C:/Users/Aurélien/Passeport Elise/Rack2/plugins/Prism/res/ComponentLibrary/prism_Switch3_2-08.svg
The code I use to load the reportedly missing background looks like:
void addSVGLayer(std::string svg_path)
{
if(rack::system::exists(asset::plugin(pluginInstance, svg_path)))
{
std::shared_ptr<Svg> svg = APP->window->loadSvg(asset::plugin(pluginInstance, svg_path));
VoxglitchPanel *voxglitch_panel = new VoxglitchPanel;
voxglitch_panel->setBackground(svg);
addChild(voxglitch_panel);
}
}
In the above code, rack::system::exists(asset::plugin(pluginInstance, svg_path))
is reporting false.
The immediate question that comes to mind is: What is svg_path set to?
That gets just a little bit complicated.
Step #1: A Voxglitch.json config file is loaded from asset::user. If it doesn’t exist, it’s copied into place from the res/ folder.
if(! rack::system::exists(asset::user("Voxglitch.json")))
{
rack::system::copy(asset::plugin(pluginInstance, "res/voxglitch_config.json"), asset::user("Voxglitch.json"));
}
Step #2: From there, it’s loaded and parsed to get the “theme” name, which is either “default” or “light”.
There are a few parts of this process which could quietly fail. I wouldn’t mind adding WARN messages if they did, but I haven’t gotten the OK to add WARN messages yet.
Regarless, my hunch is that, up to now, everything is functioning OK. Why? Because if you look at pgatt’s original error message:
Cannot read file /Users/usersname/Documents/Rack2/plugins/voxglitch/res/themes/default/background2.jpg
You can see that the “default” theme is being used. (It’s a long story, but I had the wrong default theme name set to “dark” when pgatt first reported the bug, so I knew that the correct “default” theme name was being loaded from the config file.)
Step #3: Each module has the following folders:
- /res/{{module_name}}/themes/default
- /res/{{module_name}}/themes/light
In each folder is a config.json which contains the path to the background file.
For example:
That theme configuration file is parsed and the path to the background is loaded.
The answer to the question, “What’s svg_path set to?” is:
/Users/{{ usersname }}/Documents/Rack2/plugins/voxglitch/res/themes/default/background2.jpg
I asked the user to confirm that those files existed, and he said that they do:
At this point, I’m rather stuck.
- I don’t see any missing files on the user’s computer.
- I don’t see any capitalization errors.
- Although he’s using a different language for his Windows, it doesn’t seem to be a problem for any of his other modules.
- Other Windows users are successful in using my modules
- I don’t have any logging capabilities for learning more about his issue.
Any recommendations? Thanks!