-
Notifications
You must be signed in to change notification settings - Fork 131
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
transferOut() Is there a limit on the transfer size #209
Comments
Some operating systems impose limitations on how much data can be part of pending USB transactions. If you check about://device-log you should see the low-level operating system error which triggered the |
Is this limitation for chrome? If I transfer 500 MB of files from the command line, it will work. |
I think he means that Google fastboot is sending 500MB buffer to usb everytime. But after detailed review, the real usb_linux.cpp uses 16KB buffer to send it. So case closed |
thanks all. |
but is there any webAPI to check os limit? |
Here is the experiment
sample code like this
if chunk is 16KB buffer, the time is about 0.88ms ~ 1.00 ms you may notice that 15MB is 960 time of 16KB, but 522ms is only 593 times of 0.88 ms. almost doubled. |
The additional time is likely due to the overhead of submitting and asynchronously waiting for all those USB transfers to complete. The native fastboot utility uses the Linux USB API in synchronous mode and so likely has lower latency, A good trick for reducing the latency of USB transfers is to have multiple in flight so instead of sending only one 16KB transfer at a time send two or three and replace them with the next transfer when each completes. That's obviously more complicated but could easily be encapsulated into a helper function. |
I didn't get it.
|
When you submit multiple transfers to an endpoint they will execute in order. It builds up a queue of data for the USB host controller to transmit to the device. Giving the host controller multiple queued chunks improves performance because it doesn't have to involve your code (or even the operating system) to find the next chunk. Each time a chunk is fully transmitted it will notify your code that it should provide more data. These tests provide a couple examples of submitting multiple transfers like this. The purpose of the tests is in fact to check that they execute in the correct order. These examples exercise In the first example there are only 3 transfers and so we wait for completion explicitly. The second example is more dynamic and keeps a configurable number of transfers in flight, submitting a new one whenever one completes in order to keep the same number going all the time. In the case of |
I see you mentioned about "limit" 3 transfer and wait the first one to finish, and then push the fourth one. I'm not sure if there any sideeffect of calling a big amoung of transferout |
I believe that for platforms which limit transfer size the limitation applies to the total number of bytes across all pending transfers and so submitting 1000 transfers all at once wouldn't help you stay under the limit. The tests linked above have an example of the necessary code and it's not all that complicated. |
i tried like this. and it works perfectly. Thanks
|
Just to satisfy my curiosity, how does this version compare to your earlier benchmarks? |
I flashed 7.3 GB file to android device. (since transfer and flash process are both involved in the benchmarks. the real benefit should be more than 30%)
This makes me amazed that it's even faster than native fastboot. I think this really should be in the document. |
CC @beaufortfrancois to get this "one weird trick" into our WebUSB developer documentation. |
I've started a PR at GoogleChrome/web.dev#7248 to update our documentation. Note that I've updated the snippet to wait for last remaining transfers. Let me know if that works better for you @demonguy . |
It's really honored that i can contribute to webUSB in this way. And your example codes hint me that i forget |
And here it is: https://web.dev/usb/#limits-on-transfer-size |
I use transferOut(this.epOut, 50mb data) send to device but failed.
log: DOMException: A transfer error has occurred.
Is there a limit on the transfer size?
The text was updated successfully, but these errors were encountered: