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

C# [Export] Arrays not working on IOS builds 4.3 Beta #94642

Open
mrclam opened this issue Jul 22, 2024 · 4 comments
Open

C# [Export] Arrays not working on IOS builds 4.3 Beta #94642

mrclam opened this issue Jul 22, 2024 · 4 comments

Comments

@mrclam
Copy link

mrclam commented Jul 22, 2024

Tested versions

Reproducible on 4.3 Beta 2 and 4.3 Beta 3
Not tested on other versions yet
NOTE THIS IS C# SPECIFIC - GDSCRIPT seems to be fine.

System information

Godot v4.3.beta3.mono - Windows 10.0.19045 - GLES3 (Compatibility) - NVIDIA GeForce RTX 3080 (NVIDIA; 32.0.15.6070) - AMD Ryzen 9 5950X 16-Core Processor (32 Threads)

Issue description

Tracked this down by use of GD.Prints.

This is in C#. I have Arrays which are marked as "Export" which are filled in with the editor. These work fine in windows and android Builds.

On IOS build, if I build it the built code says the array is of size 0.

Steps to reproduce

In C#. Have an array of any type, which is exported and filled in the editor. For example, the way I found this bug was as follows.

    [Export]
    public Array<TouchScreenButton> buttons = new Array<TouchScreenButton>();

In the editor, add a couple of buttons to this array.

Then in the C# code, have something like :

GD.Print("Number of Buttons : " + buttons.Count);

When you run the code on Windows/Mac/Android - you'll get a debug log saying "Number of Buttons : 2" (or however many you added).

HOWEVER.. On IOS, you'll get 0.

This will happen with ANY godot type added to array in the editor.

Also happens the exact same with the following code:

[Export]public DrawNode2D[] subDrawNodes2 = null;

Minimal reproduction project (MRP)

EDIT: Added a small repro below.

iosbug.zip

@akien-mga akien-mga changed the title C# [Export] Arrays not working on IOS builds 4.3.3Beta C# [Export] Arrays not working on IOS builds 4.3 Beta Jul 23, 2024
@felipejfc
Copy link

Hit the same bug today! Observed on 4.3-stable and iOS build
For some reason it happens only on our export builds that will go to the store but not on the local builds sending the ipa from the editor to the device directly

@atlasapplications
Copy link

I tried your minimal reproduction sample and I noticed a bug that may or may not be related that I've also encountered in the past.

Since the Godot editor relies on compiled C# assemblies to display [Export] properties, there are instances when you first load your project where data is contained in the scene file that relies on the attached script, but since those assemblies don't exist yet, the data is wiped. That seems to be the case here with your minimal sample because the top level Node2D that is the default Node, has [Export] properties that contain an array of NodePaths, but that data structure doesn't exist yet if you haven't hit the build button. So when you run the project, the arrays are empty.

It's kind of like how you can comment out the [Export] property, run the project, which will wipe the data in the scene file, and then uncomment again. It causes data loss. One of the instances where this always happens is when you upload your project with a .gitignore based system since the compiled assemblies are contained in the .godot folder so I'm not sure if this is what you're experiencing on iOS because this also happens to me on Windows.

@atlasapplications
Copy link

I should also note that I tried to replicate this bug with various data structures and it does not happen to certain data types such as a single exported bool or string. It appears to only happen with exported arrays which is why I think this may be the same bug.

@a-camargo
Copy link

a-camargo commented Sep 9, 2024

We were getting this issue on both Android and iOS on CI builds, which were run --headless and immediately exported the apps. We solved it by doing a pre-export step, running the editor with:
godot-mono -v -e --headless --path . --import --build-solutions (related issue about --import)
This will ensure assets are imported and your C# code is compiled before actually running the export.

btw, we're using v4.3.stable.mono.official [77dcf97d8]

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

No branches or pull requests

5 participants