#Problems with mobile performance when attack or move player - 60 to 45 fps

63 messages · Page 1 of 1 (latest)

oak drift
#

I hear tips i think is something related with export android configuration and player.gd script.

Please i need help i would like to fix it before continue. Or if u need something else.

long plank
#

can you benchmark how long different parts of your script take?
https://docs.godotengine.org/en/latest/tutorials/scripting/debug/the_profiler.html

and you can just add some simple start/end time diffs on different parts of the code.
then figure out what is causing the FPS to drop

oak drift
long plank
oak drift
#

im still investigating the issue seems weird for me since im new into creating videogames but thanks for guide me bresk

oak drift
#

ok so i decide to start over again with all the project from scratch

#

first of all i would like to ask

#

is any way to be able to push content into my github from godot directly?

#

i was trying to use codex to help me but starts to crash at the point of make pull requests

#

@long plank

long plank
#

It should be possible - look at some tutorials on YouTube

oak drift
#

nah bro even with just 400 tiles or 40 still happens the same

#

first map 4000 tiles 60 to 45 fps just by doing click

#

400 same

#

and 40 same

#

mobile

#

so i can´t understand where is the problem....

oak drift
#

so this is happening me when i touch the screen in the mobile

#

how can i fix that process time?

patent agate
oak drift
#

thats why im asking how to

#

i can´t find the problem

#

i mean just happens when i tap the mobile screen

lapis umbra
#

Keep in mind, _input() is called ANY TIME there is a change in input, mouse movement and touch screen inputs produce a LOT of events per second.

if you run heavy stuff in _input(), it is going to tank performance.

#

You should only use _input() to retrieve information about inputs and not much else.

oak drift
#
func _input(event):
    if tapped_this_frame:
        return
    if event is InputEventScreenTouch and event.pressed and event.index == 0:
        tapped_this_frame = true

        var target_tile = Vector2i(event.position / TILE_SIZE)
        var current_tile = Vector2i(position / TILE_SIZE)
        if target_tile != current_tile and target_tile != last_requested_tile:
            last_requested_tile = target_tile
            Pathfinding.find_path(current_tile, target_tile)

func _process(delta):
    tapped_this_frame = false
lapis umbra
#

find_path() sounds like a heavy call

patent agate
oak drift
#

no

#
func find_path(start_tile: Vector2i, end_tile: Vector2i) -> void:
    if is_busy or not astar.region.has_point(start_tile) or not astar.region.has_point(end_tile):
        emit_signal("path_ready", [])


        return

    is_busy = true
    pending_start = start_tile
    pending_end = end_tile
    thread.start(Callable(self, "_thread_find_path"))
#
func _thread_find_path():
    var result := astar.get_id_path(pending_start, pending_end)
    call_deferred("_finish_thread", result)

func _finish_thread(result: Array[Vector2i]):
    if thread:
        thread.wait_to_finish()
    is_busy = false
    emit_signal("path_ready", result)

func _exit_tree():
    if thread and thread.is_started():
        thread.wait_to_finish()
lapis umbra
#

this looks pretty light, altho i never use threads myself.

I assume that you already know that threads have their own overhead, as they need to synch up with the main thread at some point.

oak drift
#

yes

#

im struggling on how godot export games to android mobile.

#

why process time is so high just for tapping the screen?

#

if i dont have nothing in my code to do anything

patent agate
#

Surely it should show up in Script Functions if it is this, unless the thread stuff is somehow tucking it away. ;\

#

As an example

oak drift
#

thats a mobile game tap based?

patent agate
#

No, I'm just showing where to look on the profiler.

oak drift
#

running trough the usb device to the mobile?

#

to test it?

lapis umbra
#

My main M.O. for finding performance hogs is commenting out specific lines of code and see which has the best result in lowering frame time.
Start trying to block _input() entirely.
If that works, block the heaviest lines on _input() until you find the most effective one.

Sadly, if the profiler is not helping, your best bet is a binary search.

patent agate
#

What it should definitely show is a bunch of calls to get_path

oak drift
#

oh nah i told u my scripts are not the problem.

lapis umbra
#

It could also be an issue with USB devices, there is a very weird and persistent bug where USB devices with certain IDs can cause very strange hiccups, both when loading and processing.

oak drift
#

i think is more like a version of the godot problem.

lapis umbra
#

Moving them around ports tends to fix it, assuming you have more than 1 port

oak drift
#

mmmm i will try something different instead of usb connection or wifi connection.

#

I think i will put again the code to move trough the map and test it just by exporting

#

not debuggin

patent agate
#

To be fair the profiler in Godot is kinda meh.

oak drift
#

if i see like lag spikes is still a problem.

#

if dont then i know where is the problem

#

in Godot

#

and i assume i would need to go to github issues

#

to let them know this problem

lapis umbra
#

i mean, it probably is in Godot
But hopefully there is a fixable source of it

oak drift
#

Thanks guys i will come here when more news about this comes.

oak drift
#

Ok so yep, the problem is the usb debugger in mobile devices.

#

Just by exporting the game and installing manually