Touch events not working on Android Beta

Hi - I noticed that scrolling in our game was going slowly on Android beta (build number CP11.251209.007.A1, tested on a Pixel 8a and a Pixel 6 Pro). Digging in a little more I saw that actually dragging sprites around the screen also was slow and jerky. We’re using Defold 1.11.2 currently.

I made a little debug project that demonstrates this. On this beta OS, our touch debug screen only reports the pointer (action.x/y) and it updates infrequently; touch (action.touch) never arrives. On older Android versions (including current live v16 also tested on Android 13, the same build works correctly with continuous updates and full touch data.

touch_debug_standalone.zip (12.3 KB)

I guess the issue is with the Android beta but thought we should let you guys know in case there’s anything needs to be done to Defold to cater for this.

Thanks!

local function format_touch_text(action)
	local lines = {}
	if action.touch then
		table.insert(lines, string.format("touches: %d", #action.touch))
		for i, touch in ipairs(action.touch) do
			table.insert(lines, string.format("%d id:%s x:%.1f y:%.1f", i, tostring(touch.id), touch.x, touch.y))
		end
	end
	if action.x and action.y then
		table.insert(lines, string.format("pointer x:%.1f y:%.1f", action.x, action.y))
	end
	if #lines == 0 then
		lines[1] = "no touch"
	end
	return table.concat(lines, "\n")
end

function init(self)
	self.debug_text_node = gui.get_node("debug_text")
	gui.set_text(self.debug_text_node, "touch debug")
	msg.post(".", "acquire_input_focus")
end

function final(self)
	msg.post(".", "release_input_focus")
end

function on_input(self, action_id, action)
	if not action then
		return false
	end
	if action.touch or action.x or action.y then
		gui.set_text(self.debug_text_node, format_touch_text(action))
	end
	return false
end

A little more on this. If I switch on ‘show touchpad input’ and ‘pointer location’ in the phone’s Developer Options, these work fine, both outside our Defold game and in it.

If I play the game (or run my test app) in html5 mode, again, the touches/input are fine. This suggests there’s something going wrong between the Android OS beta and Defold which is causing these events to have no x,y values.

Thanks. Can you please create an issue on GitHub?

Thanks Bjorn, done

1 Like