UI Mouse detection problem due to (?) V-Sync

Godot Version

v4.6.stable.official(Windows 11)

Question

Hi guys. I seemingly found a problem with the interaction between Control nodes and CollisionShape2D nodes regarding capturing mouse movement (entering and exiting the CollisionShape2D node), where depending on if V-Sync is on or off the detection becomes reliable or reliable, respectively. To recreate this I create a new project and place an Area2D node with a CollisionShape2D child (circular, raidius ~20 px); then place a Control node, i.e. Button, on top of it, so that they interesect; then write this in the root node:

extends Node2D

func _ready() -> void:
    $Area2D.mouse_entered.connect(on_mouse_entered)
    $Area2D.mouse_exited.connect(on_mouse_exited)

func on_mouse_entered():
    print('mouse entered')

func on_mouse_exited():
    print('mouse EXITED')

The layout in the scene:

Then, if I wiggle my mouse between the two nodes, so that it crosses from being above node to being above another node, I can get it, so that the console prints “mouse entered“ even though my mouse is on the button and no longer on the Area2D node (normally, once the mouse goes over the button, ‘mouse exited‘ is printed). This problem seemingly occurs only if V-Sync is off. If V-Sync is on, then there doesn’t seem to be a problem.

I can understand if V-Sync delays user input, but I don’t understand why V-Sync would affect what I would describe as ‘game logic‘. The problem may not be directly caused by disabling/enabling V-Sync, it is just what I have noticed.

This is relevant to my current project where I want to reliably detect when a mouse is on a CollisionShape2D objects, while they are overlayed with UI. If there is any fix it would be nice to know.

Thanks.

Physics picking input events are the last ones processed as explained in

The Control nodes will take precedence and block the input event from propagating to other objects.

Also, as explained in the CollisionObject2D.mouse_entered documentation:

Note: Due to the lack of continuous collision detection, this signal may not be emitted in the expected order if the mouse moves fast enough and the CollisionObject2D’s area is small. This signal may also not be emitted if another CollisionObject2D is overlapping the CollisionObject2D in question.

Which means that, because these input events will only be checked in the physics tick, fast movement may not be registered.

If you also disable v-sync then… yeah. The problem will get worse as the input events will be processed as fast as possible while the physics input events will only be processed at the physics rate you have set in your project (60 ticks per second by default)