[2D] Experiencing performance issues (repeated freezes), but with "perfect" FPS

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Ortcel

Hi.

The issue is experienced on Godot_v3.0.6-stable_win64.
The game is a 2D platformer, exported to Android.
The issue is experienced:
- on my computer (Windows 10 64, CPU: 8700K, GPU: GTX 1060 6 GB, RAM: 16 GB), while testing it with F5
- on my smartphone (Xperia XA2, RAM: 3 GB), once exported and installed with the .apk
- on my friend’s smartphone (Honor 8X, RAM: 4 GB), once exported and installed with the .apk

My project doesn’t have much nodes. To keep it as simple as possible: a TileMap, and a KinematicBody2D with a Sprite, a CollisionShape2D and a custom camera (a Node2D).
I also made a new project to try to identify the issue, with literally 30 lines of code.

The problem in itself: the game will struggle for maybe 0.5 - 1 sec, every few seconds, looking like the FPS drop frequently… but when I print said FPS, everything seems alright (144 FPS with v-sync, and a lot more without).
The issue is reduced on my computer.
The issue is reduced with the “light” version.

I have been experiencing this issue for a week, I tried to modify some settings, I even tried with Godot 3.1 (alpha) to use the ESGL 2 option, but none of what I did actually solved it.

My code from the light version:

extends KinematicBody2D

const UP = Vector2(0, -1)
const SCREEN_LENGTH = 1024
const SPEED = 300
const GRAVITY = 40
const JUMP_HEIGHT = 800

var motion = Vector2()
var jump = false

func _ready():
	motion.x = SPEED


func _physics_process(delta):
	motion.y += GRAVITY
	
	if is_on_floor() && jump:
		motion.y -= JUMP_HEIGHT
	
	if position.x <= 16 || position.x >= SCREEN_LENGTH - 16:
		motion.x *= -1
	
	motion = move_and_slide(motion, UP)


func _input(event):
	if event is InputEventMouseButton:
		jump = event.pressed

I’m facing same problem, trying to search for a solution, if none is found i’ll have no choice but drop godot and rebuild everything.

My project size is 1920 x 1080, with very few objects. Imagine when have all it needs…

marcelo | 2020-10-24 23:59