Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Seeing weird frame counts with wait_frames #593

Open
bitwes opened this issue Apr 22, 2024 · 0 comments
Open

Seeing weird frame counts with wait_frames #593

bitwes opened this issue Apr 22, 2024 · 0 comments
Labels

Comments

@bitwes
Copy link
Owner

bitwes commented Apr 22, 2024

When reviewing PR for i578 I noticed that the first test would fail sometimes and the count would be 1. Changing wait_frames(10) to wait_frames(15) would result in a count of 15 (sometimes 14). I poked and prodded the code but couldn't get it to act in the expected manner until I changed the awaiter to count frames via _process instead of _physics_process. This is the opposite of what I would expect. I would not expect higher frame counts in _process than _physics_process, it should be the other way around.

This might mean that we should have wait_frames which waits _process frames and wait_physics_frames which waits based on _physics_process.

I just upgraded to macOS Sonoma 14.4.1 (23E224), so maybe that is causing the issue. This should be verified on other OSes.

Here's the code that I was running

extends GutTest

class InputSingletonTracker:
	extends Node
	var input_frames = []

	var _frame_counter = 0

	func _process(delta):
		_frame_counter += 1
		if Input.is_action_pressed("jump"):
			print(_frame_counter, '  jump down')
			input_frames.append(str(_frame_counter, ':', delta))


class TestInputSingleton:
	extends "res://addons/gut/test.gd"
	var _sender = InputSender.new(Input)

	func before_all():
		InputMap.add_action("jump")

	func after_all():
		InputMap.erase_action("jump")

	func after_each():
		_sender.release_all()
		_sender.clear()

	func test_raw_input_press():
		var r = add_child_autofree(InputSingletonTracker.new())
		await wait_frames(1)

		Input.action_press("jump")
		await wait_frames(2)
		Input.action_release("jump")
		print(r.input_frames)
		assert_gt(r.input_frames.size(), 1, 'input size')
@bitwes bitwes added the bug label Apr 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant