Skip to content

A fast 2D and 3D game engine — TypeScript SDK, C++/WebAssembly core, visual editor. Ship one project to web, desktop, WeChat MiniGames, playable ads, and native Android / iOS.

fix(ui): a quick tap on a slow frame still clicks

esenginebd7dcca1b0ca
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 89ad7ec5d..2671632bd 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -22,6 +22,7 @@ published separately; it ships inside the editor.
### Fixed
+- A quick tap on a slow frame still clicks a button: a finger that landed and lifted between two frames was seen only lifting, so the button never saw a press.
- A tap on vivo's quick game lands where the finger is: the host reports touches in physical pixels, and every tap landed off the screen.
- Games on vivo's quick game run past their first frame: the frame loop now hands requestAnimationFrame a handler the runtime accepts.
- The debug channel works on vivo's quick game: logs arrive in batches, and a replay is sent at the size the Frame Debugger shows instead of the whole screen.
diff --git a/sdk/src/ui/input/pointerBook.ts b/sdk/src/ui/input/pointerBook.ts
index d3146277b..471cf99dd 100644
--- a/sdk/src/ui/input/pointerBook.ts
+++ b/sdk/src/ui/input/pointerBook.ts
@@ -43,10 +43,10 @@ export interface UiPointerEvent {
export const MOUSE_POINTER = -1;
/**
- * This frame's pointers. A touch host synthesizes mouse button 0 from the FIRST
- * finger, so while any finger is on the glass the fingers ARE the pointers —
- * counting both presses every control twice. A finger that lifted this frame is
- * still a pointer, carrying where it lifted: that is where its release lands.
+ * This frame's pointers: the fingers while any is on the glass (a touch host also
+ * synthesizes button 0 from the first, which would press every control twice),
+ * else the mouse. A finger that lifted this frame stays, where it lifted — and one
+ * that also landed this frame was pressed too, or a quick tap on a slow frame is lost.
*/
export function uiPointersOf(input: InputState): UiPointerSample[] {
const pointers: UiPointerSample[] = [];
@@ -59,7 +59,8 @@ export function uiPointersOf(input: InputState): UiPointerSample[] {
}
for (const t of input.touchesEnded.values()) {
pointers.push({
- id: t.id, x: t.x, y: t.y, down: false, pressed: false, released: true, hovers: false,
+ id: t.id, x: t.x, y: t.y, down: false,
+ pressed: input.touchesStarted.has(t.id), released: true, hovers: false,
});
}
return pointers;
diff --git a/sdk/tests/ui-multi-pointer.test.ts b/sdk/tests/ui-multi-pointer.test.ts
index ceaed11e6..33a540062 100644
--- a/sdk/tests/ui-multi-pointer.test.ts
+++ b/sdk/tests/ui-multi-pointer.test.ts
@@ -131,4 +131,14 @@ describe('the pointer set a frame of input makes', () => {
expect(pointers).toHaveLength(1);
expect(pointers[0]).toMatchObject({ id: 3, x: 70, y: 90, down: false, released: true, hovers: false });
});
+
+ it('clicks with a tap that landed and lifted inside one frame', () => {
+ // A 10 fps quick-game emulator dropped every quick tap: the finger was gone by the frame.
+ const input = new InputState();
+ input.touches.set(0, { id: 0, x: 10, y: 5 });
+ input.touchesStarted.set(0, { id: 0, x: 10, y: 5 });
+ input.endTouch(0);
+ const events = new UiPointerBook().step(uiPointersOf(input), screen, () => true);
+ expect(kinds(events, BUTTON_A)).toEqual(['press', 'release', 'click']);
+ });
});
diff --git a/tools/releaseNotes.mjs b/tools/releaseNotes.mjs
index 362b482cb..99be9ad32 100644
--- a/tools/releaseNotes.mjs
+++ b/tools/releaseNotes.mjs
@@ -1090,4 +1090,6 @@ export const NOTED = {
{ note: 'The debug channel works on vivo\'s quick game: logs arrive in batches, and a replay is sent at the size the Frame Debugger shows instead of the whole screen.' },
'fix(minigame): a tap on vivo\'s quick game lands where the finger is':
{ note: 'A tap on vivo\'s quick game lands where the finger is: the host reports touches in physical pixels, and every tap landed off the screen.' },
+ 'fix(ui): a quick tap on a slow frame still clicks':
+ { note: 'A quick tap on a slow frame still clicks a button: a finger that landed and lifted between two frames was seen only lifting, so the button never saw a press.' },
};