godot icon indicating copy to clipboard operation
godot copied to clipboard

Fix loss of gdextension on editor startup

Open Hilderin opened this issue 1 year ago • 8 comments

  • Fixes #97900
  • Fixes #97962
  • Fixes #98056
  • Fixes #97735

The GDExtension files were not processed in EditorFileSystem::_first_scan_process_scripts following optimization in #95678.

Thanks to @NetroScript to pinpoint the problem and find the solution. This PR is based on it's suggested modifications. That's why I added him as Coauthor.

I think your approach to use ResourceLoader::get_recognized_extensions_for_type is the right one. It's sounds like a bug to me that the method returns .res and .tres for GDExtension. I'm not an expert of the GDExtensions but I'm pretty sure .res and .tres are not supported for GDExtensions. If you check into GDExtensionLibraryLoader::parse_gdextension_file, it only supports a ConfigFile format and not a resource file. It does not seems easy to modify ResourceLoader::get_recognized_extensions_for_type to not return .res and .tres for GDExtension and I'm worry about side effects so I think that excluding .res and .tres extensions in _first_scan_filesystem seems the right way to me.

Edited: Adding #97962 in the fixed issue list. Edited: Adding #98056 in the fixed issue list.

Hilderin avatar Oct 10 '24 00:10 Hilderin

This should also fix https://github.com/godotengine/godot/issues/97962

FireCatMagic avatar Oct 10 '24 00:10 FireCatMagic

Thanks for the fast PR. When I checked it out I also found no way to exclude res and tres. As all resource loaders get iterated to find extensions the ResourceFormatLoaderBinary for example also is iterated, which returns true for all handled types (there in theory it would be possible to add an exclusion from my uneducated observations), which causes res to be added.

NetroScript avatar Oct 10 '24 08:10 NetroScript

Exactly! We will see what reviewers think about that.

Hilderin avatar Oct 10 '24 09:10 Hilderin

This also fixes gdextensions not loading on android: https://github.com/godotengine/godot/issues/98056

TCROC avatar Oct 10 '24 14:10 TCROC

I think we should rename and attempt to modify ResourceLoader::get_recognized_extensions_for_type to not return .res and .tres for GDExtension

Or at least see that its too difficult

fire avatar Oct 12 '24 15:10 fire

It's not exactly a bug. ResourceFormatLoaderText/Binary handle any type of Resource

I haven't tested it, but I don't think re-saving a .gdextension file as .tres/.res would result in a working GDExtension, because the GDExtension resource class doesn't keep all its data in registered properties. If there's a way to prevent re-saving as a .tres/.res we should probably do that - although, that's not in scope for this PR.

dsnopek avatar Oct 15 '24 12:10 dsnopek

It's similar issue to #34080

KoBeWi avatar Oct 15 '24 13:10 KoBeWi

As suggested by @fire, I modified code to prevent ResourceLoader::get_recognized_extensions_for_type returning res and tres extensions for GDExtension. I little if added in ResourceFormatLoaderBinary::get_recognized_extensions_for_type and ResourceFormatLoaderText::get_recognized_extensions_for_type did the trick.

Hilderin avatar Oct 20 '24 22:10 Hilderin

Thanks!

Repiteo avatar Oct 21 '24 21:10 Repiteo