godot icon indicating copy to clipboard operation
godot copied to clipboard

Fix bad OGG importer's name inside .import files during project conversion

Open olefebvre3 opened this issue 2 years ago • 2 comments

This PR fixes the initial scene loading popup error from #73393. I've implemented a small fix based on the observations of @gotnospirit about the OGG Vorbis importer's name change between Godot 3.x and 4.x. Thus changing each

importer="ogg_vorbis"

line into

importer="oggvorbisstr"

inside "*.import" files, while in the conversion process, seem to prevent the scene loading error from occurring.

olefebvre3 avatar Mar 07 '23 23:03 olefebvre3

Just to be clear, what do you mean by crash? A crash usually refers to something like a segmentation fault, i.e. the program halts abruptly due to an illegal operation.

Here I expect the issue is just that some OGG files can't be loaded?

akien-mga avatar Mar 07 '23 23:03 akien-mga

Just to be clear, what do you mean by crash? A crash usually refers to something like a segmentation fault, i.e. the program halts abruptly due to an illegal operation.

Here I expect the issue is just that some OGG files can't be loaded?

I'll try to recap. Let me know is something still isn't clear.

When I tried yesterday to run the issue's sample project in 4.1dev (without the PR), I thought it had crashed because there was an error popup when loading "MainScene.tscn". So I thought it was the "crash" mentioned in the issue and therefore the import problem (misunderstanding on my part).

However, by trying a new conversion now, still without the PR, I noticed that the loading error popup of the scene was rather due to a problem with the loading of the TTF file, surely because this one does not have an ".import" file before the conversion and thus during the initial loading of the scene. When doing another conversion this time with the PR fix, I noticed that the scene loading error popup had disappeared.

Because of this, I think that the presence of the importer="ogg_vorbis" line (the old one) in the ".import" file of an OGG file seems to block part of the import process only during the initial launch of the converted project. After this initial launch, Godot automatically corrects the importer="ogg_vorbis" line to importer="oggvorbisstr ", even without my PR, but only after closing the scene loading error popup, so outside the scope of the conversion.

Thus, fixing the old importer line with the new one during the conversion prevents the initial scene pop error to appear.

Btw, the 4.0 stable release behaves the same as 4.1dev without the PR.

olefebvre3 avatar Mar 08 '23 09:03 olefebvre3

I did some testing and I can confirm that on 4.0.3, after initial conversion, the project on the first open shows this error:

image

And these errors in the terminal (most are to be expected when opening a project with existing .import files but no imported files):

ERROR: No loader found for resource: res://.import/night_theme.ogg-df5d434f7207740f45458a924fcef945.oggstr.
   at: _load (core/io/resource_loader.cpp:230)
ERROR: Failed loading resource: res://night_theme.ogg. Make sure resources have been imported by opening the project in the editor at least once.
   at: _load (core/io/resource_loader.cpp:222)
ERROR: res://Music.tscn:6 - Parse Error: [ext_resource] referenced non-loaded resource at: res://night_theme.ogg
   at: _parse_ext_resource (scene/resources/resource_format_text.cpp:174)
ERROR: Condition "!preset.is_valid()" is true. Continuing.
   at: load_config (editor/export/editor_export.cpp:227)
ERROR: Cannot open file 'res://.godot/imported/m6x11.ttf-bb038061aa28ea2a1e230221535a4e7a.fontdata'.
   at: get_dependencies (core/io/resource_format_binary.cpp:1249)
ERROR: Condition "!importer.is_valid()" is true. Continuing.
   at: reimport_files (editor/editor_file_system.cpp:2267)
ERROR: Condition "!importer.is_valid()" is true. Continuing.
   at: reimport_files (editor/editor_file_system.cpp:2267)
ERROR: Cannot open file 'res://.godot/imported/m6x11.ttf-bb038061aa28ea2a1e230221535a4e7a.fontdata'.
   at: load (core/io/resource_format_binary.cpp:1192)
ERROR: Failed loading resource: res://.godot/imported/m6x11.ttf-bb038061aa28ea2a1e230221535a4e7a.fontdata. Make sure resources have been imported by opening the project in the editor at least once.
   at: _load (core/io/resource_loader.cpp:222)
ERROR: Failed loading resource: res://m6x11.ttf. Make sure resources have been imported by opening the project in the editor at least once.
   at: _load (core/io/resource_loader.cpp:222)
ERROR: res://MainMenu.tscn:10 - Parse Error: [ext_resource] referenced non-loaded resource at: res://m6x11.ttf
   at: _parse_ext_resource (scene/resources/resource_format_text.cpp:174)
ERROR: res://MainMenu.tscn:10 - Parse Error: [ext_resource] referenced non-loaded resource at: res://m6x11.ttf
   at: load (scene/resources/resource_format_text.cpp:621)
ERROR: Failed loading resource: res://MainMenu.tscn. Make sure resources have been imported by opening the project in the editor at least once.
   at: _load (core/io/resource_loader.cpp:222)
ERROR: Index p_idx = 1 is out of bounds (edited_scene.size() = 1).
   at: remove_scene (editor/editor_data.cpp:581)
ERROR: Cannot open file 'res://.godot/imported/m6x11.ttf-bb038061aa28ea2a1e230221535a4e7a.fontdata'.
   at: get_dependencies (core/io/resource_format_binary.cpp:1249)

After closing the editor and reopening, the scene can be opened fine and everything is fixed.

With this PR applied on top of 4.0.3, it improves things slightly, as the error dialog no longer shows up, and the main scene loads fine.

The error spam is limited to this:

ERROR: No loader found for resource: res://.import/night_theme.ogg-df5d434f7207740f45458a924fcef945.oggstr.
   at: _load (core/io/resource_loader.cpp:230)
ERROR: Failed loading resource: res://night_theme.ogg. Make sure resources have been imported by opening the project in the editor at least once.
   at: _load (core/io/resource_loader.cpp:222)
ERROR: res://Music.tscn:6 - Parse Error: [ext_resource] referenced non-loaded resource at: res://night_theme.ogg
   at: _parse_ext_resource (scene/resources/resource_format_text.cpp:174)
ERROR: Condition "!preset.is_valid()" is true. Continuing.
   at: load_config (editor/export/editor_export.cpp:227)
ERROR: Cannot open file 'res://.godot/imported/m6x11.ttf-bb038061aa28ea2a1e230221535a4e7a.fontdata'.
   at: get_dependencies (core/io/resource_format_binary.cpp:1249)

In the master branch / 4.1 beta, the project seems to import fine after conversion with or without this PR. There's error spam too, but no blocking dialog preventing from opening the main scene. So this PR doesn't seem needed strictly speaking (it's expected that .import files will contain outdated info and what cannot be used will be replaced on load), but it shouldn't hurt, and can be cherry-picked to 4.0.

akien-mga avatar Jun 15 '23 13:06 akien-mga

For the record, your commit seems not to be linked to your GitHub account. See: Why are my commits linked to the wrong user? for more info.

Specifically, the problem is that your Git email address is invalid. See the header from https://github.com/godotengine/godot/pull/74580.patch

akien-mga avatar Jun 15 '23 13:06 akien-mga

Looks fine, but fixing the Git author info before merge would be good.

Should be good now.

olefebvre3 avatar Jun 15 '23 20:06 olefebvre3

Thanks! And congrats for your first merged Godot contribution :tada:

akien-mga avatar Jun 16 '23 08:06 akien-mga