-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[question] Why are WebHID calls to sendReport
queued with concurrency 1?
#111
Comments
Honestly, I don't quite remember why I wrapped it in a promise queue. Perhaps one could do a synthetic test and send multiple commands and see what happens? However, if you're looking to send something in a synchronous manner, I don't think you'll be able to do that anyway, since the webhidDevice.sendReport() is asynchronous in itself, so you'll have no way of knowing if the commands have actually been sent, right? |
I think this is a little related to #106 I suspect what happened is this code was based on the streamdeck library, which uses a queue because it sends messages in multiple packets that need to not be interleaved with other calls to For the xkeys where the writes are only ever a single hid packet, it does look unnecessary |
The simple commands for setting LEDs and such are only a single packet. However, there are cases when sending multiple packet writes are required with X-keys. Since we support the generic "write data" command we can use web hid for maintenance of X-keys firmware for example. These operation would require multiple writes in the proper order. |
That's acceptable for my use case, it's a fire and forget as the app is closing. Based on the info in this thread given that I am only sending commands for setting LEDs I will go ahead with this approach. |
I am looking to perform multiple writes to the device in a synchronous manner. The current wrapper method implementation sequentially queues the
sendReport
promises:xkeys/packages/webhid/src/web-hid-wrapper.ts
Lines 24 to 32 in e9d925e
Is there a reason this is done? Wondering if there were any observed issues or concerns with firing for example a few dozens
sendReport
calls without waiting for any of them to resolve (before firing off the next one).The context is I am looking to perform some cleanup of the device on
beforeunload
, which must be sync.The text was updated successfully, but these errors were encountered: