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

Errors after setting custom theme in project settings #54752

Closed
Deozaan opened this issue Nov 8, 2021 · 15 comments · Fixed by #55483
Closed

Errors after setting custom theme in project settings #54752

Deozaan opened this issue Nov 8, 2021 · 15 comments · Fixed by #55483

Comments

@Deozaan
Copy link

Deozaan commented Nov 8, 2021

Godot version

v3.4.stable.official [206ba70]

System information

Windows 10

Issue description

I'm using a custom theme in my project. Instead of having to remember to manually set the custom theme override for each Control node in various scenes to be able to get an accurate preview, I've set the custom theme in the Project Settings.

Godot 3 4 Bug Report - Project Settings Custom Theme

When I press F5 (or F6) to test the project/scene I get a bunch of errors related to loading the theme and custom images as the window launches.

E 0:00:00.724   _load_data: Condition "img.is_null() || img->empty()" is true. Returned: ERR_FILE_CORRUPT
  <C++ Source>  scene/resources/texture.cpp:566 @ _load_data()
E 0:00:00.731   _load: Failed loading resource: res://.import/GuiChecked.svg-40071e1e72cdcbe9d0e9ea53c8ee9f94.stex. Make sure resources have been imported by opening the project in the editor at least once.
  <C++ Error>   Condition "found" is true. Returned: RES()
  <C++ Source>  core/io/resource_loader.cpp:270 @ _load()
E 0:00:00.738   _load: Failed loading resource: res://assets/ui/GuiChecked.svg. Make sure resources have been imported by opening the project in the editor at least once.
  <C++ Error>   Condition "found" is true. Returned: RES()
  <C++ Source>  core/io/resource_loader.cpp:270 @ _load()
E 0:00:00.745   poll: res://theme.tres:4 - Parse Error: [ext_resource] referenced nonexistent resource at: res://assets/ui/GuiChecked.svg
  <C++ Source>  scene/resources/resource_format_text.cpp:412 @ poll()
E 0:00:00.749   load: Failed to load resource 'res://theme.tres'.
  <C++ Error>   Condition "err != OK" is true. Returned: RES()
  <C++ Source>  core/io/resource_loader.cpp:206 @ load()
E 0:00:00.755   _load: Failed loading resource: res://theme.tres. Make sure resources have been imported by opening the project in the editor at least once.
  <C++ Error>   Condition "found" is true. Returned: RES()
  <C++ Source>  core/io/resource_loader.cpp:270 @ _load()
E 0:00:00.759   register_scene_types: Error loading custom theme 'res://theme.tres'
  <C++ Source>  scene/register_scene_types.cpp:795 @ register_scene_types()

If I unset the custom theme from Project Settings and just set my top-most Control node's Theme override to use the custom theme, these errors go away. Furthermore, when I have the custom theme configured as a project setting and launch a scene which doesn't have any Control nodes (i.e., no custom theme set or referenced in the scene), I still get these errors. This leads me to believe that my custom theme is okay, and all the related files are okay, but that the problem is somehow related to how the custom theme interacts with the Project Settings.

Steps to reproduce

  1. Open minimal reproduction project and press F5.
  2. Check Errors tab of Debugger to see the errors.

Minimal reproduction project

CustomThemeBugReport.zip

@YuriSizov
Copy link
Contributor

Hmm, I wonder if the problem is related to the usage of SVG for icons, instead of, say, PNG.

@Deozaan
Copy link
Author

Deozaan commented Nov 8, 2021

I just tested that hypothesis by removing the SVG images from the custom theme and replacing one of them with a PNG. I get the same 7 errors in the same order, but of course this time they refer to the PNG where they used to refer to the SVG.

@Deozaan
Copy link
Author

Deozaan commented Nov 8, 2021

And perhaps I should clarify that everything appears to work properly even with the errors. It's just that I think these errors should not be happening when launching the project.

So I think that it's just some code happening in the wrong order while initializing the window. It's like it tries to reference the theme on startup before the rest of the engine is ready for that. But then once the rest of the engine catches up and it displays my Control nodes, the custom theme can be accessed without problems.

