-
Notifications
You must be signed in to change notification settings - Fork 17
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
Offscreen API #303
Offscreen API #303
Conversation
Tackling some internal complications with spawning workers in a service-worker context, but should be ready for review soon. We'll need to additionally consider fallback scenarios and the proper error handling / propagation (reference #295?) for serial builds. |
@grod220 building the actions in parallel in the offscreen document and passing the prebuilt vector of actions back to the extension is working, but calls to the |
Ah, you've run into our classic wasm serialization issue. We've each run into this independently 😅 . Think we should document this somewhere. When crossing the javascript->wasm boundary, you can pass javascript objects. However, it's not a guarantee that serde can deserialize it into structs. For that to be successful, it has to be in json format (protobuf rules though). Bufbuild provides the helper const transaction = build_parallel(
batchActions.map(action => action.toJson()),
req.transactionPlan.toJson(),
witnessData.toJson(),
req.authorizationData.toJson()
) |
Benchmarks on my machine ( The broadcasting operation In terms of outstanding work before this PR can be merged, @turbocrime we should implement a fallback mechanism for serial builds in cases where web workers are not supported. One idea is to introduce a global variable like We can further consider load-balancing the workload distributed to the web-workers using a queue when the number of |
The "broadcast" step in the web code is currently a hardcoded 6s timeout. Two points:
@grod220 is currently working on replacing the hardcoded timeout with detection logic. |
Going from 30s build time to 12s build time is amazing! If we can also cut down some of the wasm overhead, we're stacking improvements that get us pretty close to the ideal scenario of being able to build the transaction in the time it takes the user to review the transaction in the approval dialog. |
ah I was wondering why it was hard-coded specifically to 6s! |
Agreed #113 shouldn't be blocked for much longer. |
In what case would web workers not be supported? |
It's generally a good idea to check for web worker support (https://www.w3schools.com/html/html5_webworkers.asp). I referenced this chart (https://caniuse.com/webworkers), yet it suggests that 98% of devices wouldn't have an issue. |
@hdevalence If we don't implement the check, there's no reason to keep the |
From the caniuse.com page, we can unconditionally use web workers, since we're only targeting Chrome |
hey, i think have quite a lot of feedback on the event and message flow, so i'm just going to add some commits to this pr. we should pair when possible |
I paired with Gabe yesterday, and am currently refactoring the underlying serialization formats as |
* messy wip * cool wip * pair L + Tal changes * satisfy linter * removed timers * fix action length * add comments --------- Co-authored-by: turbocrime <[email protected]>
I think we're close to be able to merge once the last few comments are addressed. |
The offscreen lifecycle management is sufficient for now. In a separate issue, we'll make it more complete and enable servicing multiple simultaneous requests. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great job! Have some remaining points from me. Really excited to get this in though. After this (and Christmas), we should do a release and get users on the new fast builds.
References #146
This PR supports building transactions in the web in parallel using web-workers! Additionally, the
serial
build method has been deprecated.The output console logs can be monitored by navigating to
chrome://extensions
, clickingdetails
, and theninspect view
.