dennis95 / dennix

Dennix is a unix-like hobbyist operating system written from scratch.
ISC License
163 stars 13 forks source link

GUI I/O has ~1 second delay #34

Open ghost opened 1 year ago

ghost commented 1 year ago

Every time I move the mouse or type something in the terminal (while running the GUI), there is ~1 second delay between me moving the mouse, and the cursor actually moving on the screen. The issue is happening to me in QEMU while using multiple computers for virtualization (Linux x64 host, and macOS m1 host with emulated x86_64 hardware). Not sure if it happens with any other hypervisors.

dennis95 commented 1 year ago

It is unfortunately a known issue that the GUI does not have good performance. The cause for the mouse lag is that the window is being redrawn for every mouse packet received: https://github.com/dennis95/dennix/blob/master/libdxui/src/events.c#L491 The performance impact depends on the used hardware and the display resolution.

The redraw should only happen after all mouse packets were processed and the redraw should be limited to the area the cursor was in before and after all packets were processed.

Another performance issue in the GUI is #35.

ghost commented 1 year ago

I don't have much time to look through the code, but from what I understood the whole screen gets redrawn on every interrupt (note: I might be wrong). If that's the case, functions from here and here could be implemented so that the redraw happens only on the regions which are affected by the mouse (i.e. there's no reason to redraw the terminal window if we move the mouse on the desktop). The same thing should happen when typing - redraw only the terminal window when we type.

This really pumped up the performance of my own window manager (virtually no flickering even without the use of double buffering)

Dashbloxx commented 1 year ago

Run with KVM:

qemu-system-x86_64 -accel kvm -cdrom dennix.iso

This should really make the mouse work normally/more instantly.

Or, run it on bare metal, which should work even better.

ajh123 commented 1 year ago

Running inside Virtual Box seems less slower for me.