EDIT: I was wrong. See my next comment for more details.

@AureaFUNSoft
Copy link

AureaFUNSoft commented Nov 9, 2021

I also encounter similar problem. In my case i use webp image, then when I run the the game, Theme is not working and the theme just reverted to default.

@Deozaan
Copy link
Author

Deozaan commented Nov 9, 2021

AureaFUNSoft's comment got me to double check, because I thought the theme was working despite these errors. And I found something interesting.

If I close the project, delete the .import folder, then open the project again in Godot 3.3.4, the custom theme setting in the Project Settings works without problems. If I then close the project and open it again in Godot 3.4, the custom theme settings in the Project Settings also works without problems (no errors).

But if I then delete the .import folder again and open the project in Godot 3.4, I get the errors and the custom theme does not work. The issue seems to be related to how Godot 3.4 imports the theme. If Godot 3.3.4 imports the theme, then Godot 3.4 can read it just fine. But if Godot 3.4 imports the theme, I get errors.

So the current workaround is to delete the .import folder, import the project in 3.3.4, then relaunch the project using Godot 3.4.

@ghost
Copy link

ghost commented Nov 14, 2021

I have the same issue on the same version, Windows 10, GLES3, NVIDIA GeForce GT 540M, graphics driver version 23.21.13.9135, Intel(R) Core(TM) i7-2670QM CPU @ 2.20GHz.

The issue occurred when I added a texture to CheckButton by dragging an imported graphic from the editor - the theme stopped displaying, the same errors appeared. Adding a new StreamTexture to CheckButton and manually setting the resource to res://.import/button.png-76b80516a6ac8aaf48535d9d57e0549f.stex caused the theme to start displaying, but the CheckButton texture still does not appear, and the following errors appeared:
ERROR: Condition "img.is_null() || img->empty()" is true. Returned: ERR_FILE_CORRUPT
at: _load_data (scene/resources/texture.cpp:566)
ERROR: Condition "img.is_null() || img->empty()" is true. Returned: ERR_FILE_CORRUPT
at: _load_data (scene/resources/texture.cpp:566)
After restarting the editor, the paths to the resources in StreamTexture are emptied.

AaronWizard added a commit to AaronWizard/LegendsOfMajesticSteel that referenced this issue Nov 25, 2021
@Sirgulator
Copy link

Sirgulator commented Nov 30, 2021

Tested with 3.4 and 3.4.1rc1 (Linux)
Having the same issue, could trigger the behavior by setting the filtering of a PNG used by the theme and re-importing, since then got this message:

ERROR: Condition "img.is_null() || img->empty()" is true. Returned: ERR_FILE_CORRUPT
   at: _load_data (scene/resources/texture.cpp:566)
ERROR: Failed loading resource: res://.import/themetex.png-363ab9f9e3582cb36e37300b1020dd30.stex. Make sure resources have been imported by opening the project in the editor at least once.
   at: _load (core/io/resource_loader.cpp:270)
ERROR: Failed loading resource: res://GUI/themetex.png. Make sure resources have been imported by opening the project in the editor at least once.
   at: _load (core/io/resource_loader.cpp:270)
ERROR: res://GUI/custom-theme.tres:3 - Parse Error: [ext_resource] referenced nonexistent resource at: res://GUI/themetex.png
   at: poll (scene/resources/resource_format_text.cpp:412)
ERROR: Failed to load resource 'res://GUI/custom-theme.tres'.
   at: load (core/io/resource_loader.cpp:206)
ERROR: Failed loading resource: res://GUI/custom-theme.tres. Make sure resources have been imported by opening the project in the editor at least once.
   at: _load (core/io/resource_loader.cpp:270)
ERROR: Error loading custom theme 'res://GUI/custom-theme.tres'
   at: register_scene_types (scene/register_scene_types.cpp:797)

@akien-mga akien-mga changed the title [3.4] Errors after setting custom theme in project settings Errors after setting custom theme in project settings Nov 30, 2021
@akien-mga akien-mga added this to the 3.5 milestone Nov 30, 2021
@YuriSizov
Copy link
Contributor

