I have discovered a very strange crash that I have been unable to narrow down to a specific engine feature, but it seems to all be related to the character somehow.
Repro steps:
- Download and open the repro file:
crash-escmenu-repro-minimal.rbxl (98.9 KB) - Start a full playtest
- Wait a few seconds. Eventually, a red, flashing, 3D model of the word “ERROR” will be equipped to your character’s right hand to show when you can trigger the bug
- Press the Escape key or whatever key you use to open the Roblox escape menu
Expected behavior:
The escape menu opens, no shenanigans.
Actual behavior:
The engine crashes the instant Escape is pressed.
This appears to occur due to the following code:
local function BoundFunctionProxy(ActionName: string, ActionState: Enum.UserInputState, InputObject: InputObject)
if ActionState == Enum.UserInputState.Cancel then
warn(`Mutating the input state for {ActionName}!`)
ActionState = Enum.UserInputState.End
end
local ActionResult: Enum.ContextActionResult? = BoundFunction(ActionName, ActionState, InputObject)
if not ActionResult then
return Enum.ContextActionResult.Pass
else
return ActionResult
end
end
, in the ModuleScript
ReplicatedStorage.SharedModules.ButtonControlsUtility
. Removing the line ActionState = Enum.UserInputState.End
in the if
-statement that checks if ActionState
is Cancel
(which appears to be triggered when the Escape menu is opened), fixes the crash.
I sincerely apologize that the repro file is… a little hefty. I tried to and have reduced it significantly, but after multiple hours of attempts to reduce it further, I figure that’s it probably not worth it and (hopefully) won’t make that much of a difference in this case.
Main points:
- A
ContextActionService
wrapper is used -
ControllerManager
s are used with a Luau state machine (StarterPlayer.StarterCharacterScripts.ControllerStateMachine
) and Luau character initialization script (ServerScriptService.InitializeCharacters
) - All bound functions are related to the character in some way
- All bound functions are mis-fired at the same time (because the
Cancel
state is called on all of them regardless of whether their input was ever fired) - Some of the code isn’t very good because I’ve haphazardly removed large swathes of it and the datamodel, and some of it was just bad when I first wrote it anyway or has become obsolete
- The action happens in the
ReplicatedStorage.SharedModules.ClientModule
ModuleScript
and theServerScriptService.ServerWeapons
Script
Workaround: In my case, just don’t change ActionState
.
Beta features: Disabling them all changes nothing; the crash still occurs.