tiny-pilot / tinypilot

Use your Raspberry Pi as a browser-based KVM.
https://tinypilotkvm.com
MIT License
3.01k stars 252 forks source link

Paste text asynchronously #1558

Closed jdeanwallace closed 1 year ago

jdeanwallace commented 1 year ago

Resolves https://github.com/tiny-pilot/tinypilot/issues/1026 Dependent on https://github.com/tiny-pilot/tinypilot/pull/1557

Writing individual keystrokes to the HID interface is slow, resulting in API requests to paste large amounts of text to timeout. This PR writes multiple keystrokes to the HID interface at once, and does so asynchronously.

Review on CodeApprove

mtlynch commented 1 year ago

I'd like to take a step back and rethink how we resolve #1026.

I know that this is still in draft, but it seems like we've created a significant amount of churn moving code from JS to Python when it seems like the underlying problem is that the backend is not staying responsive to HTTP/websockets requests when it's processing a large number of sequential HID messages. I'd like to solve that underlying problem before we get too deep into the JS -> Python migration because it doesn't seem like this fix strictly depends on the migration.

My concern with this PR is:

Is there a way we can fix #1026 in the app/hid modules? It's okay if we have to adjust the semantics to add a param like release_after or something, but I don't want to bleed out things like buffers or multiprocessing.

I'd like to solve the threading issue first, because if we fix that, then maybe the whole chain starting from #1545 becomes unnecessary.