On_input action - table too large for msg.post

We have some code based on the cursor_and_gesture example from defold-input.
Recently we’ve had problems with the game freezing (not responding to input, but music continues) and I’ve noticed the following in our analytics:
buffer (2026 bytes) too small for table, exceeded at key for element #9

This is in code that’s equivalent to the following in cursor_and_gesture/controller.script:

function on_input(self, action_id, action)
	if self.forward_input then
		msg.post("#cursor", "input", { action_id = action_id, action = action })

How large can the action table be? On PC builds it looks pretty small. Has it possibly increased in size recently, and is it possible that other code could be adding values to it, increasing its size?

Yes, it has increased in size in this release if you have added a bindning for GAMEPAD_RAW in which case you will getting all button, hat and axis values:

1 Like

We’re on 1.2.185 so it probably isn’t that, and we don’t use game pads anyway.
I also tried pressing all my fingers on the screen at once to generate multiple touch events in the actions table, and that wasn’t enough to trigger the error. Something else is making it really big.

I suggest that you iterate over the keys and values and print them, either using pprint(action) or using a for loop:

for k,v in pairs(action) do
	if type(v) == "table" then
		print(k, "=")
		print(k, "=", v)

EDIT: Multi-touch will increase size of the actions table, especially if you have several touch points active at the same time.

1 Like

I tried multitouch already, and 5 fingers (the maximum) didn’t cause any problems.
I haven’t seen the problem myself - the only people who have don’t use the editor, so pprint won’t help as such - I’m going to try something like GitHub - deepmind/lua-pprint: A pretty print library for torch and lua. to dump the table to a file, and upload it to a test server.


I managed to (kind of) reproduce this problem when trying to reproduce a different issue.

I was building from the editor and deploying to the iPhone, and because the display sleep timer was set to the minimum (30 seconds), I was tapping the screen to prevent it sleeping.
That caused action.touch to have many more elements than normal - up to 11 instead of the normal limit of 5 - and then the table was too large to be passed in a message.

It’s less clear if this could happen in normal play, but there is probably some kind of input sanitisation that could be added to the engine to eliminate the possibility.

1 Like

Wow, interesting. And quite surprising to be honest. action.touch should have the exact same amount of entries as there are fingers/touch points on the screen.

Have reproduced this in defold-input.
Reported as https://github.com/defold/defold/issues/6028