![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | sander48k |
I am creating a 3D game with Godot 3.5.2 for mobile devices, both iOS and Android. Today I noticed that on some Android devices there is significant delay between a UI action, e.g. a button press, and the playback of a sound. I am using AudioStreamPlayer. The playback is started from GDScript when some action occurs.
To isolate the issue I created a very simple Godot project consisting of 1 scene that contains a Button and an AudioStreamPlayer. The ‘pressed’ signal triggers the following function:
func _on_button_pressed():
var time_ttnm = AudioServer.get_time_to_next_mix()
var time_latency = AudioServer.get_output_latency()
print('ttnm=%f, latency=%f' % [time_ttnm, time_latency])
$AudioStreamPlayer.play()
On iOS devices and most Android devices I have there is no noticeable delay. On one Android device however (Motorola e40 running Android 11) there is a significant and unacceptable delay (roughly half a second) between the button press and the playback of the sound.
Other info:
- The AudioStreamPlayer uses a very short sample (150ms) in WAV format.
- The time to next mix is around 0.01. The latency is 0.
- I also tested this in Godot 4.0.3 which gave the same result.
Anyone any idea what is going on here and how it can be fixed?
Looks like a platform-specific problem. Perhaps you should report this on the issue tracker on Github?
You could also try using Godot 4 to see if the issue persists (using a low end renderer if you need compatibility)
Zylann | 2023-07-06 14:48
I’d try different file formats at different sampling rates first. Maybe devices decoding facilities stumble on some odd files. Look up “android supported media formats”. Though the engine should probably already encode audio resources to the target platforms requirements…
Rpahut | 2023-07-07 12:54