qemu-ios icon indicating copy to clipboard operation
qemu-ios copied to clipboard

rapid taps cause a divide by zero in the multitouch device

Open lemonjesus opened this issue 3 years ago • 2 comments

rapidly clicking the emulator (and sometimes randomly) causes a Floating Point Exception which, according to gdb, is caused by the following lines where elapsed_ns and s->last_frame_timestamp are the same so you get a divide by 0 error:

https://github.com/devos50/qemu/blob/7385a192485af58f975393fa04b69fea9300d492/hw/arm/ipod_touch_multitouch.c#L315-L316

I suppose you could check for this and increase elapsed_ns by 1 to avoid a crash, but I'm not sure what the implication of that would be in terms of timestamping and/or possibly glitchy movements.

lemonjesus avatar Jan 02 '23 07:01 lemonjesus

I can confirm this seems to work. Touch seems accurate still. And it doesn't crash when rapid clicking.

frame->finger_data.velX = diff_x / (elapsed_ns+1 - s->last_frame_timestamp) * 1000; frame->finger_data.velY = diff_y / (elapsed_ns+1 - s->last_frame_timestamp) * 1000;

coreycusick avatar Sep 13 '23 07:09 coreycusick

I can confirm this happens; it will also happen when repeatedly clicking at slow speeds (<2 per second)

It also seems to be noticably more likely to crash during startup, but will still crash after startup if repeated clicking occurs

preland avatar Nov 16 '23 22:11 preland