YuriSizov commented Nov 30, 2021

This is not actually a regression. Under the same circumstances, this used to crash the editor on project open, see #51003. I've just tried again with 3.3-stable with the MRP from this report, and it does indeed just crash on open.

My previous PR fixed the crash, but my research didn't actually lead me to an understanding of what is going on here, see #51014. I think that WebP module is not loaded (yet?) when we attempt to load the theme and its subresources — icons.

It is indeed irrelevant what format the source images are in, the StreamTexture is trying to load its internal data which is in WebP. So the errors here are the same for SVGs and PNGs alike.

@Deozaan
Copy link
Author

Deozaan commented Nov 30, 2021

This is not actually a regression. Under the same circumstances, this used to crash the editor on project open, see #51003. I've just tried again with 3.3-stable with the MRP from this report, and it does indeed just crash on open.

My previous PR fixed the crash, but my research didn't actually lead me to an understanding of what is going on here, see #51014. I think that WebP module is not loaded (yet?) when we attempt to load the theme and its subresources — icons.

I'm not sure that what you're describing fully explains this issue.

The MRP project crashes for me in 3.3.4-stable as well. But I assumed that was because the files were imported using 3.4-stable, and that it wasn't backwards compatible. If I delete the .import folder, then the project will open without errors in 3.3.4-stable. And then, using the .import folder from 3.3.4-stable, I can also open the project in 3.4-stable without any errors.

I didn't start to see these errors in 3.4-stable until I deleted the .import folder from my project I had started in 3.3.4-stable and allowed v3.4-stable to re-import all the project assets.

So it seems to me that it has more to do with how 3.4 is trying to import the files than it has to do with waiting for things to be loaded.

@YuriSizov
Copy link
Contributor

YuriSizov commented Nov 30, 2021

It is absolutely because of the load order. Your observations are explained by #47854 also being a part of 3.4. The way the textures are imported by default has changed and WebP module is now required.

@Deozaan
Copy link
Author

Deozaan commented Nov 30, 2021

Understood. Thank you for explaining.

@Sirgulator
Copy link

Is this expected to be fixed for 3.4 release? Currently the only breaking bug we have before release later this month.

So as I understand correctly, if i would open the project in 3.3.4 and generate a .import file for the Theme and related textures, it would work in 3.4 as long as you not re-import the assets?
How would this behave on exporting the game?

@YuriSizov
Copy link
Contributor

YuriSizov commented Dec 2, 2021

Is this expected to be fixed for 3.4 release?

It's not been merged yet, but yes, #55484 can be cherry-picked for a 3.4.x patch.

So as I understand correctly, if i would open the project in 3.3.4 and generate a .import file for the Theme and related textures, it would work in 3.4 as long as you not re-import the assets?

Theme doesn't have an import file, it's a natural Godot resource. The problem is with images, they need to be imported with 3.3.4, so that they are stored as PNGs instead of WebPs (internally, as a part of StreamTexture resource).

I think you can also fix this in 3.4 temporarily by forcing it to import PNGs. See the rendering/lossless_compression/force_png setting. The downside would be bigger size for imported resources (and therefore for the exported project).

How would this behave on exporting the game?

The 3.3 trick should work, as long as you run it on the same machine with pregenerated .import folder.

@rockgem
Copy link

rockgem commented Dec 4, 2021

im having the same problems, and when i try to load my project in 3.3.4 it simply crashes. it definitely isn't backwards compatible.

@YuriSizov
Copy link
Contributor

im having the same problems, and when i try to load my project in 3.3.4 it simply crashes. it definitely isn't backwards compatible.

You need to delete the .import folder before opening your project in 3.3. That's because 3.3 is not forward compatible with some changes in 3.4. You should also be able to avoid the issue in 3.4 itself by forcing PNG imports (see discussion above). Or you can wait for 3.4.1 patch that fixes the issue with the default setting.

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

Successfully merging a pull request may close this issue.

7 participants