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

Fix Plugin Scripts load twice on startup #102535

Conversation

Hilderin
Copy link
Contributor

@Hilderin Hilderin commented Feb 7, 2025

Thanks to @HolonProduction for helping fix this issue.!!

The issue was caused by the plugin script being loaded twice on startup when the same script is used in the plugin's ready method and as an autoload. Autoloads are created before plugins, triggering the first load. When the plugin is enabled, the script is loaded again with CACHE_MODE_IGNORE, causing it to reload while await calls are still running.

I changed the cache mode to CACHE_MODE_REUSE when enabling plugins on editor startup (while the first scan is running).

I tested this with the MRP from #100750, and as suggested by @HolonProduction, I also retested the MRP from #70667. Godot's startup process has changed quite a bit since this issue was first reported. Since #92667, scripts that reference resources can now load even before the first scan, allowing the project to load without any errors or warnings on the first startup without the .godot folder.

I have kept CACHE_MODE_IGNORE when the editor is not in startup mode to prevent potential side effects.

@HolonProduction
Copy link
Member

I think you meant to link to #100750, not my PR 😅

@Hilderin
Copy link
Contributor Author

Hilderin commented Feb 7, 2025

Totally right! I changed it. Thanks!

@Hilderin Hilderin force-pushed the fix-plugin-scripts-load-twice-on-startup branch from 94ecf45 to 7a8bb59 Compare February 7, 2025 15:55
@Hilderin Hilderin force-pushed the fix-plugin-scripts-load-twice-on-startup branch from 7a8bb59 to 7f89294 Compare February 7, 2025 15:57
Copy link
Member

@HolonProduction HolonProduction left a comment

Choose a reason for hiding this comment

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

Tested with #100750 and couldn't reproduce any errors in ~20 attempts. I was experiencing the issue around every three tries before, so quite confident that this is fixed.

Wasn't able to reproduce #70667 with this as well.

Also think it makes sense to still reload after the initial scan, since that's usually triggered by explicit user actions.

@Repiteo Repiteo merged commit 9554481 into godotengine:master Feb 7, 2025
20 checks passed
@Repiteo
Copy link
Contributor

Repiteo commented Feb 7, 2025

Thanks!

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.

Godot 4.4 throws errors when using await on EditorPlugin
4 participants