godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
90.75k stars 21.12k forks source link

Android modules do not initialize singletons : i.e (GodotPayment) (3.0.6 stable and master) #22909

Closed TheTrope closed 6 years ago

TheTrope commented 6 years ago

Hi,

I'm trying to use android modules in godot, I.e GodotPayment, or community modules At first, I first tried to install GodotFireBase module by using a custom build and templates, it was not working, after being stuck for hours, thinking I was doing something wrong during the build process. I had the idea to give a try using GodotPayment with official build and templates (3.0.6 stable).

I tried the godot iap demo from https://github.com/godotengine/godot-demo-projects/tree/master/misc/android_iap

Godot version: 3.0.6 stable

OS/device including version: windows editor + (live debug) Huawei p20 lite w/ android 8

The godot IAP demo does not work on my side, I got

GodotPayment singleton is only available on Android devices.

-> so

But suprisingly, there is no issue at loading the modules according to the adb logs (So I guess modules are correctly compiled and present in the android app)

here are my adb logs:

10-10 01:04:17.269 15899 15899 D AndroidRuntime: >>>>>> START com.android.internal.os.RuntimeInit uid 2000 <<<<<<
10-10 01:04:17.273 15899 15899 I AndroidRuntime: readDownloadBoosterConfig: 'false'
10-10 01:04:17.452 15899 15899 D AndroidRuntime: Calling main entry com.android.commands.pm.Pm
10-10 01:04:18.071 15899 15899 I AndroidRuntime: VM exiting with result code 0.
10-10 01:04:20.853 15946 15946 D AndroidRuntime: >>>>>> START com.android.internal.os.RuntimeInit uid 2000 <<<<<<
10-10 01:04:20.857 15946 15946 I AndroidRuntime: readDownloadBoosterConfig: 'false'
10-10 01:04:21.037 15946 15946 D AndroidRuntime: Calling main entry com.android.commands.pm.Pm
10-10 01:04:23.347 15946 15946 I AndroidRuntime: VM exiting with result code 0.
10-10 01:04:24.350 16001 16001 I godot   : **INIT EVENT! - 0xe6031230
10-10 01:04:24.350 16001 16001 I godot   : ***************** HELLO FROM JNI!!!!!!!!
10-10 01:04:24.350 16001 16001 I godot   : *******CLASS FOUND!!!
10-10 01:04:24.350 16001 16001 I godot   : STEP2, 0x21f6
10-10 01:04:24.350 16001 16001 I godot   : STEP3 -400818140
10-10 01:04:24.350 16001 16001 I godot   : STEP4, 0x85
10-10 01:04:24.350 16001 16001 I godot   : STEP4.5, 0x2206
10-10 01:04:24.350 16001 16001 I godot   : STEP7
10-10 01:04:24.350 16001 16001 I godot   : STEP8
10-10 01:04:24.350 16001 16001 I godot   : *******GOT METHOD _dir_open ok!!
10-10 01:04:24.350 16001 16001 I godot   : *******GOT METHOD _dir_next ok!!
10-10 01:04:24.350 16001 16001 I godot   : *******GOT METHOD _dir_close ok!!
10-10 01:04:24.350 16001 16001 I godot   : *******GOT METHOD _dir_is_dir ok!!
10-10 01:04:24.350 16001 16001 I godot   : starting to attempt get methods
10-10 01:04:24.350 16001 16001 I godot   : *******GOT METHOD _init_audio ok!!
10-10 01:04:24.350 16001 16001 I godot   : *******GOT METHOD _write_buffer ok!!
10-10 01:04:24.350 16001 16001 I godot   : *******GOT METHOD _quit ok!!
10-10 01:04:24.350 16001 16001 I godot   : *******GOT METHOD _pause ok!!
10-10 01:04:24.350 16001 16001 I godot   : test construction 5
10-10 01:04:24.350 16001 16001 I godot   : running from dir /
10-10 01:04:24.393 16001 16026 I godot   : **SETUP
10-10 01:04:24.393 16001 16026 I godot   : CMDLINE LEN 0 - APK EXPANSION 0
10-10 01:04:24.419 16001 16026 I godot   : *****SETUP OK
10-10 01:04:24.420 16001 16026 I godot   : ANDROID MODULES : org/godotengine/godot/GodotPaymentV3
10-10 01:04:24.420 16001 16026 I godot   : mod count: 1
10-10 01:04:24.420 16001 16026 I godot   : LOADING MODULE: org/godotengine/godot/GodotPaymentV3
10-10 01:04:24.420 16001 16026 I godot   : ****^*^*?^*^*class data 139
10-10 01:04:24.429 16001 16026 I godot   : ****^*^*?^*^*class instance 149
10-10 01:04:24.587 16001 16026 I godot   : ^_^_^_^_^ newcontext 0
10-10 01:04:24.588 16001 16026 I godot   : ^_^_^_^_^ resize 0, 2190, 1080
10-10 01:04:24.588 16001 16026 I godot   : **FIRST_STEP
10-10 01:04:24.595 16001 16026 I godot   : OpenGL ES 3.0 Renderer: Mali-T830
10-10 01:04:24.612 16001 16001 I godot   : WARNING: not found: display/driver/keep_screen_on
10-10 01:04:24.650 16001 16026 I godot   : OpenSL Init OK!
10-10 01:04:25.044 16001 16026 I godot   : GodotPayment singleton is only available on Android devices.

