VR: changing camera CFrame on button click causes "Maximum event re-entrancy depth exceeded"

Updating the camera’s CFrame to a new value inside a ‘MouseButton1Click’ listener, causes multiple clicks to be detected. Often even causing the following error:
Maximum event re-entrancy depth exceeded for GuiButton.MouseButton1Click

Expected behavior: the click event handler shouldn’t recursively be called. It should only be called once.

The following studio file replicates the issue. It sets the camera to a different offset inside a ‘MouseButton1Click’ listener function.
VR_button_click_bug.rbxl (56.6 KB)

I understand the minimal example might be a bit far-fetched (not occuring in practice), but it does replicate a bug we have with our character selection menu. In our game we want to update the camera whenever a new character has been selected (make the character fit on screen). This is done in a click listener, causing the bug to occur.

Used VR device: quest 2; occured both when connected to pc, and standalone with the beta app.

Band-aid fix: adding a task.wait(0.1) in the click listener before updating the camera’s cframe.

Suspected cause: the UI shifts when the camera’s CFrame is updated. This probably does a recalculation of clicks?

3 Likes

We’ve filed a ticket into our internal database for this issue, and will come back as soon as we have updates!

Thanks for flagging!

3 Likes

This does indeed look like incorrect behavior. However, we don’t plan on fixing the issue in the engine as it is a rare enough case - your workaround is a good one and we can recommend it. Thanks for the report, these are very helpful!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.