Skip to content
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

Float64Array is converted to Uint8Array when sent over IPC #17195

Closed
vshymanskyy opened this issue Mar 2, 2019 · 5 comments
Closed

Float64Array is converted to Uint8Array when sent over IPC #17195

vshymanskyy opened this issue Mar 2, 2019 · 5 comments
Assignees
Projects

Comments

@vshymanskyy
Copy link

vshymanskyy commented Mar 2, 2019

  • Electron Version:
    v1.8.8, v3.1.4, v4.0.6
  • Operating System:
    • Windows 10 (1803)

Expected Behavior

Float64Array and other Typed Arrays should preserve their type and correct values.

Actual Behavior

Main process sends an object with multiple Float64Array instances, Renderer gets all of them converted byte-wise to Uint8Array.

P.S. With electron 1.7.16 it was converted to Array with correct values.

May be related to #13055 or #6572

@welcome
Copy link

welcome bot commented Mar 2, 2019

👋 Thanks for opening your first issue here! If you're reporting a 🐞 bug, please make sure you include steps to reproduce it. We get a lot of issues on this repo, so please be patient and we will get back to you as soon as we can.

To help make it easier for us to investigate your issue, please follow the contributing guidelines.

@miniak
Copy link
Contributor

miniak commented May 12, 2019

@vshymanskyy what do you mean exactly by sent over IPC? Using ipcRenderer.send() / ipcMain.on() or the remote module?

@miniak miniak self-assigned this May 12, 2019
@MrNovado
Copy link

MrNovado commented Aug 22, 2019

@miniak having the same issue. It's ipcRenderer.send(). Also reproducible with Float32Array . "electron": "5.0.6", windows.

@miniak
Copy link
Contributor

miniak commented Oct 29, 2019

This is now natively supported in Electron 8

IPC between main and renderer processes now uses the Structured Clone Algorithm. #20214

This change cannot be backported to older major versions due to semver.

@miniak
Copy link
Contributor

miniak commented Oct 29, 2019

in older versions you can do this as the underlying ArrayBuffer is transferred:

main

const array = new Float64Array(10)
mainWindow.webContents.send('test', array, array.byteOffset, array.length)

renderer

ipcRenderer.on('test', (e, buffer, byteOffset, length) => {
  const array = new Float64Array(buffer.buffer, byteOffset, length)
  console.log('test', array)
})

@miniak miniak closed this as completed Oct 29, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
3.1.x
Unsorted Issues
Development

No branches or pull requests

4 participants