Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Project files are accessed each time Godot gains focus #32086

Closed
NelloDev opened this issue Sep 11, 2019 · 11 comments
Closed

Project files are accessed each time Godot gains focus #32086

NelloDev opened this issue Sep 11, 2019 · 11 comments

Comments

@NelloDev
Copy link

Godot version:
Godot_v3.1.1-stable_x11.64
OS/device including version:
5.2.11-arch1-1-ARCH
Issue description:
Several project files are accessed or modified each time Godot gains focus. Here is a logfile from inotifywait that was set to monitor the project directory

11-09-2019 04:00:47 icon.png.import OPEN
11-09-2019 04:00:47 icon.png.import CLOSE_NOWRITE,CLOSE
11-09-2019 04:00:47 icon.png.import OPEN
11-09-2019 04:00:47 icon.png.import CLOSE_NOWRITE,CLOSE
11-09-2019 04:00:47 icon.png.import OPEN
11-09-2019 04:00:47 icon.png.import ACCESS
11-09-2019 04:00:47 icon.png.import CLOSE_NOWRITE,CLOSE
11-09-2019 04:00:47 icon.png.import OPEN
11-09-2019 04:00:47 icon.png.import ACCESS
11-09-2019 04:00:47 icon.png.import CLOSE_NOWRITE,CLOSE
11-09-2019 04:00:47 icon.png.import OPEN
11-09-2019 04:00:47 icon.png.import ACCESS
11-09-2019 04:00:47 icon.png.import CLOSE_NOWRITE,CLOSE
11-09-2019 04:00:47 project.godot ATTRIB

https://streamable.com/h4jkk

This happens every time Godot loses and regains focus. The file "project.godot" has its "last modified" attribute updated each time this happened which was triggering a backup on my system.
Steps to reproduce:
Open any project in Godot
Switch focus away from Godot then back to it.

@groud
Copy link
Member

groud commented Sep 11, 2019

I think this is expected, Godot checks for changes in files to update the view is the files were modified with an external editor.

@NelloDev
Copy link
Author

@groud I did some more digging and it looks like project.godot is read when the project is opened to populate the Project List in the Project Manager. If you edit project.godot in an external editor then open Godot those changes will be reflected in the Project Manager.

Once the project is open in Godot the files don't appear to be read. If you edit project.godot the changes aren't reflected in Godot. Actually now that I've played with it it looks like both project.godot and icon.png.import are overwritten each time Godot gains focus. Why would that happen on focus?

@Zylann
Copy link
Contributor

Zylann commented Sep 11, 2019

Do you mean Godot actually opens the file for writing? That would be strange to do that on focus compared to a read.

@KoBeWi
Copy link
Member

KoBeWi commented Sep 11, 2019

Actually, the files shouldn't be opened at all if their modified date didn't change since last check. That would make sense at least.

@Zylann
Copy link
Contributor

Zylann commented Sep 11, 2019

But as I understood, opening the file (for read I asume) IS the way Godot tests for that, isn't it? Otherwise it needs OS-specific code (or use stat)

@KoBeWi
Copy link
Member

KoBeWi commented Sep 11, 2019

No, there's a get_modified_time(). I've seen it in few places, not sure about this case.

@NelloDev
Copy link
Author

Well, it looks like icon.png.import is opened and read on focus regardless of whether or not it was modified. Also, I can't figure out why but when I modify it externally then give Godot focus it will either read the file or the file will be overwritten with whatever the Godot has loaded and any changes are lost.

I don't know how to make this happen (or make it stop when it starts) but it will seemingly discard/overwrite my changes to icon.png.import while also happily accepting changes made in default_env.tres and to icon.png.

@nikolatesla20
Copy link

No, there's a get_modified_time(). I've seen it in few places, not sure about this case.

How would that help though unless godot is storing mod dates for every file? Are we sure its not using a hash comparison, in which case it would have to read the file?

@KoBeWi
Copy link
Member

KoBeWi commented Sep 11, 2019

How would that help though unless godot is storing mod dates for every file?

Modified time is part of file's metadata, like the name. It's handled by OS.

@NelloDev
Copy link
Author

To add on to this: I didn't notice there was a hidden .import folder that contains icon.png[...].md5 and icon.png[...].stex. These are also open and read on focus

12-09-2019 21:35:06 icon.png-487276ed1e3a0c39cad0279d744ee560.md5 OPEN
12-09-2019 21:35:06 icon.png-487276ed1e3a0c39cad0279d744ee560.md5 ACCESS
12-09-2019 21:35:06 icon.png-487276ed1e3a0c39cad0279d744ee560.md5 CLOSE_NOWRITE,CLOSE
12-09-2019 21:35:06 icon.png-487276ed1e3a0c39cad0279d744ee560.stex OPEN
12-09-2019 21:35:06 icon.png-487276ed1e3a0c39cad0279d744ee560.stex CLOSE_NOWRITE,CLOSE

@darksylinc
Copy link
Contributor

I've been looking into this issue.

This bug was fixed by #95678 and should be part of Godot 4.4 when it comes out.

I didn't check 3.x. Unless 3.x is EOL or this issue won't be fixed for 3.x; I suggest to close this ticket.

@KoBeWi KoBeWi closed this as completed Dec 13, 2024
@KoBeWi KoBeWi added this to the 4.4 milestone Dec 13, 2024
@akien-mga akien-mga added the bug label Dec 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants