godot
godot copied to clipboard
Long Paths in Windows cause `ERROR: Condition "f.is_null()" is true.`
Tested versions
Reproducible in both: v4.3.dev.custom_build [d4f726f3e] (latest build from Master) and v4.2.stable.official [46dc27791]
So not a new thing.
System information
Godot v4.3.dev (d4f726f3e) - Windows 10.0.22621 - Vulkan (Forward+) - dedicated NVIDIA GeForce RTX 3080 Ti (NVIDIA; 31.0.15.5222) - AMD Ryzen 9 5900X 12-Core Processor (24 Threads)
Issue description
Long paths in Windows will cause this error on loading projects:
ERROR: Condition "f.is_null()" is true.
at: ShaderRD::_save_to_cache (servers\rendering\renderer_rd\shader_rd.cpp:474)
Steps to reproduce
I did this in Windows 11 in PowerShell.
cd c:\
mkdir ten1111111\twenty1111\thirty1111\forty11111\fifty11111
cd ten1111111\twenty1111\thirty1111\forty11111\fifty11111
gh repo clone godotengine/godot-demo-projects
cd .\godot-demo-projects\3d\antialiasing\
godot.windows.editor.x86_64.exe --import
You don't have to use --import but it is an easy way to open/close the editor in one shot and it always produces the error.
Minimal reproduction project (MRP)
This seems to happen with any project that has sufficient content. My guess is that it has to do with the folder nesting and file name lengths in the project.
I used the Godot Demo Projects, specifically the 3D Anti-Aliasing demo in my example above as it produces the error consistently.
Shader cache directories can indeed be pretty long, with this kind of format:
.godot/shader_cache/Fsr2ComputeLuminancePyramidPassShaderRD/b79145b5e865e2cb1debff5e6f3073b94a76ff83f389bfd8a348677336e72982/
So adding that to an already long path like
C:\ten1111111\twenty1111\thirty1111\forty11111\fifty11111
might indeed start hitting some Win32 path limits of 256 chars.
I think there are ways to raise this limit nowadays though? CC @bruvzg
With \\?\ prefix, limit should be 32K. Maybe we aren't using it everywhere.
If the path is relative we don't use \\?\ as far as I can tell
I discovered this when I was using the Windows default temp folder to run some Godot apps and they failed because the default Windows temp folder is already pretty long and adding a couple of nested folders hit the limit:
C:\Users\chris\AppData\Local\Temp
As another example, there are a lot of Steam games sitting in folders with longer paths:
C:\ten1111111\twenty1111\thirty1111\forty11111\fifty11111
C:\Program Files (x86)\Steam\steamapps\common\Halo The Master Chief Collection
Anything in steam is going to bump into this pretty quickly if our game name isn't very short, although I guess that typically wouldn't be game source, but rather a .pck file. Still, just an example of long paths being pretty common.
Seems like for some use cases (like current directory) adding \\?\ is not sufficient, and we should also set opt in in in the app manifest.