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

Add an editor setting to import resources while unfocused #76991

Merged

Conversation

Calinou
Copy link
Member

@Calinou Calinou commented May 12, 2023

This can be used to speed up iteration by starting the import process earlier when saving files in the project folder. This also allows getting visual feedback on changes without having to click the editor window, which is useful with multi-monitor setups.

The downside is that this increases idle CPU usage and may steal CPU time from other applications when importing resources, so this is disabled by default.

This needs testing in various workflows, especially 3D ones with large scenes that can take a while to export. We need to make sure Godot doesn't try to import partially written files.

@Calinou Calinou requested a review from a team as a code owner May 12, 2023 05:29
@Calinou Calinou added this to the 4.x milestone May 12, 2023
@akien-mga
Copy link
Member

How will this behave when resources depend on each other? For example a .gltf with external textures. If it starts importing as soon as it sees the first file being added, it will likely fail.

@Calinou
Copy link
Member Author

Calinou commented May 19, 2023

How will this behave when resources depend on each other? For example a .gltf with external textures. If it starts importing as soon as it sees the first file being added, it will likely fail.

I could see this being an issue already with the current import system (if you focus the editor while a large glTF scene with separate textures is being written by a 3D DCC), but this will indeed be a more common occurrence with this setting enabled.

We should probably have a way to reject an import as "postponed" in this case if it doesn't fulfill certain conditions, such as the presence of other non-empty files.

@fire @lyuma Does Blender write the external textures first or the .gltf file first?

@fire fire requested a review from a team May 22, 2023 03:46
@Calinou Calinou force-pushed the editor-add-import-unfocused-setting branch from 9dd8049 to e32c0ed Compare February 1, 2024 19:30
@Calinou Calinou force-pushed the editor-add-import-unfocused-setting branch from e32c0ed to 6e8de46 Compare April 15, 2024 16:01
@Calinou
Copy link
Member Author

Calinou commented Apr 15, 2024

Rebased and tested again, it works as expected. I've changed the reimport timer from 1.0s to 0.5s to make reimporting quicker too.

This can be used to speed up iteration by starting the import process
earlier when saving files in the project folder. This also allows getting
visual feedback on changes without having to click the editor window,
which is useful with multi-monitor setups.

The downside is that this increases idle CPU usage and may steal CPU
time from other applications when importing resources, so this is
disabled by default.
@Calinou Calinou force-pushed the editor-add-import-unfocused-setting branch from 6e8de46 to ed54096 Compare April 15, 2024 17:40
Copy link
Contributor

@passivestar passivestar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works as expected on my end. Tested on a file with a bunch of beefy 4k textures

@akien-mga akien-mga modified the milestones: 4.x, 4.3 Apr 15, 2024
@akien-mga akien-mga merged commit c2d2ff6 into godotengine:master Apr 16, 2024
16 checks passed
@akien-mga
Copy link
Member

Thanks!

@timothyqiu
Copy link
Member

Is it intended that the periodic scan is also performed when the editor is still in focus?

@Calinou
Copy link
Member Author

Calinou commented Apr 16, 2024

Is it intended that the periodic scan is also performed when the editor is still in focus?

I don't know. I didn't specifically think about this scenario while implementing this, but it is possible for an external app to update a resource in the Godot project while the editor is focused. The main situation where this can occur is when exporting something that takes a while to export from an app like Blender, alt-tab to Godot, and have the export be completed while Godot is focused.

Does this work correctly when the editor is focused currently (when the new setting is disabled)? Ideally, this should always work regardless of this setting.

I expect we'll need to do some tweaking of the feature added here either way, as I don't expect this first iteration to be perfect. The polling frequency may need to be made adjustable too, or even automatically determined based on the duration of the last poll (so we don't poll too often in a large project).

@Calinou Calinou deleted the editor-add-import-unfocused-setting branch April 16, 2024 16:59
@lyuma
Copy link
Contributor

lyuma commented Apr 16, 2024

I am particularly concerned about instances where godot reads an incomplete file while it is being written. A classic example is exporting a large fbx or gltf from blender and then switching to godot before it is finished writing. Except now it could happen at any time.

in godot this can be very dangerous because it could refresh the scene while importing the broken file and lose data

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add an editor setting to import resources even when the editor window isn't focused
5 participants