dialogic-godot / dialogic

💬 Create Dialogs, Visual Novels, RPGs, and manage Characters with Godot to create your Game!
https://dialogic.pro
MIT License
3.35k stars 206 forks source link

Subsystems not loaded on 4.3 exported builds #2156

Closed monitz87 closed 1 month ago

monitz87 commented 1 month ago

The problem

Describe the bug

Summary: Godot 4.3 re-added script compilation to exported builds, which causes issues when Dialogic inspects the file system

Similar to #1587 , using FileAccess.file_exists instead of ResourceLoader.exists causes trouble when running exported builds that convert scripts into binary. .gd files get turned into .gdc and .gd.remap, which makes FileAccess.file_exists return false even if the script actually exists. ResourceLoader.exists on the other hand knows how to handle these remappings and returns true as it should. In this specific scenario, when the Dialogic singleton is loading the subsystems, the indexer scripts aren't found, so no subsystems are loaded, which causes other errors down the line.

I don't see any reason to use FileAccess.file_exists over ResourceLoader.exists anywhere in Dialogic tbh. At the moment, there are plenty of occurrences of the former across the codebase. ResourceLoader.exists is more robust against export remap shenanigans, and unless I'm mistaken, all file manipulation in Dialogic is internal to the game that is using it.

To Reproduce Steps to reproduce the behavior:

  1. Create a script in your project that accesses any Dialogic subsystem (e.g Dialogic.Styles.load_style("foo"))
  2. Attach the script to a node and add it to the main scene
  3. Export your project with "Compressed binary tokens (smaller files)" selected in the "Scripts" tab of the export config
  4. Run the exported game client from the console, will get an error for trying to call load_style in nil

Expected behavior The subsystems should load correctly

System (please complete the following information):

CakeVR commented 1 month ago

Hello, if fix the suggested works for you, we certainly should fix this before 4.3 releases. Thanks for raising this to our awareness.

Jowan-Spooner commented 1 month ago

I have removed nearly all uses of FileAccess.file_exists, but did not test the 4.3 exports. If you could test them again with the latest main branch, then maybe we could close this 🙏??

Thanks!

Jowan-Spooner commented 1 month ago

Okay I've tested it and exports are working again for me on 4.3.dev5 with the latest main branch. Will close this.