-
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
lnc+util: assign WASM callbacks to a namespaced scope #79
Conversation
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.
I'm not sure why that's happening. Can you confirm that the callbacks for all four connections are all being called? It should be logged in the console. You can also check that the local/remote keys are set for all 4 nodes in localStorage. |
@jamaljsr after doing some further testing it looks like we might be hitting some kind of rate limiting / DOS protection in Firefox. You can see in this first screenshot (firefox) only three of the WASM binaries are loaded - However in Chrome it works fine with 4 simultaneous connections - |
Interesting. I was not aware of that limitation, but it's definitely something we need to consider when handling multiple WASM instances. I wonder how the other browsers (Safari, Edge, Brave) handle it. Also mobile browsers may have strict limitations as well. |
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.
Approving this since my test script was able to connect 4 clients simultaneously in different namespaces using Chrome. Seems like we're hitting some other edge case in Firefox loading the WASM files. 🤔
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.
tACK. Great job, Jamal!
This PR updates the LNC class to no longer use the JS
global
object for the callbacks from the WASM client. The callbacks functions will now be nested under an object using thenamespace
as a name. So if the app usesnew LNC({ namespace: 'myapp' });
, the callbacks will be created on theglobal.myapp
object instead of previously being onglobal
.This depends on lightninglabs/lightning-node-connect#72 which has been merged into the
master
branch.Steps to test with the kitchen-sink demo:
make wasm
to produce the WASM binarylnc-web
repolightning-node-connect/example/wasm-client.wasm
intolnc-web/demos/kitchen-sink/public/
kitchen-sink/src/App.js
to use the new WASM binary and your own pairing phrase and namespacelnc-web
code. Then start the appgetInfo
window.onLocalPrivCreate
isundefined
and thattypeof window.myapp.onLocalPrivCreate
isfunction
Note: This PR also fixes an issue in the
credentialStore
where it was overwriting the data on every page reload in the kitchen-sink demo. This was due to the password being provided in the constructor.