godot: 3.4 RC1 Mono builds crash on Android (regression from #53610)

Godot version

3.4 RC1

System information

Editor: Win10, JetBrains Rider, dotnet cli Device: Samsung S21

Issue description

Deploying default GDScript projects in the Mono-enabled editor 3.4 RC1 succeeds.

Generating a C# project, building, and deploying, also succeeds.

Adding a single C# script to a node, and deploying, causes a black screen on the device, which then crashes.

Steps to reproduce

Download 3.4 RC1.

Create a simple scene (I used a 3D scene, camera and sphere with an AnimationPlayer to move the sphere).

Deploy this to an android device - this should work.

Project->tools->C#-> generate mono project

Right click a node (e.g. the Camera) and attach a C# script. I added some camera movement to test, but you can also just use the default empty script, same effect - Godot splash screen, followed by crash to home screen.

Logcat reveals the following:

2021-10-21 20:05:18.774 18318-24502/org.godotengine.test34android E/godot: ERROR: No loader found for resource: res://FloatCamera.cs.
2021-10-21 20:05:18.774 18318-24502/org.godotengine.test34android E/godot:    at: _load (core/io/resource_loader.cpp:278) - Method failed. Returning: RES()
2021-10-21 20:05:18.774 18318-24502/org.godotengine.test34android E/godot: ERROR: res://Spatial.tscn:3 - Parse Error: [ext_resource] referenced nonexistent resource at: res://FloatCamera.cs
2021-10-21 20:05:18.774 18318-24502/org.godotengine.test34android E/godot:    at: poll (scene/resources/resource_format_text.cpp:412) - res://Spatial.tscn:3 - Parse Error: [ext_resource] referenced nonexistent resource at: res://FloatCamera.cs
2021-10-21 20:05:18.774 18318-24502/org.godotengine.test34android E/godot: ERROR: Failed to load resource 'res://Spatial.tscn'.
2021-10-21 20:05:18.774 18318-24502/org.godotengine.test34android E/godot:    at: load (core/io/resource_loader.cpp:206) - Condition "err != OK" is true. Returned: RES()
2021-10-21 20:05:18.774 18318-24502/org.godotengine.test34android E/godot: ERROR: Failed loading resource: res://Spatial.tscn. Make sure resources have been imported by opening the project in the editor at least once.
2021-10-21 20:05:18.774 18318-24502/org.godotengine.test34android E/godot:    at: _load (core/io/resource_loader.cpp:271) - Condition "found" is true. Returned: RES()
2021-10-21 20:05:18.774 18318-24502/org.godotengine.test34android E/godot: ERROR: Failed loading scene: res://Spatial.tscn
2021-10-21 20:05:18.774 18318-24502/org.godotengine.test34android E/godot:    at: start (main/main.cpp:1996) - Condition "!scene" is true. Returned: false
2021-10-21 20:05:18.834 18318-24502/org.godotengine.test34android E/godot: ERROR: Condition "default_certs != nullptr" is true.
2021-10-21 20:05:18.834 18318-24502/org.godotengine.test34android E/godot:    at: load_default_certificates (modules/mbedtls/crypto_mbedtls.cpp:314) - Condition "default_certs != nullptr" is true.
2021-10-21 20:05:18.835 18318-24502/org.godotengine.test34android E/godot: ERROR: No loader found for resource: res://FloatCamera.cs.
2021-10-21 20:05:18.835 18318-24502/org.godotengine.test34android E/godot:    at: _load (core/io/resource_loader.cpp:278) - Method failed. Returning: RES()
2021-10-21 20:05:18.835 18318-24502/org.godotengine.test34android E/godot: ERROR: res://Spatial.tscn:3 - Parse Error: [ext_resource] referenced nonexistent resource at: res://FloatCamera.cs
2021-10-21 20:05:18.835 18318-24502/org.godotengine.test34android E/godot:    at: poll (scene/resources/resource_format_text.cpp:412) - res://Spatial.tscn:3 - Parse Error: [ext_resource] referenced nonexistent resource at: res://FloatCamera.cs
2021-10-21 20:05:18.835 18318-24502/org.godotengine.test34android E/godot: ERROR: Failed to load resource 'res://Spatial.tscn'.
2021-10-21 20:05:18.835 18318-24502/org.godotengine.test34android E/godot:    at: load (core/io/resource_loader.cpp:206) - Condition "err != OK" is true. Returned: RES()
2021-10-21 20:05:18.835 18318-24502/org.godotengine.test34android E/godot: ERROR: Failed loading resource: res://Spatial.tscn. Make sure resources have been imported by opening the project in the editor at least once.
2021-10-21 20:05:18.835 18318-24502/org.godotengine.test34android E/godot:    at: _load (core/io/resource_loader.cpp:271) - Condition "found" is true. Returned: RES()
2021-10-21 20:05:18.835 18318-24502/org.godotengine.test34android E/godot: ERROR: Failed loading scene: res://Spatial.tscn
2021-10-21 20:05:18.835 18318-24502/org.godotengine.test34android E/godot:    at: start (main/main.cpp:1996) - Condition "!scene" is true. Returned: false
2021-10-21 20:05:18.905 18318-24502/org.godotengine.test34android E/godot: ERROR: Condition "default_certs != nullptr" is true.
2021-10-21 20:05:18.905 18318-24502/org.godotengine.test34android E/godot:    at: load_default_certificates (modules/mbedtls/crypto_mbedtls.cpp:314) - Condition "default_certs != nullptr" is true.
2021-10-21 20:05:18.906 18318-24502/org.godotengine.test34android E/godot: ERROR: No loader found for resource: res://FloatCamera.cs.
2021-10-21 20:05:18.906 18318-24502/org.godotengine.test34android E/godot:    at: _load (core/io/resource_loader.cpp:278) - Method failed. Returning: RES()
2021-10-21 20:05:18.906 18318-24502/org.godotengine.test34android E/godot: ERROR: res://Spatial.tscn:3 - Parse Error: [ext_resource] referenced nonexistent resource at: res://FloatCamera.cs
2021-10-21 20:05:18.906 18318-24502/org.godotengine.test34android E/godot:    at: poll (scene/resources/resource_format_text.cpp:412) - res://Spatial.tscn:3 - Parse Error: [ext_resource] referenced nonexistent resource at: res://FloatCamera.cs
2021-10-21 20:05:18.906 18318-24502/org.godotengine.test34android E/godot: ERROR: Failed to load resource 'res://Spatial.tscn'.
2021-10-21 20:05:18.906 18318-24502/org.godotengine.test34android E/godot:    at: load (core/io/resource_loader.cpp:206) - Condition "err != OK" is true. Returned: RES()
2021-10-21 20:05:18.906 18318-24502/org.godotengine.test34android E/godot: ERROR: Failed loading resource: res://Spatial.tscn. Make sure resources have been imported by opening the project in the editor at least once.
2021-10-21 20:05:18.906 18318-24502/org.godotengine.test34android E/godot:    at: _load (core/io/resource_loader.cpp:271) - Condition "found" is true. Returned: RES()
2021-10-21 20:05:18.906 18318-24502/org.godotengine.test34android E/godot: ERROR: Failed loading scene: res://Spatial.tscn
2021-10-21 20:05:18.906 18318-24502/org.godotengine.test34android E/godot:    at: start (main/main.cpp:1996) - Condition "!scene" is true. Returned: false

This goes on for quite a while. In the original project I discovered this on, it complained about every .cs script file and every scene that contained a .cs script, as far as I could tell. Full log for the sample project attached.

logcat.txt

Minimal reproduction project

test-34-android.zip

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 27 (27 by maintainers)

Most upvoted comments

Android Gradle plugin updated to 7.2, and now requires Java 11 (@madmiraal): fd942cd

Tested this hypothesis next, that’s the culprit. Reverting this commit makes 3.4 RC 1 work fine again, when built with the same container and build scripts as the official 3.4 RC 1.

Here’s a test build with Linux editor binary and Android arm64v8 templates: https://downloads.tuxfamily.org/godotengine/testing/Godot_v3.4-rc1_mono_revert_gradle7.2.zip

So if you compare the logs that I uploaded, it appears that since #53610, it’s actually triggering a full rebuild of the godot library when calling ./gradlew generateGodotTemplates, so our split workflow using scons first and then gradlew to only generate the APK is no longer working.

That explains why Mono is not included (not part of the default scons call that Gradle does if the lib hasn’t been pre-built), and why the 3.4 RC 1 official lib is bigger than the one with gradle chances reverted (probably my manual scons build uses better optimization options than Gradle’s ad hoc one).

For reference, here’s how the builds are made: https://github.com/godotengine/godot-build-scripts/blob/main/build-android/build.sh#L53-L71

In my test build, I removed the lines which are not about arm64v8 to speed things up.

I tested 3.4 beta 6 and 3.4 RC 1 and I can confirm the issue, exporting the MRP from Linux to my Pocophone F1 (the scene’s lighting flickers like hell on the version that works from beta 6, but that’s a separate issue 😃).

For reference: the upstream Gradle bug: https://github.com/gradle/gradle/issues/16756

#54155 updates the Gradle build tasks so they should once again not try to build the arm64-v8 library when running generateGodotTemplates or generateDevTemplate.

Here’s a test build with Linux editor binary and Android arm64v8 templates: https://downloads.tuxfamily.org/godotengine/testing/Godot_v3.4-rc1_mono_revert_gradle7.2.zip

Just tested this and yup, that fixes the export for me, works perfectly 👍

Looking at the changes linked, it doesn’t seem like any of them are directly causing the issue, so I guess it must be something to do with what’s changed between Gradle versions. I’ve no idea how the mono script/assembly loading in exports works tbh, it seems tricky to debug. Since the .cs files are blank in the export, I’m guessing they’re just there as a stub for the filesystem to reference, which then does some kind of virtual mapping onto the built game assembly. Hmm, I might have a poke around in the mono source later to see if anything acts differently between these two builds in the debugger.

There are several changes between 3.4 beta 6 and 3.4 RC 1 which could be involved in this issue (changelog: https://github.com/godotengine/godot/compare/3e2bb415a9b186596b9ce02debc79590380c2355...90f8cd89a738316563dac9b133628df6bafe2cb2):

  1. I updated the Mono version from 6.12.0.147 to 6.12.0.158. I can make a test build of 3.4 RC 1 with the 6.12.0.147 Mono version to see if that solves the issue.
  2. Fixes to the Android export logic (@m4gr3d): https://github.com/godotengine/godot/commit/754db65a1f7ab3bf1d10387134600a44f9d1f93b
  3. Android Gradle plugin updated to 7.2, and now requires Java 11 (@madmiraal): https://github.com/godotengine/godot/commit/fd942cd4654fa62ecf5e9feed2fd5295faa180fc
  4. Various C# marshalling bugfixes by @raulsntos (I doubt they’re related but who knows)

The build containers update seems the most likely to me, so I’ll make a test build to confirm.

That it’s working fine? IIUC the only case where the bug is reproduced is exporting from a Windows host with 3.4 RC 1?

No, the same results as in: RC 1 export crashes on launch, and Beta 6 export launches successfully, when exporting from either Windows and Linux. Edit: and with “custom build”, RC1 crashes, Beta 6 launches too.

Interestingly, I just tried installing the apks on the Android Studio simulator, and the rc1 and b6 apks BOTH worked there. I’m going to try and dig out an old Android device, to see if this is a quirk of my particular phone.