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
Fix support for typed arrays in remote/rpc-server #13055
Conversation
There are tests failing related to this change. |
9c04740
to
b2a9ebb
Compare
@zcbenz should be fixed now |
@zcbenz I still have issue with
so the test does not even seem to be correct. Just try changing you'll get this error
|
@zcbenz I would suggest adding full support for all typed array types in a separate PR, I am willing to do that. |
Sounds good to me 👍 |
b2a9ebb
to
97bd92d
Compare
@zcbenz I've changed my mind, let's do it in this PR. It's quite simple |
ca16d8a
to
7c3dd39
Compare
7c3dd39
to
642dc43
Compare
@zcbenz I think I'm done with the changes. Can you please review? |
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.
👍
Adds support for
ArrayBuffer
and all typed array views (except forDataView
) in the remote module.Also makes the IPC payload much smaller (in the net module tests the payload goes down from approx 13 KB to 5 KB) by using base64 encoding instead of an array of values.
for example when calling
electron.remote.getCurrentWindow().getNativeWindowHandle();
this is the JSON with the return valuebefore:
[{"type":"buffer","value":{"type":"Buffer","data":[32,72,27,0,64,96,0,0]}}]
after:
[{"type":"buffer","value":{"type":"Buffer","data":"oAzG+9B/AAA="}}]
Also calling
Buffer.from(value)
instead ofBuffer.from(value.buffer)
would create an unnecessary copy of the data instead of just creating a different view of the underlying memory.https://nodejs.org/api/buffer.html#buffer_class_method_buffer_from_buffer
https://nodejs.org/api/buffer.html#buffer_class_method_buffer_from_arraybuffer_byteoffset_length