It's really hard to find out if the issue come from Godot, my android device, or my setup Do you have any idea?

yleduc commented 6 years ago

I was fighting the same issue - and did not understand why for a (too) long time. It is only a typo :

In https://github.com/godotengine/godot-demo-projects/blob/master/misc/android_iap/iap.gd

    if Engine.has_singleton("GodotPayment"):
        payment = Engine.get_singleton("GodotPayments")

should obviously be:

    if Engine.has_singleton("GodotPayments"):
        payment = Engine.get_singleton("GodotPayments")

(missing "s")

TheTrope commented 6 years ago

Oh right ! Typo error, ohhhhhh Thank you, I'll have a try this evening !

But then, I was thinking it was a common issue with the one I had, trying to use Firebase android module (https://github.com/FrogSquare/GodotFireBase/issues) with my custom build and templates

I've been following the steps closely, and I got the module loaded

LOADING MODULE: org/godotengine/godot/FireBase without error in adb

but then :

Engine.has_singleton('FireBase') -> is False

What would be the issue in this case? Maybe It's possible to display/debug the list of existing singletons? Thanks

jabcross commented 5 years ago

I still have the same problem, fixing the typo didn't help.

image

Logcat gives this error. It looks like a parsing error, but the scripts seem fine to me (they're the standard ones from the example, with the typo fix).

2018-11-16 21:21:38.212 18129-18181/org.godotengine.androidiap E/Adreno-GSL: <gsl_memory_alloc_pure:2207>: GSL MEM ERROR: kgsl_sharedmem_alloc ioctl failed.
2018-11-16 21:21:38.212 18129-18181/org.godotengine.androidiap E/godot: **SCRIPT ERROR**: Parse Error: Unexpected token: ':':Control
2018-11-16 21:21:38.212 18129-18181/org.godotengine.androidiap E/godot:    At: res://iap_demo.gdc:2:GDScript::load_byte_code() - Parse Error: Unexpected token: ':':Control
2018-11-16 21:21:38.212 18129-18181/org.godotengine.androidiap E/godot: **ERROR**: Method/Function Failed, returning: ERR_PARSE_ERROR
2018-11-16 21:21:38.212 18129-18181/org.godotengine.androidiap E/godot:    At: modules/gdscript/gdscript.cpp:771:load_byte_code() - Method/Function Failed, returning: ERR_PARSE_ERROR
2018-11-16 21:21:38.212 18129-18181/org.godotengine.androidiap E/godot: **ERROR**: Condition ' err != OK ' is true. returned: RES()
2018-11-16 21:21:38.212 18129-18181/org.godotengine.androidiap E/godot:    At: modules/gdscript/gdscript.cpp:2115:load() - Condition ' err != OK ' is true. returned: RES()
2018-11-16 21:21:38.212 18129-18181/org.godotengine.androidiap E/godot: **ERROR**: Failed loading resource: res://iap_demo.gdc
2018-11-16 21:21:38.212 18129-18181/org.godotengine.androidiap E/godot:    At: core/io/resource_loader.cpp:192:_load() - Method/Function Failed, returning: RES()
2018-11-16 21:21:38.212 18129-18181/org.godotengine.androidiap E/godot: **ERROR**: res://main.tscn:3 - Parse Error: [ext_resource] referenced nonexistent resource at: res://iap_demo.gd
2018-11-16 21:21:38.212 18129-18181/org.godotengine.androidiap E/godot:    At: scene/resources/scene_format_text.cpp:439:poll() - res://main.tscn:3 - Parse Error: [ext_resource] referenced nonexistent resource at: res://iap_demo.gd
2018-11-16 21:21:38.212 18129-18181/org.godotengine.androidiap E/godot: **ERROR**: Condition ' err != OK ' is true. returned: RES()
2018-11-16 21:21:38.212 18129-18181/org.godotengine.androidiap E/godot:    At: core/io/resource_loader.cpp:155:load() - Condition ' err != OK ' is true. returned: RES()
2018-11-16 21:21:38.213 18129-18181/org.godotengine.androidiap E/godot: **ERROR**: Failed loading resource: res://main.tscn
2018-11-16 21:21:38.213 18129-18181/org.godotengine.androidiap E/godot:    At: core/io/resource_loader.cpp:192:_load() - Method/Function Failed, returning: RES()
2018-11-16 21:21:38.213 18129-18181/org.godotengine.androidiap E/godot: **ERROR**: Failed loading scene: res://main.tscn
2018-11-16 21:21:38.213 18129-18181/org.godotengine.androidiap E/godot:    At: main/main.cpp:1670:start() - Condition ' !scene ' is true. returned: false
2018-11-16 21:21:38.216 1060-3067/? E/AudioFlinger: open /proc/18129/cmdline error
2018-11-16 21:21:38.361 2546-2546/? E/PropertyValuesHolder: java.lang.reflect.InvocationTargetException
2018-11-16 21:21:38.361 2546-2546/? E/PropertyValuesHolder: java.lang.reflect.InvocationTargetException
2018-11-16 21:21:38.544 684-732/? E/ANDR-PERF-OPTSHANDLER: perf_lock_rel: updated /sys/class/scsi_host/host0/../../../clkscale_enable with 1
     return value 2
2018-11-16 21:21:54.764 18249-18249/? E/wet: Sync is not initialized yet
akien-mga commented 5 years ago

@jabcross The log sounds like you're using Android templates which don't match your editor version. You need templates built from the same git commit. The assert failure in the editor is normal, the singleton is only available on Android.

jabcross commented 5 years ago

Thanks, I really had a dirty template.

Tried again, with fresh install of Godot and demo-projects.

On Android, the game freezes on the Godot game engine splash screen.

Output of logcat:

2018-11-21 14:25:14.988 1261-1261/? E/MSM-irqbalance: IRQ 79 not found in internal structure or should be ignored
2018-11-21 14:25:16.318 684-732/? E/ANDR-PERF-REQUEST: Failed to set timer
2018-11-21 14:25:17.896 1652-1708/? E/ANDR-PERF-JNI: com_qualcomm_qtiperformance_native_perf_io_prefetch_start
2018-11-21 14:25:17.896 683-683/? E/ANDR-IOP: IOP HAL: Received pkg_name = org.godotengine.androidiap pid = -1
2018-11-21 14:25:17.900 1652-1708/? E/ActivityTrigger: activityStartTrigger: not whiteListedorg.godotengine.androidiap/org.godotengine.godot.Godot/1
2018-11-21 14:25:17.901 1652-1708/? E/ActivityTrigger: activityResumeTrigger: not whiteListedorg.godotengine.androidiap/org.godotengine.godot.Godot/1
2018-11-21 14:25:17.910 683-744/? E/ANDR-IOP: is_in_recent_list is TRUE
2018-11-21 14:25:17.910 683-744/? E/ANDR-IOP: io prefetch is deactivate
2018-11-21 14:25:17.929 1652-1708/? E/ActivityTrigger: activityResumeTrigger: not whiteListedorg.godotengine.androidiap/org.godotengine.godot.Godot/1
2018-11-21 14:25:18.078 2546-2546/? E/PropertyValuesHolder: java.lang.reflect.InvocationTargetException
2018-11-21 14:25:18.078 2546-2546/? E/PropertyValuesHolder: java.lang.reflect.InvocationTargetException
2018-11-21 14:25:18.309 1060-6682/? E/AudioFlinger: open /proc/25485/cmdline error
2018-11-21 14:25:18.310 660-3070/? E/msm8974_platform: platform_check_backends_match: Invalid snd_device = 
2018-11-21 14:25:18.310 660-3070/? E/ACDB-LOADER: Error: ACDB AudProc vol returned = -19
2018-11-21 14:25:18.311 660-3070/? E/ACDB-LOADER: Error: ACDB_CMD_GET_AFE_COMMON_TABLE_SIZE Returned = -19
2018-11-21 14:25:18.311 660-3070/? E/ACDB-LOADER: Error: ACDB AFE returned = -19
2018-11-21 14:25:18.543 1652-1869/? E/WindowManager: Performed 6 layouts in a row. Skipping
2018-11-21 14:25:18.546 1652-1742/? E/ANDR-PERF-JNI: com_qualcomm_qtiperformance_native_perf_io_prefetch_start
2018-11-21 14:25:18.546 683-683/? E/ANDR-IOP: IOP HAL: Received pkg_name = org.godotengine.androidiap pid = 25485
2018-11-21 14:25:18.547 683-744/? E/ANDR-IOP: io prefetch Capture is deactivated 
2018-11-21 14:25:19.908 684-732/? E/ANDR-PERF-OPTSHANDLER: perf_lock_rel: updated /sys/class/scsi_host/host0/../../../clkscale_enable with 1
     return value 2
2018-11-21 14:25:19.984 1261-1261/? E/MSM-irqbalance: IRQ 79 not found in internal structure or should be ignored
2018-11-21 14:25:24.985 1261-1261/? E/MSM-irqbalance: IRQ 79 not found in internal structure or should be ignored
2018-11-21 14:25:29.988 1261-1261/? E/MSM-irqbalance: IRQ 79 not found in internal structure or should be ignored
2018-11-21 14:25:34.988 1261-1261/? E/MSM-irqbalance: IRQ 79 not found in internal structure or should be ignored
j2l commented 5 years ago

Should be re-opened. I landed here because I tested an empty android template with an empty Godot project and scrutinized the content of the 500kB apk. I noticed that Godot Payment is included, without any module option. If it helps, here's what I see with 3.1beta1: image

akien-mga commented 5 years ago

I don't see how that relates to this issue? Yes, GodotPayments is part of the base package, and that's why it's available.

j2l commented 5 years ago

Merci Rémi, Where is the base package doc page located? I'm trying to disable all modules to understand what is base, what is mandatory (png, freetype so far), what is optional, what does what.

akien-mga commented 5 years ago

There's no doc about it, but you can disable only what is exposed in scons --help. Anything further requires modifying the engine.

j2l commented 5 years ago

Thx. It raises some many questions. Making another ticket

volzhs commented 5 years ago

use community channels for a question though...