Skip to content

gdext 0.4.3: Extensions fail to load on Android (aarch64-linux-android) when built with 0.4.3 #1423

@riverfr0zen

Description

@riverfr0zen

Recently I upgraded to godot 0.4.3, and my extension stopped working (fails to load) on Android.

This only affects Android for me. The extension works fine on Linux builds with godot 0.4.3.

If I build with godot pinned to 0.4.2 (godot = "=0.4.2" in Cargo.toml), the extension works as expected on Android.

Supplying a bunch of details below. Please let me know if you'd like to see anything else. Thanks.

Environment

  • gdext version: 0.4.3 (broken) vs 0.4.2 (working)
  • Godot version: 4.5.1.stable.official.f62fdbde1
  • Platform: Android (tested on physical device, Pixel 8a, via Godot's Remote Deploy)
  • Target: aarch64-linux-android
  • Rust version: Latest stable

Invocation

The extension is added as a child to my Game scene, and in Game.gd, I am loading it as so:

func _ready():
    var from_rust = $ImageOptimizer.testfn(20.0)
    print("From rust: " + str(from_rust))

adb logcat output

Used command: adb logcat | grep -E "(godot|mak3rs|ImageOptimizer|GDExtension|FATAL|dlopen)"

adb logcat of Extension built with 0.4.3 (fails to load):

11-30 23:02:50.555 31384 31437 I godot   : Vulkan 1.4.303 - Forward Mobile - Using Device #0: ARM - Mali-G715
11-30 23:02:50.671 31384 31437 I godot   :
11-30 23:02:51.648 31384 31437 E godot   : ERROR: Cannot get class 'ImageOptimizer'.
11-30 23:02:51.648 31384 31437 E godot   :    at: _instantiate_internal (core/object/class_db.cpp:546)
11-30 23:02:51.648 31384 31437 E godot   : WARNING: Node ImageOptimizer of type ImageOptimizer cannot be created. A placeholder will be created instead.
11-30 23:02:51.648 31384 31437 E godot   :    at: instantiate (scene/resources/packed_scene.cpp:277)
11-30 23:02:51.850 31384 31437 E godot   : SCRIPT ERROR: Invalid call. Nonexistent function 'testfn' in base 'Node'.
11-30 23:02:51.850 31384 31437 E godot   :    at: _ready (res://Game.gd:127)
11-30 23:02:51.850 31384 31437 E godot   :    GDScript backtrace (most recent call first):
11-30 23:02:51.850 31384 31437 E godot   :        [0] _ready (res://Game.gd:127)

adb logcat of extension built with 0.4.2 (loading succeeds):

11-30 23:12:35.257 32135 32180 I godot   : Vulkan 1.4.303 - Forward Mobile - Using Device #0: ARM - Mali-G715
11-30 23:12:35.395 32135 32180 I godot   :
11-30 23:12:36.457 32135 32180 I godot   : [INFO] mak3rs::imageopt: ImageOptimizer initialized
11-30 23:12:36.662 32135 32180 I godot   : [INFO] mak3rs::imageopt: In testfn, doing 2 * 20
11-30 23:12:36.662 32135 32180 I godot   : From rust: 40.0

With simplified test extension

Since my ImageOptimizer extension is quite involved, I also created a simple test extension to troubleshoot:

lib.rs

use godot::prelude::*;

struct TestExt;

#[gdextension]
unsafe impl ExtensionLibrary for TestExt {}

#[derive(GodotClass)]
#[class(base=Node)]
pub struct SimpleTest {
    #[base]
    base: Base<Node>,
}

#[godot_api]
impl INode for SimpleTest {
    fn init(base: Base<Node>) -> Self {
        godot_print!("SimpleTest initialized");
        Self { base }
    }
}

#[godot_api]
impl SimpleTest {
    #[func]
    pub fn hello(&self, name: GString) -> GString {
        godot_print!("Hello called with: {}", name);
        let result = format!("Hello, {}!", name);
        GString::from(&result)
    }
}

Cargo.toml

[package]
name = "testext"
version = "0.1.0"
edition = "2021"

[lib]
crate-type = ["cdylib"]

[dependencies]
godot = "0.4.3"
# If godot is pinned to 0.4.2, the extension works fine on Android
# godot = "=0.4.2"

TestExt.gdextension

[configuration]
entry_symbol = "gdext_rust_init"
compatibility_minimum = 4.1

[libraries]
linux.release.x86_64 = "res://testext/target/release/libtestext.so"
linux.debug.x86_64 = "res://testext/target/release/libtestext.so"

android.debug.arm64 = "res://testext/target/aarch64-linux-android/release/libtestext.so"
android.release.arm64 = "res://testext/target/aarch64-linux-android/release/libtestext.so"

Invocation in Game.gd

func _ready():
    print($SimpleTest.hello("yoyo"))
    var from_rust = $ImageOptimizer.testfn(20.0)
    print("From rust: " + str(from_rust))

With all necessary env vars configured, the extension was built with: cargo build --target aarch64-linux-android --lib --release

adb logcat output with simple extension

adb logcat of simple extension built with 0.4.3 (SimpleTest fails to load, while my ImageOptimizer, built with 0.4.2, initializes):

12-01 00:39:36.380  6531  6577 E godot   : ERROR: Cannot get class 'SimpleTest'.
12-01 00:39:36.380  6531  6577 E godot   :    at: _instantiate_internal (core/object/class_db.cpp:546)
12-01 00:39:36.380  6531  6577 E godot   : WARNING: Node SimpleTest of type SimpleTest cannot be created. A placeholder will be created instead.
12-01 00:39:36.380  6531  6577 E godot   :    at: instantiate (scene/resources/packed_scene.cpp:277)
12-01 00:39:36.381  6531  6577 I godot   : [INFO] mak3rs::imageopt: ImageOptimizer initialized
12-01 00:39:36.591  6531  6577 E godot   : SCRIPT ERROR: Invalid call. Nonexistent function 'hello' in base 'Node'.
12-01 00:39:36.591  6531  6577 E godot   :    at: _ready (res://Game.gd:127)
12-01 00:39:36.591  6531  6577 E godot   :    GDScript backtrace (most recent call first):
12-01 00:39:36.591  6531  6577 E godot   :        [0] _ready (res://Game.gd:127)

adb logcat of simple extension built with 0.4.2 (everything works):

12-01 00:43:30.626  6863  6929 I godot   : Vulkan 1.4.303 - Forward Mobile - Using Device #0: ARM - Mali-G715
12-01 00:43:30.759  6863  6929 I godot   :
12-01 00:43:31.661  6863  6929 I godot   : SimpleTest initialized
12-01 00:43:31.661  6863  6929 I godot   : [INFO] mak3rs::imageopt: ImageOptimizer initialized
12-01 00:43:31.865  6863  6929 I godot   : Hello called with: yoyo
12-01 00:43:31.865  6863  6929 I godot   : Hello, yoyo!
12-01 00:43:31.865  6863  6929 I godot   : [INFO] mak3rs::imageopt: In testfn, doing 2 * 20
12-01 00:43:31.865  6863  6929 I godot   : From rust: 40.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions