Godot version:
3.1 stable
OS/device including version:
Windows 10
Issue description:
Every so often, when I press F5 to start my project, the Project list opens instead.
Related https://github.com/godotengine/godot/issues/11391, though now it happens quite rarely
I wouldn't say rarely. I'll definitely see it more than once on any given day doing development in Godot.
Yes, it's rare, but I can confirm it happens.
As far as I know this happens if some process has locked your project.godot file (might be Godot itself by saving it before running) and Windows is sadly incapable of reading a file that it being written to.
One solution could be to enforce a delay between saving and running the project to make sure that Windows file accesses won't conflict.
I may be wrong, I've only started looking at this, but:
We seem to use _wfopen_s() on Windows.
The Windows docs for that state:
Files that are opened by fopen_s and _wfopen_s are not sharable.
If you require that a file be sharable, use _fsopen, _wfsopen with the appropriate sharing mode constant—for example, _SH_DENYNO for read/write sharing.
And if you look for _SH_DENYNO and fsopen(), those seem to be used a lot in OSS code to get around similar issues.
Example: https://codereview.chromium.org/668022
Issue 668022: Change default fopen() on Windows from fopen_s() to fsopen(,,_SH_DENYNO)
Change default fopen() on Windows from fopen_s() to fsopen(,,_SH_DENYNO). fopen_s() won't let you open a file that is open by another process. This has the unfortunate property of triggering a race condition in Python exposed by running run-webkit-tests using a lot of threads and spawning off image_diff. There doesn't seem to be a good reason to disallow files that are open in other processes, so I'm changing this.
So could this be a possible fix?
If the file was shareable, would it still allow to read it properly and not half-modified? I find it strange that Godot attempts to modify/lock it while launching the game (without waiting for all files of the project to be properly saved, that is). If that's the case, that should be fixed instead of hiding the symptom.
I never had this problem in 3.1 though, so can't repro (I never use F5 however, if that even matters).
By default, Godot always saves the project before running. You can disable this in the Editor Settings (Run → Auto Save → Save Before Running). Try disabling it and see if the bug still occurs to confirm this.
I'm working on a PR to address the locking behaviour as per my comment above, may take some time however, file locking is icky to test.
This is happening to me. It seems to happen quite consistently when I edit a script and then attempt to run the project. If I use play scene instead, I get a window with nothing but gray inside.
Using Windows 7, Godot 3.1.1
https://cdn.discordapp.com/attachments/477544613511692358/581843684916723733/unknown.png
happens very frequently to me, windows 10 godot 3.1.1. When it starts happening it usually continues happening unless I fiddle around with my tabs.
@mhilbrunner Do you have any progress?
Happens very frequently to me too on latest build
Never happened to me before upgrading to 3.1.2. Now it happens multiple times a day.
Hi there,
I have the same issue, and maybe it's just a coincidence, but it seems more present since 3.2.
For me it's by pressing F6.
Fun fact : if I define a main scene in the project settings, F6 (on another scene) no longer launches the project manager but the main scene. 🤷♂️
https://www.youtube.com/watch?v=NzuZhAc7N8I
Using Windows 10 Pro 64bits v1909 (18363.592) and Godot v3.2.stable.official / Same issue on Debian (WSL)
Edit : If I define the problematic scene as the main scene, no more trouble
Happens to me after editing shaders or opening a singleton CanvasLayer scene in v3.2.2rc1, not even sure if it's just a coincidence or not.
On win 7, godot 3.2.3, always after editing shaders. Even if I change to another scene tab.
I've been having this problem for a long time (since 3.1, I think). I've returned to Godot from a long hiatus since yesterday, and it's been happening to me quite a lot (on 3.2.3.stable), which is why I'm here. Sometimes it does this many times in a row.
I'm on Windows 7.
@NoodleSushi @Skaruts @Avarobin Does the workaround below work? I'm trying to isolate what could be the cause of the issue.
By default, Godot always saves the project before running. You can disable this in the Editor Settings (Run → Auto Save → Save Before Running). Try disabling it and see if the bug still occurs to confirm this.
After disabling auto save, you'll have to press Ctrl + S before running the project to see your changes.
Most helpful comment
I may be wrong, I've only started looking at this, but:
https://github.com/godotengine/godot/blob/09e94aa087485ccf5b4318c4a619db4f6b067cc5/drivers/windows/file_access_windows.cpp#L117
We seem to use
_wfopen_s()on Windows.The Windows docs for that state:
And if you look for
_SH_DENYNOandfsopen(), those seem to be used a lot in OSS code to get around similar issues.Example: https://codereview.chromium.org/668022
So could this be a possible fix?